Why this code fails - Mailing list pgsql-odbc

From Igor Korot
Subject Why this code fails
Date
Msg-id CA+FnnTxF3rCGsBr7i5qCP5W1F8QyOajG0h2dJ5h-9iusdLMz6g@mail.gmail.com
Whole thread Raw
Responses Re: Why this code fails  (Clemens Ladisch <clemens@ladisch.de>)
List pgsql-odbc
Hi,
Following code fails with the error "Invalid column nuber in DescribeCol".

I'm trying to run it with the iODBC DM and the official PG ODBC driver.

[code]
int ODBCDatabase::AskPostgresForLogFile()
{
    int result = 0;
    SQLWCHAR *columnName = new SQLWCHAR[256], *columnData;
    SQLSMALLINT columnNameLen, columnDataType, columnDataDigits,
columnDataNullable;
    SQLLEN columnDataLen;
    SQLULEN columnDataSize;
    std::wstring query = L"SHOW log_directory";
    std::vector<std::wstring> errorMsg;
    SQLWCHAR *qry = new SQLWCHAR[query.length() + 2];
    memset( qry, '\0', query.length() + 2 );
    uc_to_str_cpy( qry, query );
    RETCODE ret = SQLAllocHandle( SQL_HANDLE_STMT, m_hdbc, &m_hstmt );
    if( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO )
    {
        ret = SQLPrepare( m_hstmt, qry, SQL_NTS );
        if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
        {
            GetErrorMessage( errorMsg, 1 );
            result = 1;
        }
        else
        {
            ret = SQLDescribeCol( m_hstmt, 1, columnName, 256,
&columnNameLen, &columnDataType, &columnDataSize, &columnDataDigits,
&columnDataNullable );
            if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
            {
                GetErrorMessage( errorMsg, 1 );
                result = 1;
            }
            else
            {
            }
}
[/code]

Thank you.


pgsql-odbc by date:

Previous
From: 狐狸的面包雨
Date:
Subject: psqlodbc && nested transaction
Next
From: Clemens Ladisch
Date:
Subject: Re: Why this code fails