[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
McKoi escaping/formatting rules for text-parameters to custom function
- To: <mckoidb@xxxxxxxxx>
- Subject: McKoi escaping/formatting rules for text-parameters to custom function
- From: "Thomas Muller" <ttm@xxxxxxxxx>
- Date: Mon, 21 Jun 2004 15:23:08 +0100
- Delivered-To: mailing list mckoidb@mckoi.com
- Importance: Normal
- Mailing-List: contact mckoidb-help@mckoi.com; run by ezmlm
Hi,
I have some escaping trouble (I think) submitting a input to a custom
function (see previous posting: "Newbie: Can't access public member in
custom function".
McKoi's internal parsing fails with:
Caused by: com.mckoi.database.jdbc.MSQLException: Lexical error at line
1, colum
n 90. Encountered: "+" (43), after : "\'^\\"
at
com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface.handleExe
cuteThrowable(AbstractJDBCDatabaseInterface.java:289)
Extract:
if( ! number.startsWith( "*" ) ) {
number = "^" + number;
}
if( ! number.endsWith( "*" ) ) {
number = number + "$";
}
number = Utils.replace( number, "*", ".*" );
number = Utils.replace( number, "(", "\\(" );
number = Utils.replace( number, ")", "\\)" );
number = Utils.replace( number, "+", "\\+" );
number = Utils.replace( number, "?", "." );
number = Utils.replace( number, " ", "\\s" );
String query = "SELECT * FROM " + TABLE_PERSONS + " p
LEFT OUTER JOIN "
+ TABLE_MBX_USERS + " m ON p." +
JDBCPerson.COL_UID + "=m."
+ JDBCMbxUser.COL_UID
+ " WHERE"
+ " regexp_match('" + number + "',p."
+ JDBCPerson.COL_TELEPHONE_NUMBER + ")"
+ " OR regexp_match('" + number + "',p."
+ JDBCPerson.COL_PRIMARY_EXTENTION + ")"
+ " OR regexp_match('" + number + "',m."
+ JDBCMbxUser.COL_MBX_CLIENT_NUMBER +
")"
+ " OR regexp_match('" + number + "',m."
+ JDBCMbxUser.COL_SECOND_LINE + ")";
An example query that fails:
SELECT * FROM persons p LEFT OUTER JOIN mbx_users m ON p.uid=m.uid WHERE
regexp_match('^\+44\s\(0\)--$',p.telephone_number) OR
regexp_match('^\+44\s\(0\)--$',p.primary_extention) OR
regexp_match('^\+44\s\(0\)--',m.mbx_client_number) OR
regexp_match('^\+44\s\(0\)--$',m.second_line)
How should the pattern be escaped/formatted in order for McKoi to accept
it and push it through to the custom function?
Any input would be much appreciated.
Regards,
--
Thomas