Groups | Blog | Home
all groups > sql server odbc > september 2004 >

sql server odbc : ODBC Bug in SQL Server 8?



Peter Arrenbrecht
9/21/2004 2:45:08 PM
Hi all

If I prepare the following statement:

SELECT zA."ID" AS fA_A
, zA."IDFirma" AS fA_B
, zA."Name" AS fA_C
, zA."Vorname" AS fA_D
, zA."IDMandant" AS fA_E
, zB."ID" AS fB_A
FROM AtlasTest.Adresse AS zA
INNER JOIN AtlasTest.Mandant AS zB
ON zB."ID" = zA."IDMandant" AND (zB."ID" = ?)
WHERE zA."IDFirma" = 1
ORDER BY 1

the ODBC driver then returns 0 in SQLNumResultCols. If I change the "?"
to "1", however, everything works ok (6 cols). It even works if I use a
"?" in the where clause.

SQL Server Version is 8.00.760 (SP3).

Any clues?

Regards,
Peter Arrenbrecht
Brannon Jones
9/29/2004 2:06:24 PM
Unfortunately the SQL Server driver doesn't handle these cases very well.
Are you binding the parameter before preparing the statement?

Brannon

[quoted text, click to view]
brannonj NO[at]SPAM gmail.com
10/5/2004 12:53:52 PM
Ah. When you prepare the statement, the driver needs to know certain
information about each parameter (ie. data type,precision,etc). If you
don't bind the parameter, then the driver will try to describe it on
it's own. In a lot of cases this will fail (like using a parameter in
a sub-select). If you bind the parameter first, then the driver can
use the binding information you specified to describe the parameter.
In most cases, this should resolve any syntax errors you are getting.
Brannon
Peter Arrenbrecht
10/5/2004 5:25:42 PM
No, after.

[quoted text, click to view]
Peter Arrenbrecht
10/7/2004 10:24:42 AM
Thanks! I shall try this. It is a little annoying, though, as we relied
on the data type information from the server to cast our param values
properly. That will need some rethinking.

peo

[quoted text, click to view]
AddThis Social Bookmark Button