oracle 存储过程中查询结果无法赋值到变量,请指教

2024-12-02 19:55:21
推荐回答(1个)
回答1:

你最后没commit

CREATE OR REPLACE PROCEDURE test1
IS
tmpVar NUMBER;
strSQL VARCHAR2 (2000);
BEGIN

strSQL := 'drop table test';

EXECUTE IMMEDIATE strSQL;
strSQL := 'CREATE TABLE DDCXD.test(bh NUMBER)';

EXECUTE IMMEDIATE strSQL;

strSQL := 'select count(*) from local_xx';

EXECUTE IMMEDIATE strSQL into tmpVar ;

strSQL := 'insert into test values(' || tmpVar || ')';

EXECUTE IMMEDIATE strSQL;
commit;
END test1;

这样就行了