Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I'm having a problem where a single development machine has stopped receiving SQL errors when it attempts to use an illegally formatted string as a uniqueidentifier (as part of a few different unit tests). The query is this:

SELECT * FROM MyTable WHERE Id = 'this is not a legally formatted identifier'

(where the 'Id' column is of type UNIQUEIDENTIFIER)

When this query is executed against a database from InteractiveSQL, or via the C API on any of our other development PCs, this generates a -157 error: "Cannot convert 'this is not a legally formatted identifier' to a uniqueidentifier", as we expect. On this one development machine, though, no error is generated when the query is issued via the C API, and the query appears to be processed as if it had been able to successfully convert it into a uniqueidentifier -- it simply returns no result rows. (executing the query via InteractiveSQL on this problematic machine generates the error as expected)

The only thing I'm aware of which makes this development machine different from the others is that I upgraded it to use SQLAnywhere, whereas the other machines are running This behaviour remains the same, though, when I downgrade back to

Is there perhaps a local setting or configuration file that could be causing this unexpected lack-of-error only when executing the query through the C API, and only on this one computer? I'm just trying to work out why I'd be seeing different behaviour on this single Mac computer than on any of the other Macs and PCs.

asked 13 Mar '13, 20:32

Trevor%20Powell's gravatar image

Trevor Powell
accept rate: 0%

edited 15 Mar '13, 22:15

Mark%20Culp's gravatar image

Mark Culp

I don't have installed at the moment, but I can confirm that and behave as expected: "If the data type of any argument is UNIQUEIDENTIFIER, convert to UNIQUEIDENTIFIER and compare." according to ...and therefore raises an error...

Cannot convert 'this is not a legally formatted id...' to a uniqueidentifier SQLCODE=-157, ODBC 3 State="07006"

However, it probably has nothing to do with the API or any configuration file, because the comparison and the resulting exception is the exclusive responsibility of the server. Comparison rules are baked-in, so to speak, not subject to the whims and vagaries of an unstable environment or a steenking client (no offense intended, some of my best friends are clients :)

So... sounds like a bug to me, given your testimony.

(14 Mar '13, 09:06) Breck Carter
Replies hidden

So... sounds like a bug to me, given your testimony.

However, when the database engine is downgraded to, then the behaviour should be OK again, right? - And according to the OP, it is not. (All under the assumption the database engine is running locally...)

FWIW, with, the following simple test via DBISQL raises -157 as expected, too:

SELECT cast('this is not a legally formatted identifier' as UNIQUEIDENTIFIER)
(14 Mar '13, 09:43) Volker Barth

@Volker: That doesn't exactly test tpowell's case, which was an implicit conversion that apparently doesn't get attempted. Instead, try this...

SET @id = NEWID();
  FROM dummy
 WHERE @id = 'this is not a legally formatted identifier';
(14 Mar '13, 09:47) Breck Carter

Thanks for the correction. With, it raises -157, too:) - But then again, tested with DBISQL, not with the C API...

(14 Mar '13, 10:03) Volker Barth

@VolkerBarth Yes, the database engine is running locally, in all tests. The bad behaviour is limited to the one machine which had been upgraded to, and persisted after being downgraded again, and only via the C API; every other interface I've tried throws the errors that one would expect. I haven't yet tested a clean install of SQLAnywhere, but that'll be my next step. The simple test you mention executes (via the C API) without throwing an error on all our development machines -- both upgraded and non-upgraded ones -- but returns no rows. It does throw an error under InteractiveSQL on all machines, under both versions.

(14 Mar '13, 19:30) Trevor Powell

Clean install of results in the error being thrown as expected. A clean install of does not throw the error, and also does not return any values (again, only via the C API). An in-place downgrade from to causes the C API to continue to not throw an error. Neither version 3798 nor 3853 nor 3853-downgraded-to-3798 give an error or a result from the 'SELECT cast' statement suggested by @volker, when issued via the C API. To me, this is starting to feel like it might be a bug in the C API, introduced between 3798 and 3853.. but I can't explain why it would persist after the in-place downgrade from 3853 to 3798.

(14 Mar '13, 20:25) Trevor Powell

I can't seem to reproduce this via the C API on my Windows machine with (I unfortunately do not have a Macintosh handy to test this on).

With capi.sql:

SET @id = NEWID();
  FROM dummy
 WHERE @id = 'this is not a legally formatted identifier';

(and assuming you have Visual Studio set up:)

cd "%SQLANY12%\sdk\dbcapi\examples"
dbinit capi.db
dbeng12 capi.db
dbcapi_isql.exe -c "uid=dba;pwd=sql;eng=capi"

Connected successfully!

dbcapi_isql.exe> read capi.sql
Estimated number of rows: 1
1 rows returned

Estimated number of rows: -1
0 rows returned
Failed: [-157] 'Cannot convert 'this is not a legally formatted id...' to a uniqueidentifier'

Warning: [105] 'Procedure has completed'
Total elapsed time = 5929ms

(14 Mar '13, 21:36) Jeff Albion
showing 1 of 7 show all flat view
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Mar '13, 20:32

question was seen: 1,967 times

last updated: 15 Mar '13, 22:15