on 2011 Sep 14 2:10 PM
I am using SQL Anywhere Network Server Version 11.0.1.2044 with Interactive SQL Version 11.0.1, build 2044. When I execute the following statement in this ISQL,
select {fn right(StringColumn, 5)} from ATable;
I got the following Error:
Could not execute statement. Syntax error near 'fn right(StringColumn, 5)' on line 1 SQLCODE=-131, ODBC 3 State="42000"
When I execute the same statement in the ISQL Session of the Database Painter of PowerBuilder Version 12.1 Build 6875, I got two different results: 1.When the DelimitIdentifier='Yes' in the SQLCA.DBParm of the database connection string, it executes correctly. 2.When the DelimitIdentifier='No' in the SQLCA.DBParm of the database connection string, it gives me the following error message:
SQLSTATE = 37000 [Sybase][ODBC Driver][SQL Anywhere]Syntx error near 'from' on line 1
Should it work without setting DelimitIdentifier='Yes' for the database connection in PowerBuilder? Is it a bug for PB or SQL Anywhere?
Regarding select {{fn POSITION(StringColumn in 'abc')}} from ATable;
The ODBC driver escape syntax parser is looking for uppercase keywords like IN or FROM in scalar function syntax involving functions POSITION and EXTRACT. The string comparison should be done in a case-insensitive manner. This problem will be corrected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem with functions like RIGHT and the Powerbuilder DelimitIdentifier='No' option is that the ODBC driver places quotation marks around functions that are keywords when it rewrites the escape syntax.
So this ...
select {{fn right(DepartmentName,4)}} from Departments;
is rewritten as this ...
select "RIGHT"(DepartmentName,4) from Departments;
The PB DelimitIdentifier='No' option results in the server option "quoted_identifier" being set "off".
Of course, when it is "off", then "RIGHT" is interpreted as the literal value 'RIGHT' and this leads to the syntax error. It's as if you had tried to execute this ...
select 'RIGHT'(DepartmentName,4) from Departments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think what you are asking is "is it necessary to use the quotation marks?" For example create table foo (col1 char(65) default {{fn char(65)}}) becomes create table foo (col1 char(65) default "CHAR"(65)) but does there exist a case where something like create table foo (col1 char(65) default CHAR(65)) could result in a syntax error because CHAR (or whatever) is interpreted as a keyword rather than a function. I need a SQL syntax expert to answer this.
I don't believe iSQL is using ODBC to access the database engine. I'm not certain that ODBC escapes would be handled properly, being as they get "fixed up" by the driver before being sent to the database.
Possibly related google searches: SQL_ATTR_NOSCAN, SQLNativeSql
Not sure I can comment about DelimitIdentifier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Doubled braces does work in DBISQL, though it removed the first non-space character so you have to do like:
*select {{fn right(StringColumn, 5)}} from ATable;
instead of just:
select {{fn right(StringColumn, 5)}} from ATable;
That's a bug, probably in the SQL Anywhere's JDBC driver.
When I test the problem in PowerBuilder with ODBC connection, the following statements cause errors when the DelimitIdentifier is set to 'No' in the SQLCA.DBParm of the database connection string:
select {fn CHAR(40)} from ATable;
select {fn LEFT(StringColumn,5)} from ATable;
select {fn RIGHT(StringColumn,5)} from ATable;
while all other ODBC string functions work just fine, such as:
select {fn RTRIM(StringColumn)} from ATable;
select {fn SUBSTRING(StringColumn,1,1)} from ATable;
select {fn UCASE(StringColumn)} from ATable;
This inconsistency might be a bug in the ODBC driver for SQL Anywhere.
Here is a common problem for both JDBC and ODBC driver of SQL Anywhere:
The following statement works
select {{fn POSITION(StringColumn IN 'abc')}} from ATable;
while this does not work
select {{fn POSITION(StringColumn in 'abc')}} from ATable;
The only difference: "IN" is upper case while "in" is lower case. Should case matter?
Given that I would think that those function names that are reserved words in SQL Anywhere are problematic.
Note that I'm in the position to draw any conclusions from that.
No, the case should not matter, but in this specific case it did: http://search.sybase.com/kbx/changerequests?bug_id=684608. This has been fixed in 11.0.1.2678.
User | Count |
---|---|
62 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.