昨天在寫存儲過程的時候發(fā)現(xiàn)了一個以前忽視了的地方,不知道對大家有沒有用。 創(chuàng)建顯性游標(biāo): create or replace PRocedure test is cursor test1 is select name from devp; test2 devp.name%type; begin open test1; loop fetch test1 into test2; dbms_output.put_line(test2); --注重,此處用的是test2變量 exit when test1%notfound; end loop; close test1; end; /
create or replace procedure test is cursor test1 is select name from devp; test2 test1%rowtype; begin open test1; loop fetch test1 into test2; dbms_output.put_line(test2.name); --注重,此處用的是test2.name exit when test1%notfound; end loop; close test1; end; /
下面用隱性游標(biāo)試一下: create or replace procedure test is cursor test1 is select name from devp; test2 devp.name%type; begin for test2 in test1 loop dbms_output.put_line(test2.name); --注重,此處用的是test2.name end loop; end; /
create or replace procedure test is cursor test1 is select name from devp; test2 test1%rowtype; begin for test2 in test1 loop dbms_output.put_line(test2.name); --注重,此處用的是test2.name end loop; end; /