Re: SQL_NEED__DATA

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL_NEED__DATA
Date: 2026-10-02 00:03:17
Message-ID: CANzqJaDkZhV6_kggoK6XxBSPpj5QKx2dH8zng=nzOvftH_2qEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-odbc

A repeater in plain SQL would eliminate the possibility of it being a bug
in your C++ code.

Alternatively, strip your code down to the barest minimum (aka just the
first INSERT) and see if that works. Then keep adding a bit more code.
Keep doing that until you find the failure point, or it succeeds.

On Thu, Oct 1, 2026 at 7:06 PM Igor Korot <ikorot01(at)gmail(dot)com> wrote:

> Hi,
>
> Does anybody here know what could be the problem?
>
> Thank you.
>
>
> ---------- Forwarded message ---------
> From: Igor Korot <ikorot01(at)gmail(dot)com>
> Date: Thu, Oct 1, 2026 at 6:26 PM
> Subject: SQL_NEED__DATA
> To: PostgreSQL ODBC list <pgsql-odbc(at)postgresql(dot)org>
>
>
> Hi,
>
> Consider following table:
>
> CREATE TABLE IF NOT EXISTS abcatvld(abv_name char(30) NOT NULL,
> abv_vald char(254), abv_type smallint, abv_cntr integer, abv_msg
> char(254), PRIMARY KEY( abv_name ));
>
> the following code:
>
> [code]
> int ODBCDatabase::CreateUpdateValidationRule(bool isNew, const
> std::wstring &name, const std::wstring &rule, const int type, const
> std::wstring &message, std::vector<std::wstring> &errorMsg)
> {
> int result = 0;
> std::wstring errorMessage;
> std::wstring query = L"";
> SQLLEN val1, val2, val3, val4, val5;
> if( isNew )
> query = L"INSERT INTO abcatvld( abv_name, abv_vald, abv_type,
> abv_msg ) VALUES( ?, ?, ?, ?)";
> else
> query = L"UPDATE abcatvld SET abv_name = ?, abv_vald = ?,
> abv_type = ?, abv_msg = ? WHERE abv_name = ?";
> auto qry = new SQLWCHAR[query.length() + 2];
> memset( qry, '\0', query.length() + 2 );
> uc_to_str_cpy( qry, query );
> auto qryName = new SQLWCHAR[32];
> memset( qryName, '\0', 32 );
> uc_to_str_cpy( qryName, name );
> auto qryRule = new SQLWCHAR[258];
> memset( qryRule, '\0', 258 );
> uc_to_str_cpy( qryRule, rule );
> auto qryType = (int) type;
> auto qryMessage = new SQLWCHAR[256];
> memset( qryMessage, '\0', 256 );
> uc_to_str_cpy( qryMessage, message );
> auto ret = SQLAllocHandle( SQL_HANDLE_STMT, m_hdbc, &m_hstmt );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, CONN_ERROR );
> result = 1;
> }
> if( !result )
> {
> ret = SQLPrepare( m_hstmt, qry, SQL_NTS );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !result )
> {
> ret = SQLBindParameter( m_hstmt, 1, SQL_PARAM_INPUT,
> SQL_C_WCHAR, SQL_WCHAR, 32, 0, qryName, 0, &val1 );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !result )
> {
> ret = SQLBindParameter( m_hstmt, 2, SQL_PARAM_INPUT,
> SQL_C_WCHAR, SQL_WCHAR, 258, 0, qryRule, 0, &val2 );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !result )
> {
> ret = SQLBindParameter( m_hstmt, 3, SQL_PARAM_INPUT,
> SQL_C_SSHORT, SQL_INTEGER, 0, 0, &qryType, 0, &val3 );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !result )
> {
> ret = SQLBindParameter( m_hstmt, 4, SQL_PARAM_INPUT,
> SQL_C_WCHAR, SQL_WCHAR, 254, 0, &qryMessage, 0, &val4 );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !isNew && !result )
> {
> ret = SQLBindParameter( m_hstmt, 5, SQL_PARAM_INPUT,
> SQL_C_WCHAR, SQL_WCHAR, 32, 0, qryName, 0, &val5 );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> if( !result )
> {
> ret = SQLExecute( m_hstmt );
> if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
> {
> GetErrorMessage( errorMsg, STMT_ERROR );
> result = 1;
> }
> }
> }
>
> returns 99 (SQL_NEED_DATA).
>
> What am I doing wrong?
>
> Thank you.
>
>
>

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2026-10-02 00:34:42 Re: Why is materialized view creation a "security-restricted operation"?
Previous Message Ron Johnson 2026-10-01 23:55:52 Re: Why is materialized view creation a "security-restricted operation"?

Browse pgsql-odbc by date

  From Date Subject
Previous Message Igor Korot 2026-10-01 23:39:38 Fwd: SQL_NEED__DATA