Обсуждение: SQLColAttribute with SQL_DESC_LENGTH for varchar and text types

Поиск
Список
Период
Сортировка

SQLColAttribute with SQL_DESC_LENGTH for varchar and text types

От
Przemyslaw Rzepecki
Дата:
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

Вложения