我正在尝试在 db2 过程中执行查询:
CREATE OR REPLACE PROCEDURE TEST (IN indbnm VARCHAR(30), IN intblnm VARCHAR(30))
LANGUAGE SQL
BEGIN
DECLARE statmnt2 VARCHAR(1000);
DECLARE VAR_COD_TIPO_ARQU CHAR(1);
DECLARE stmt1 STATEMENT;
SET statmnt2 = 'SELECT COD_TIPO_ARQU FROM '||indbnm||'.'||intblnm||' FETCH FIRST 1 ROWS ONLY';
PREPARE stmt1 FROM statmnt2;
SET VAR_COD_TIPO_ARQU = EXECUTE (stmt1);
END@
这会产生以下错误:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0206N "STMT1" is not valid in the context where it is used. LINE
NUMBER=33. SQLSTATE=42703
VAR_COD_TIPO_ARQU
动态设置值的正确方法是什么COD_TIPO_ARQU
?
谢谢你。