oracle 测试存储过程,执行一次,上次的返回结果便累加上去,如何清
oracle 测试存储过程,执行一次,上次的返回结果便累加上去,如何清<p>CREATE OR REPLACE PROCEDURE PROC_Test(O_CUR OUT SYS_REFCURSOR) IS
STR VARCHAR2(2000);
TB_COUNT INT;
BEGIN
--先判断全局临时表是否存在,没存在则重新建立:</p><p>SELECT COUNT(*)
INTO TB_COUNT
FROM USER_TABLES
WHERE TABLE_NAME = UPPER('temp_table');
IF TB_COUNT = 0 THEN
STR := 'CREATE GLOBAL TEMPORARY TABLE temp_table(</p><p>Name VARCHAR2(100),</p><p>Data VARCHAR2(500),</p><p>Category VARCHAR2(200)
) ON COMMIT PRESERVE ROWS';
EXECUTE IMMEDIATE STR;
END IF;
STR := 'INSERT INTO temp_table(Name,Data,Category) VALUES(''省委'',100,null)';
EXECUTE IMMEDIATE STR;
STR := 'INSERT INTO temp_table(Name,Data,Category) VALUES(''市委'',50,null)';
EXECUTE IMMEDIATE STR;
COMMIT;
STR := 'SELECT * FROM temp_table';
OPEN O_CUR FOR STR; -- 给游标变量赋值</p><p>END PROC_Test;</p>
然后右键测试,运行,查看游标值2条数据,再运行,查看游标值就变成了4条。等大神解答
查一下语法
页:
[1]