我正在DB2中执行以下过程。
create procedure checkUpdate()
LANGUAGE SQL
begin
DECLARE EOF INT DEFAULT 0;
DECLARE STMT VARCHAR(200);
DECLARE COL_NAME NVARCHAR(40);
Declare col_name_cursor cursor for
select c.column_name from sysibm.tables t join sysibm.columns c on t.table_schema = c.table_schema and t.table_name = c.table_name where t.table_schema ='ARCHANA' and t.table_name = 'ADULT' and c.data_type not like 'CHARACTER%';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET EOF = 1;
OPEN col_name_cursor;
WHILE EOF = 0 DO
FETCH FROM col_name_cursor INTO COL_NAME;
INSERT INTO GAUSSIAN_VALUES select CLASS,avg(COL_NAME),stddev(COL_NAME) from ADULT GROUP BY CLASS;
END WHILE;
CLOSE col_name_cursor;
end@
但是,在DB2命令窗口中执行此操作时出现以下错误。
SQL0420N在函数“DECFLOAT”的字符串参数中找到无效字符。 SQLSTATE = 22018
我做了一些调试,发现错误来自Declare游标行。我将光标的select语句更改为“从成人中选择年龄”进行检查,错误消失。选择整数值时不会发生错误。在varchar的情况下发生。我被困住了,不知道这里缺少什么链接。
谢谢!
答案 0 :(得分:0)
COL_NAME是NVARCHAR类型......
如何计算字符值的avg(COL_NAME),stddev(COL_NAME)
?
也许你打算花一点时间?