On 06-Mar-2002 Steffen Goeldner wrote:
> [EMAIL PROTECTED] wrote:
>> 
>> On 05-Mar-2002 Steffen Goeldner wrote:
>> > Currently, long get_info() return values (e.g. SQL_KEYWORDS)
>> > are truncated.
>> > That's because the buffer has a static size of 256.
>> > The attached patch allocates the buffer dynamically and
>> > reallocates it if needed.
>> >
>> >
>> > Steffen
>> 
>> As far as I recall you can call SQLGetInfo with a NULL InfoValuePtr but a
>> valid
>> StringLengthPtr. This then returns the size of the buffer you would need to
>> get
>> all the data back.
>> 
>> e.g.
>> 
>> if (SQL_SUCCEEDED(SQLGetInfo(hdbc, SQL_KEYWORDS, NULL, 0, &sqlsmallint))) {
>>         SQLCHAR         buf;
> 
> Hmm, works for the MS Access ODBC driver, but seems to be an
> undocumented feature. Other drivers (e.g. Oracle) ignore this
> call.

Fair enough, if Oracle does not handle it then it is not a useful solution - I
just thought it might simplify your patch. However, as to undocumented, there is
a hint in the ODBC programmers reference volume 2 which says:

BufferLength
Length of the *InfoValuePtr buffer. If the value in *InfoValuePtr is not a
character string, or if the InfoValuePtr is a null pointer, the BufferLength
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
argument is ignored.

This would seem to suggest passing a NULL InfoValuePtr is valid but it does not
specifically say if StringLengthPtr is !NULL, it will be written to by
SQLGetInfo if InfoValuePtr = NULL.


>> 
>>         buf = malloc(sqlsmallint + 1);
>>         SQLGetInfo(hdbc, SQL_KEYWORDS, buf, sqlsmallint + 1, *sqlsmallint);
>>         /* copy buf somewhere */
>>         free(buf);
>> }

Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development

Reply via email to