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

From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: Daniel Vogelbacher <daniel(at)vogelbacher(dot)name>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: SQL_ERROR on SQLExecute() when using SQL_C_NUMERIC for parameters
Date: 2013-06-04 03:35:29
Message-ID: 51AD6081.6060503@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

(2013/06/04 3:49), Daniel Vogelbacher wrote:
> On [Mon, 03.06.2013 20:33], Hiroshi Inoue wrote:
>> 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.
>
>
> Ahh, many thanks for the hint.
> Curious that the same code works fine with TDS and Firebird ODBC drivers :-)

There are some differences among odbc drivers about the handling
of SQL_C_NUMERIC data.

Please note that psqlodbc driver ignores the precision or scale
specified in SQLSetDescField() calls. Please set the precision and
scale of SQL_NUMERIC_STRUCT data itself.

Anyway please add the following statement to rebind the data.
SQLSetDescField(hdesc, 1, SQL_DESC_DATA_PTR, ..);

regards,
Hiroshi Inoue

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Inoue, Hiroshi 2013-06-04 03:47:29 Re: Segmentation Fault in Postgres server when using psqlODBC
Previous Message Daniel Vogelbacher 2013-06-03 18:49:15 Re: SQL_ERROR on SQLExecute() when using SQL_C_NUMERIC for parameters