pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop
2+ messages / 2 participants
[nested] [flat]
* ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop
@ 2021-07-03 11:54 PG Doc comments form <noreply@postgresql.org>
2021-08-18 16:17 ` Re: ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 2+ messages in thread
From: PG Doc comments form @ 2021-07-03 11:54 UTC (permalink / raw)
To: pgsql-docs@lists.postgresql.org; +Cc: andrew@andrewculver.com
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/13/ecpg-variables.html
Description:
Without this line:
EXEC SQL WHENEVER NOT FOUND CONTINUE;
after the while(1), I find that ECPG CURSOR examples fail.
For example, this example under 36.4.4.3.2. Structures fails:
EXEC SQL BEGIN DECLARE SECTION;
typedef struct
{
int oid;
char datname[65];
long long int size;
} dbinfo_t;
dbinfo_t dbval;
EXEC SQL END DECLARE SECTION;
memset(&dbval, 0, sizeof(dbinfo_t));
EXEC SQL DECLARE cur1 CURSOR FOR SELECT oid, datname,
pg_database_size(oid) AS size FROM pg_database;
EXEC SQL OPEN cur1;
/* when end of result set reached, break out of while loop */
EXEC SQL WHENEVER NOT FOUND DO BREAK;
while (1)
{
/* Fetch multiple columns into one structure. */
EXEC SQL FETCH FROM cur1 INTO :dbval;
/* Print members of the structure. */
printf("oid=%d, datname=%s, size=%lld\n", dbval.oid, dbval.datname,
dbval.size);
}
EXEC SQL CLOSE cur1;
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop
2021-07-03 11:54 ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop PG Doc comments form <noreply@postgresql.org>
@ 2021-08-18 16:17 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2021-08-18 16:17 UTC (permalink / raw)
To: andrew@andrewculver.com; pgsql-docs@lists.postgresql.org
On Sat, Jul 3, 2021 at 11:54:11AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/ecpg-variables.html
> Description:
>
> Without this line:
> EXEC SQL WHENEVER NOT FOUND CONTINUE;
> after the while(1), I find that ECPG CURSOR examples fail.
>
> For example, this example under 36.4.4.3.2. Structures fails:
Uh, can you give me full C example to test? I already see EXEC SQL
WHENEVER NOT FOUND DO BREAK in the sample code, so I don't see how
CONTINUE would actually work, since it would just loop over the result
infinitely.
---------------------------------------------------------------------------
>
> EXEC SQL BEGIN DECLARE SECTION;
> typedef struct
> {
> int oid;
> char datname[65];
> long long int size;
> } dbinfo_t;
>
> dbinfo_t dbval;
> EXEC SQL END DECLARE SECTION;
>
> memset(&dbval, 0, sizeof(dbinfo_t));
>
> EXEC SQL DECLARE cur1 CURSOR FOR SELECT oid, datname,
> pg_database_size(oid) AS size FROM pg_database;
> EXEC SQL OPEN cur1;
>
> /* when end of result set reached, break out of while loop */
> EXEC SQL WHENEVER NOT FOUND DO BREAK;
>
> while (1)
> {
> /* Fetch multiple columns into one structure. */
> EXEC SQL FETCH FROM cur1 INTO :dbval;
>
> /* Print members of the structure. */
> printf("oid=%d, datname=%s, size=%lld\n", dbval.oid, dbval.datname,
> dbval.size);
> }
>
> EXEC SQL CLOSE cur1;
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
If only the physical world exists, free will is an illusion.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-08-18 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-07-03 11:54 ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop PG Doc comments form <noreply@postgresql.org>
2021-08-18 16:17 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox