EXECUTE IMMEDIATE

动态执行语句

1.

DROP  PROCEDURE db2execute
;
CREATE  PROCEDURE db2execute(strsql CLOB(64K))
BEGIN
EXECUTE IMMEDIATE strsql;
END
;

2.

begin atomic
  declare intCount integer;
  declare strSQL varchar(20000);
	set intCount=(select count(*) from sysibm.systables where name=UPPER('?') and creator=UPPER('?') and Type='T');
	if (intCount=0) then
		set strSQL =  'CREATE TABLE 
tabname;
		set strSQL = strSQL || '(';
		set strSQL = strSQL || '   name	Char (9)	NOT NULL';
		set strSQL = strSQL || ' , creator	Char (9)	NOT NULL';
		set strSQL = strSQL || ') IN tablespacename;
	call db2execute(strSQL);
	end if; 
end
;

  

 

你可能感兴趣的:(EXECUTE IMMEDIATE)