Re: libpq simple SELECT - Mailing list pgsql-general

From Laurenz Albe
Subject Re: libpq simple SELECT
Date
Msg-id 319efe7106d8db21e3bfa0fdb60fa37aa59d331c.camel@cybertec.at
Whole thread Raw
In response to Re: libpq simple SELECT  (Igor Korot <ikorot01@gmail.com>)
List pgsql-general
On Wed, 2025-12-17 at 13:07 -0800, Igor Korot wrote:
> This is a comment:
>
> /*
>      * Our test case here involves using a cursor, for which we must be inside
>      * a transaction block.  We could do the whole thing with a single
>      * PQexec() of "select * from pg_database", but that's too trivial to make
>      * a good example.
>      */
>
> When I read it my understanding is:
>
> It is possible to write the code without a cursor..
> However it will be trivial and so the code will use CURSOR.
> But the usage of CURSOR is actually not required - it is used
> in the docs only to make a good example.
>
> However, when I tried to write the code without the CURSOR
> it seems that CURSOR usage is a must and not optional, which
> contradicts the comment above.
>
> I hope now my question is clear. I want to know if using CURSR
> is a must.

Sorry that it took me so long to understand what you mean.

Your PQexec call should return all rows.  If you don't get all rows, there
must be some other problem with your code.  You didn't show enough of the
code for me to see where the problem is.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Igor Korot
Date:
Subject: Re: libpq simple SELECT
Next
From: Joe Conway
Date:
Subject: Re: Record last SELECT on a row?