How to get rid of label used but not defined

I'm trying to print the rows of a table in embedded sql. I have this code where publication is the table and pubid is the attribute. I tried this:

    EXEC SQL DECLARE C1 CURSOR FOR SELECT pubid FROM publication;
    EXEC SQL OPEN C1;
    EXEC SQL WHENEVER NOT FOUND GOTO close_c1;
    for(;;) {
        EXEC SQL FETCH C1 INTO :pubid;
        cout<<pubid<<endl;
    }
    close_c1:
    EXEC SQL CLOSE C1;

The compiler gives me this error: error: label 'close_c1' used but not defined. How do I fix this?

Answers


Just guessing... Put the WHENEVER line first in your embedded sql sequence.

From "SQL Reference Volume 2":

WHENEVER ..... Note: ..... Every executable SQL statement in a program is within the scope of one implicit or >explicit WHENEVER statement of each type. The scope of a WHENEVER statement is related to the listing sequence of the statements in >the program, not their execution sequence.


Need Your Help

Spring boot docker plugin requires removing the image everytime

java eclipse maven docker spring-boot

I created a basic spring boot app and I am using the docker-maven-plugin