Re: How to properly use TRIM()?

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to properly use TRIM()?
Date: 2026-03-07 19:58:22
Message-ID: CA+FnnTznxpXh8nAJhjnggpfYz0MEnEdK89FtejDNTmX87MktiA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, Rob,

On Sat, Mar 7, 2026 at 1:20 PM Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
>
>
>> reloptions text[]
>
>
> Then why it’s not showing {} as in the “included” columns?
>
> Or it’s an ARRAY() implementation?
>
> Thank you.
>
>>
>
> One is an empty array, the other is null. Those are not the same thing.

Following code successfully retrieves column 3 and exits, but keep
looping for column 4.

while( ( ret = SQLGetData( m_hstmt, 3, SQL_C_WCHAR,
included.get(), 255, &ind[2] ) ) != SQL_NO_DATA )
{
if( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO )
{
auto numBytes = ind[2];
if( ind[2] == SQL_NO_TOTAL )
numBytes = 255;
else if( ind[2] > 255 )
numBytes = 255;
str_to_uc_cpy( includedCol, included.get() );
}
else
{
GetErrorMessage( errorMsg, STMT_ERROR );
result = 1;
}
}
includedCol.erase( 0, 1 );
includedCol.pop_back();
}
while( ( ret = SQLGetData( m_hstmt, 4, SQL_C_WCHAR,
index_param.get(), 255, &ind[3] ) ) != SQL_NO_DATA )
{
if( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO )
{
auto numBytes = ind[3];
if( ind[3] == SQL_NO_TOTAL )
numBytes = 255;
else if( ind[3] > 255 )
numBytes = 255;
str_to_uc_cpy( options, index_param.get() );
}
else
{
GetErrorMessage( errorMsg, STMT_ERROR );
result = 1;
}
}

when I tried to run it without nullif() and trim().

So I started looking for a way to return SQL_NO_DATA
on that 4th column...

Thank you.

P.S.: Sorry for kind of throwing ODBC code here. You have ODBC
related list, but this is where things get in the cross.

>
>>
>>
>> > Included is one, storage is not.
>> >
>> > Thank you.
>> >
>> >>
>> >> Given that error message, an array of text is the correct type.
>> >>
>> >> Array[]::text[]
>> >>
>> >> David J.
>> >>
>> >
>> >
>>
>>
>> --
>> Adrian Klaver
>> adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2026-03-07 20:03:19 Re: How to properly use TRIM()?
Previous Message Rob Sargent 2026-03-07 19:19:52 Re: How to properly use TRIM()?