with SQL Anywhere Network Server Version 17.0.10.6160 I experience the following effect: SELECT MyCount = count() FROM Table WHERE TableID = '58693'; leads to the error "ERROR [42000] [Sybase][ODBC Driver][SQL Anywhere]Syntax error near ';' on line 1 " But SELECT count() as MyCount FROM Table WHERE TableID = '58693'; works fine. Can anyone explain? asked 22 Oct '20, 09:31 Martin |
Based on information provided in the support incident, I was able to reproduce this error. A database created pre-v17 and not upgraded will report a syntax error due to the trailing semicolon in some interfaces such as ODBC: SELECT MyCount = count() FROM Table WHERE TableID = '58693'; To reproduce, I modified the sample odbcselect to execute: SELECT mycount = count() FROM syshistory; which reported the syntax error in a database created with 16.0 Build 1691 but not after upgrading the database using 17.0 build 6160 or with a database created with that same 17.0 release. Several options to resolve this are available
answered 27 Oct '20, 23:39 Chris Keating 2
I have also reproduced this using the SQL Anywhere .NET driver with the same findings. There is a need to upgrade or create the database in v17 to get support for the semi-colon terminator for Transact-SQL based statements.
(28 Oct '20, 00:01)
Chris Keating
|
My SQL is a bit rusty... but I believe the first syntax (which generates the error) is TSQL which does not use semicolons to separate statements, whereas the second is WATCOM SQL which does use semicolons. answered 22 Oct '20, 09:50 Mark Culp |
I do not get a syntax error with the statement. Note that the first statement is TSQL dialect and the use of semicolons as a statement separator in TSQL was not supported until 17.0 and requires a database upgraded or created using 17. You can query the table syshistory to confirm the version of software used to create the database and whether the database has been upgraded and which version was used. That said, I also do not see an error with this statement using a v16 running on the same version of SA17 as you reported.
Interestingly enough, the first statement (used with MyTable instead of TABLE as table name for obvious reasons) returns 'Transact-SQL' both with 17.0.10.6175 and 16.0.0.2798:
You are right database was created using SA 16.0.0.1691, is that the culprit?
This is a message for future lurkers...
Sorry to be so late to the party, but...
absolutely positively DOES NOT WORK on SQL Anywhere 16...
...or SQL Anywhere 17...
...with or without the semicolon.
Details matter, especially when exploring the absurd differences between Transact SQL and Watcom SQL.
Details like copy-and-pasting actual code when asking questions on this forum.
"Obvious" was an exaggeration here, it took me a while to understand the "Error at character 30" when using "...FROM TABLE" :)