c++ - 如何摆脱使用但未定义的标签

标签 c++ sql c db2 embedded-sql

我正在尝试在嵌入式 sql 中打印表格的行。我有这段代码,其中 publication 是表,pubid 是属性。我试过这个:

    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;

编译器给我这个错误:错误:标签“close_c1”已使用但未定义。 我该如何解决这个问题?

最佳答案

只是猜测... 将 WHENEVER 行放在嵌入式 sql 序列的第一位。

来自“SQL 引用第 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.

关于c++ - 如何摆脱使用但未定义的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3207075/

相关文章:

c++ - fstream 二进制读/写行为

C++:用户定义类的动态数组

c - 链接器错误 "cannot find -l/some/path/libfilename"

c - 函数指针是否强制清除指令流水线?

c++ - 字符串和循环

c++ - 具有不同包含类型的 STL 容器?

mysql - 在 MySQL 中对 DISTINCT 查询使用 MIN MAX 查询?

sql - 查找引用某个表中特定列的所有存储过程

SQL Server - Where 条件用法

c - Gstreamer-mp3 上的持续时间查询错误