public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Igor Korot <[email protected]>
Cc: Adrian Klaver <[email protected]>
Cc: Rob Sargent <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: How to properly use TRIM()?
Date: Sat, 7 Mar 2026 15:26:35 -0700
Message-ID: <CAKFQuwa4-OFWdE35fHNR+YvzHVDjaKR7Rw37f+cJY_Gxk1jAgA@mail.gmail.com> (raw)
In-Reply-To: <CA+FnnTwqP_-RcQSRCUMc4gpYk8ofNV11MJ_S2rYCpWhe3CPTmA@mail.gmail.com>
References: <CA+FnnTwxSeLhR8zNZsoR2SAXYVf9Db+zi3+SpPqdBe==m3X-AQ@mail.gmail.com>
	<[email protected]>
	<CA+FnnTznxpXh8nAJhjnggpfYz0MEnEdK89FtejDNTmX87MktiA@mail.gmail.com>
	<CAKFQuwYaVKcMU0wP3SAbct8FU0H4iy=E1HxxBY-gcvmoK-GsrQ@mail.gmail.com>
	<CA+FnnTy5Fc5WdM=yPSL7bBDrGYHD2aQTwGbFZFuv9dHm_AAgGA@mail.gmail.com>
	<[email protected]>
	<CA+FnnTwqP_-RcQSRCUMc4gpYk8ofNV11MJ_S2rYCpWhe3CPTmA@mail.gmail.com>

On Sat, Mar 7, 2026 at 2:46 PM Igor Korot <[email protected]> wrote:

> Hi, Adrian,
>
> On Sat, Mar 7, 2026 at 3:29 PM Adrian Klaver <[email protected]>
> wrote:
> >
> > On 3/7/26 12:46 PM, Igor Korot wrote:
> > > Hi, David,
> > >
> > > On Sat, Mar 7, 2026 at 12:03 PM David G. Johnston
> > > <[email protected] <mailto:[email protected]>>
> wrote:
> > >
> > >     On Sat, Mar 7, 2026 at 12:58 PM Igor Korot <[email protected]
> > >     <mailto:[email protected]>> wrote:
> > >
> > >         So I started looking for a way to return SQL_NO_DATA
> > >         on that 4th column...
> > >
> > >
> > >     Doesn't "No Data" refer to the result set as a whole, not
> individual
> > >     columns?  I'd assume NULL is detected some other way.
> > >
> > >
> > > No, I think it’s column based.
> >
> > 1) My knowledge of ODBC is limited.
> >
> > 2) This:
> >
> >
> https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/return-codes-odbc?view=sql-server-v...
> >
> > "SQL_NO_DATA    No more data was available. The application calls
> > SQLGetDiagRec or SQLGetDiagField to retrieve additional information. One
> > or more driver-defined status records in class 02xxx may be returned.
> > Note: In ODBC 2.x, this return code was named SQL_NO_DATA_FOUND."
> >
> > would seem to indicate that David Johnston is correct:
>
> From the SQLGetData() ODBC documentation
> (
> https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function?view=sql-server-ver1...
> ):
>
> [quote]
> When it returns the last part of the data, SQLGetData returns
> SQL_SUCCESS. Neither SQL_NO_TOTAL nor zero can be returned on the last
> valid call to retrieve data from a column, because the application
> would then have no way of knowing how much of the data in the
> application buffer is valid. If SQLGetData is called after this, it
> returns SQL_NO_DATA. For more information, see the next section,
> "Retrieving Data with SQLGetData."
> [/quote]
>
> However it looks like the driver does not behave as expected.
>
> It keeps returning SQL_SUCCESS continuously...
>
> Or am I misinterpreting the docs?
>
>
Ok, you are indeed performing an iteration of SQLGetData that does return
SQL_NO_DATA when you've exhausted the contents of the field being retrieved.

You still need to check ind[3] for:
https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function?view=sql-server-ver1...
Step 2

I have no idea why you would end up in an infinite loop there though.  I
suppose maybe step 2's lack of describing the flow when the data is null
means you need to break out of the loop manually after dealing with the
null value in some manner.

David J.


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: How to properly use TRIM()?
  In-Reply-To: <CAKFQuwa4-OFWdE35fHNR+YvzHVDjaKR7Rw37f+cJY_Gxk1jAgA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox