免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2665 | 回复: 1
打印 上一主题 下一主题

[C++] 动态SQL 错误 EXEC SQL EXECUTE IMMEDIATE USING [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-11-26 11:55 |只看该作者 |倒序浏览
int main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char szSql[1000];
char col1[100];
EXEC SQL END DECLARE SECTION;
.....
strcpy(szSql, "DELETE FROM feng_test7 WHERE col1 = 'a'");
//strcpy(col1, "d");
EXEC SQL EXECUTE IMMEDIATE :szSql;
....

}

上面程序不会报错,执行成功。
但是下面proc就会报错:
int main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char szSql[1000];
char col1[100];
EXEC SQL END DECLARE SECTION;
.....
strcpy(szSql, "DELETE FROM feng_test7 WHERE col1 = :v1");
strcpy(col1, "d");
EXEC SQL EXECUTE IMMEDIATE :szSql USING :col1;
....

}

proc include=/usr/local/oracle/precomp/public include=/usr/local/oracle/rdbms/public include=/home/icqz/incl LINES=true CODE=cpp parse=none cpp_suffix=C RELEASE_CURSOR=yes CLOSE_ON_COMMIT=NO UNSAFE_NULL=YES DBMS=V8 CPOOL=YES LINES=YES iname=test1.pc

Pro*C/C++: Release 10.2.0.1.0 - Production on Tue Nov 26 11:50:54 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

System default option values taken from: /usr/local/oracle/precomp/admin/pcscfg.cfg

Syntax error at line 176, column 36, file test1.pc:
Error at line 176, column 36 in file test1.pc
        EXEC SQL EXECUTE IMMEDIATE :szSql USING :col1;
...................................1
PCC-S-02201, Encountered the symbol "USING" when expecting one of the following:

   ; ( [ . ++ -- ->

Error at line 0, column 0 in file test1.pc
PCC-F-02102, Fatal error while doing C preprocessing
make: *** [test1.o] 错误 1


难道EXEC SQL EXECUTE IMMEDIATE 不能使用USING吗?

论坛徽章:
0
2 [报告]
发表于 2013-11-26 12:36 |只看该作者
应该去掉 IMMEDIATE就可以了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP