Re: SQL_ERROR on SQLExecute() when using SQL_C_NUMERIC for parameters

From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Daniel Vogelbacher <cx(at)cytrinox(dot)net>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: SQL_ERROR on SQLExecute() when using SQL_C_NUMERIC for parameters
Date: 2013-06-03 11:33:00
Message-ID: 51AC7EEC.6040101@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Sorry for the late reply.

(2013/05/26 19:38), Daniel Vogelbacher wrote:
> Hi,
>
> when using SQLBindParameter with SQL_C_NUMERIC input, the function
> returns SQL_SUCCESS. But a call to SQLExecute() returns SQL_ERROR with
> "Syntax error on )".
>
> It seems that the psqlodbc driver did not replace the ? marker
> properly and an invalid statement is passed to the server. This only
> happens with SQL_C_NUMERIC, for other datatypes the marker gets
> replaced.

SQLSetDescField() causes the problem.
SQLBindParameter() sets SQL_DESC_DATA_PTR field but subsequent
SQLSetDescField() calls make the record unbound.

regards,
Hiroshi Inoue

> The used statement was:
>
> INSERT INTO numtest(num1) VALUES(?);
>
> where num1 is of type NUMERIC(5,3)
>
> The driver was built from source psqlodbc-09.01.0200.tar.gz for
> unixODBC.
>
>
> Here is the odbctrace for the specific part:
>
>
> [ODBC][27210][1369515859.324218][SQLBindParameter.c][217]
> Entry:
> Statement = 0x1a908b0
> Param Number = 1
> Param Type = 1
> C Type = 2 SQL_C_NUMERIC
> SQL Type = 2 SQL_NUMERIC
> Col Def = 5
> Scale = 3
> Rgb Value = 0x1a91210
> Value Max = 0
> StrLen Or Ind = 0x1a91230
> [ODBC][27210][1369515859.324329][SQLBindParameter.c][397]
> Exit:[SQL_SUCCESS]
> [ODBC][27210][1369515859.324359][SQLSetDescFieldW.c][168]
> Entry:
> Descriptor = 0x1ab2ef0
> Rec Number = 1
> Field Ident = SQL_DESC_PRECISION
> Value = 0x5
> Buffer Length = -8
> [ODBC][27210][1369515859.324402][SQLSetDescFieldW.c][246]
> Exit:[SQL_SUCCESS]
> [ODBC][27210][1369515859.324421][SQLSetDescFieldW.c][168]
> Entry:
> Descriptor = 0x1ab2ef0
> Rec Number = 1
> Field Ident = SQL_DESC_SCALE
> Value = 0x3
> Buffer Length = -8
> [ODBC][27210][1369515859.324452][SQLSetDescFieldW.c][246]
> Exit:[SQL_SUCCESS]
> [ODBC][27210][1369515859.324480][SQLExecute.c][187]
> Entry:
> Statement = 0x1a908b0
> [ODBC][27210][1369515859.328804][SQLExecute.c][348]
> Exit:[SQL_ERROR]
> DIAG [42601] FEHLER: Syntaxfehler bei <BB>)<AB>;
> Error while executing the query

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Joshua Berry 2013-06-03 14:55:58 Re: Segmentation Fault in Postgres server when using psqlODBC
Previous Message Inoue, Hiroshi 2013-06-02 23:58:23 Re: ODBC SELECT Timeout