日期:2014-05-17 浏览次数:20726 次
CREATE OR REPLACE PROCEDURE p01 IS v_sql VARCHAR2(1000); BEGIN v_sql:='CREATE TABLE student(no VARCHAR2(5),sname VARCHAR2(10))'; execute IMMEDIATE v_sql; END p01; EXEC p01; CREATE OR REPLACE PROCEDURE p02 IS cur_stu sys_refcursor; temp VARCHAR2(5); BEGIN INSERT INTO student VALUES ('001','张三'); INSERT INTO student VALUES ('002','李四'); INSERT INTO student VALUES ('003','王五'); COMMIT; OPEN cur_stu FOR 'select no from student'; LOOP FETCH cur_stu INTO temp; EXIT WHEN cur_stu%NOTFOUND; Dbms_Output.put_line('=='||temp); END LOOP; END p02; EXEC p02; output: 23 PL/SQL block, executed in 0.078 sec. ==001 ==002 ==003 Total execution time 0.094 sec.