pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: andrew@andrewculver.com
Subject: ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop
Date: Sat, 03 Jul 2021 11:54:11 +0000
Message-ID: <162531325118.701.13401788614496956581@wrigleys.postgresql.org> (raw)

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;


view thread (2+ messages)  latest in thread

Message-ID: <162531325118.701.13401788614496956581@wrigleys.postgresql.org>
Permalink:  ../162531325118.701.13401788614496956581@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/162531325118.701.13401788614496956581@wrigleys.postgresql.org

 · 

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: pgsql-docs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, andrew@andrewculver.com
  Subject: Re: ECPG cursor examples should include EXEC SQL WHENEVER NOT FOUND CONTINUE; after the while loop
  In-Reply-To: <162531325118.701.13401788614496956581@wrigleys.postgresql.org>

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

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