data studio
和clp
/ Control Center
有更改语句终结符的不同提示所有这些汇总结果都是一个非常重的脚本标题:
--<ScriptOptions statementTerminator="^"/>
--#SET TERMINATOR ^
CREATE PROCEDURE db2inst1.tmp_my_drop_procs()
BEGIN
DECLARE @STMT VARCHAR(10000);
FOR v1 AS SELECT SPECIFICNAME from syscat.procedures where PROCSCHEMA = 'DB2INST1' AND PROCNAME = 'CREATE_OR_UPDATE_ARCH'
DO
SET @STMT = 'DROP SPECIFIC PROCEDURE DB2INST1.' || SPECIFICNAME;
EXECUTE IMMEDIATE @STMT;
END FOR;
END
^
CALL db2inst1.tmp_my_drop_procs()^
DROP PROCEDURE db2inst1.tmp_my_drop_procs^
CREATE PROCEDURE db2inst1.CREATE_OR_UPDATE_ARCH()
DYNAMIC RESULT SETS 1
BEGIN ATOMIC
-- ...
END
^
答案 0 :(得分:0)
您可以添加一个忽略SQLSTATE'42704'(未找到对象)的继续处理程序。这是我撒谎的一个例子。
CREATE PROCEDURE drop_procedure (procschema varchar(128),
procname varchar(128))
LANGUAGE SQL
BEGIN
DECLARE tmpstmt VARCHAR(100);
SET tmpstmt = 'drop procedure ' || procschema || '.' || procname;
A: BEGIN
-- Do nothing if drop procedure fails
DECLARE CONTINUE HANDLER FOR SQLSTATE '42704'
BEGIN
END;
EXECUTE IMMEDIATE tmpstmt;
END;
END @