I'm trying to print the rows of a table in embedded sql. I have this code where publication is the 开发者_C百科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?
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.
精彩评论