当前位置: 代码迷 >> DB2 >> 迷惑有关问题 命令行与游标
  详细解决方案

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

热度:8093   发布时间:2013-02-26 00:00:00.0
迷惑问题 命令行与游标
写了一个脚本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脚本其实就是一个命令行命令序列,如果在命令行不能执行,用这个也是不能执行的。
------解决方案--------------------------------------------------------
我可以明确的告诉你,游标只能在存储过程、触发器、用户自定义函数中使用
  相关解决方案