on ‎2014 Aug 28 2:27 AM
I got syntax error at end of the query near ; SQLCODE=-131, ODBC 3 State='42000' I believe the error stems from using ...dba.$Regex_Match(...
begin declare @excludeSubAcctAliasRegexPatternLst long varchar; declare @acct_id int; set @excludeSubAcctAliasRegexPatternLst='test'; set @acct_id=1; select subAcct_ID, acct_type_short_name from dba.subAcct where acct_id = @acct_id or not dba.$Regex_Match(acct_type_short_name, @excludeSubAcctAliasRegexPatternLst); endwhere dba.$Regex_Match is defined as
ALTER FUNCTION "dba"."$Regex_Match"( in @str2Match long varchar,in @regexPattern long varchar ) returns bit not deterministic external name 'Q:\\\\SqlAnywhereExtEnv\\\\SqlAnywhereDotNetDll.dll::SqlAnywhereDotNetDll.Util.regexMatch( string, string) bool' language CLRand the corresponding clr member is
public static bool regexMatch(string s, string pattern) { try { return Regex.IsMatch(s, pattern, roIcEc); } catch { } return false; }I have used successfully other members from the dll for clr proc. this is my first time using clr function.
Request clarification before answering.
I think the error comes from the fact that you treat the bit datatype as a boolean value which is not valid in SQL Anywhere - cf. that sample which also raises -131 (SQLE_SYNTAX_ERROR):
begin declare b bit = 0; select * from sys.dummy where not b; end;In contrast, the following comparison with 0 or 1 will work:
begin declare b bit = 0; select * from sys.dummy where b = 0; end;So I guess you just might have to change the second condition to "...or dba.$Regex_Match(acct_type_short_name, @excludeSubAcctAliasRegexPatternLst) = 0"
FWIW, there's not boolean datatype in SQL Anywhere.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.