SQLColAttribute with SQL_DESC_LENGTH for varchar and text types

From: Przemyslaw Rzepecki <przemyslaw(dot)rzepecki(at)ericsson(dot)com>
To: <pgsql-odbc(at)postgresql(dot)org>
Cc: Yingqing Zhou <yingqing(dot)zhou(at)ericsson(dot)com>
Subject: SQLColAttribute with SQL_DESC_LENGTH for varchar and text types
Date: 2013-11-20 13:02:01
Message-ID: 1384952521.4529.96.camel@salti.rnd.ki.sw.ericsson.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi!

My application needs to know the maximum string length in a result set.
With other database/odbc driver a call to SQLColAttribute with
SQL_DESC_LENGTH. With pgsql the returned size is always 255 for a
varchar column and 8190 for a text column.

According to http://msdn.microsoft.com/en-us/library/ms713558%28v=vs.85%
29.aspx the SQL_DESC_LENGTH should result "actual character length for a
variable-length data type". I also tried setting "Unknown Sizes"
parameter to 'Longest' in odbc.ini for the data source as described in
http://psqlodbc.projects.pgfoundry.org/docs/config.html but result is
still 255.

The code looks like:
ret = SQLExecDirect(hstmt, "select s from test", SQL_NTS);
ret = SQLFetchScroll(hstmt, SQL_FETCH_LAST, 0);
ret = SQLColAttribute(hstmt, 1, SQL_DESC_LENGTH,
NULL, 0, NULL, &size);
printf("size %ld\n", size);
all calls are successful.

Attached is mylog file.

Tested with unixODBC 2.3.1
psqlodbc-09.02.0100 driver
Postgresql 9.3.1 server

Thank You for any help!
Przemyslaw

Attachment Content-Type Size
mylog_eprzrze14611.log text/x-log 57.8 KB

Browse pgsql-odbc by date

  From Date Subject
Next Message Hiroshi Inoue 2013-11-23 09:44:49 Re: SQLCopyDesc to copy rows between tables
Previous Message Przemyslaw Rzepecki 2013-11-17 16:25:16 SQLCopyDesc to copy rows between tables