pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ECPG error:  break statement not within loop or switch
2+ messages / 2 participants
[nested] [flat]

* ECPG error:  break statement not within loop or switch
@ 2001-05-23 14:19 Hans-Jürgen Schönig <hs@cybertec.at>
  2001-07-06 08:07 ` Re: ECPG error:  break statement not within loop or switch Christof Petig <christof@petig-baender.de>
  0 siblings, 1 reply; 2+ messages in thread

From: Hans-Jürgen Schönig @ 2001-05-23 14:19 UTC (permalink / raw)
  To: pgsql-interfaces

I have written a small application but I can't compile the code because
of an error I have never seen before:

ecpg retrieve.pgc -o file.c
gcc -g -I /usr/include/pgsql -o prog file.c -L /usr/share/pgsql -lecpg
-lpq
retrieve.pgc: In function `main':
retrieve.pgc:57: break statement not within loop or switch
make: *** [x] Fehler 1

What does it mean?
I have listed the crucial piece of code below:

 EXEC SQL DECLARE mycursor CURSOR FOR mystatement;
        EXEC SQL OPEN mycursor;

        EXEC SQL WHENEVER NOT FOUND DO BREAK;
        while   (1)
        {
                EXEC SQL FETCH IN mycursor INTO :id, :name;
                flag=1;
                printf("records found: %i, %s\n\n", id, name);
        }

        if      (flag == 0)
        {
                printf("Insert the name of the OS: ");
                scanf("%256s", inos);

                EXEC SQL INSERT INTO os (id, name) VALUES (':intext',
':inos');         // THE ERROR OCCURS HERE
                if      (sqlca.sqlcode)
                {
                        printf("%s\n", sqlca.sqlerrm.sqlerrmc);
                        exit(0);
                }
        }

        EXEC SQL CLOSE mycursor;
        EXEC SQL DISCONNECT;

Can anybody help me?

    Hans




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ECPG error:  break statement not within loop or switch
  2001-05-23 14:19 ECPG error:  break statement not within loop or switch Hans-Jürgen Schönig <hs@cybertec.at>
@ 2001-07-06 08:07 ` Christof Petig <christof@petig-baender.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Christof Petig @ 2001-07-06 08:07 UTC (permalink / raw)
  To: Hans-Jürgen Schönig <hs@cybertec.at>; +Cc: pgsql-interfaces

Hans-Jürgen Schönig wrote:

> I have written a small application but I can't compile the code because
> of an error I have never seen before:

[...]

> retrieve.pgc: In function `main':
> retrieve.pgc:57: break statement not within loop or switch
> make: *** [x] Fehler 1
>
>         EXEC SQL WHENEVER NOT FOUND DO BREAK;

this statement inserts a 'if (sqlca.sqlcode==100) break;' after each SQL
statement following

>                 EXEC SQL INSERT INTO os (id, name) VALUES (':intext',
> ':inos');         // THE ERROR OCCURS HERE

and here it harms (of course)

you should insert
    EXEC SQL WHENEVER NOT FOUND CONTINUE;
after the while loop.

Yours
   Christof







^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-07-06 08:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-23 14:19 ECPG error:  break statement not within loop or switch Hans-Jürgen Schönig <hs@cybertec.at>
2001-07-06 08:07 ` Christof Petig <christof@petig-baender.de>

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