读书人

迷惑有关问题 命令行与游标

发布时间: 2012-03-04 11:13:33 作者: rapoo

迷惑问题 命令行与游标
写了一个脚本test.sql
declare v_code char(4);
declare cursor1 cursor for select a from tbl_tst fetch first 1 rows only for update;
open cursor1;
fetch cursor1 into v_code;
close cursor1;


db2 -tvf test.sql

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0007N The character " " following "code char(4);" is not valid.
SQLSTATE=42601


游标应该是怎么使用的?
必须是在存储过程或者程序中使用吗?



[解决办法]
跟你想的一样~~~
[解决办法]
我也这么认为。
[解决办法]
个人觉得db2 -vtf执行的sql脚本其实就是一个命令行命令序列,如果在命令行不能执行,用这个也是不能执行的。
[解决办法]
我可以明确的告诉你,游标只能在存储过程、触发器、用户自定义函数中使用

读书人网 >IBM DB2

热点推荐