Showing posts with label prepare. Show all posts
Showing posts with label prepare. Show all posts

Monday, March 19, 2012

ODBC Bug in SQL Server 8?

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
Opus Software AG
Unfortunately the SQL Server driver doesn't handle these cases very well.
Are you binding the parameter before preparing the statement?
Brannon
"Peter Arrenbrecht" <arrenbrecht@.NOXXX.opus.ch> wrote in message
news:41502254.2040509@.NOXXX.opus.ch...
> 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
> Opus Software AG
|||No, after.
Brannon Jones wrote:
> Unfortunately the SQL Server driver doesn't handle these cases very well.
> Are you binding the parameter before preparing the statement?
> Brannon
> "Peter Arrenbrecht" <arrenbrecht@.NOXXX.opus.ch> wrote in message
> news:41502254.2040509@.NOXXX.opus.ch...
>
>
|||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
|||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
brannonj@.gmail.com wrote:
> 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
>