如何在oracle中查看已创建游标的输出以及如何将其称为函数。

时间:2013-10-10 22:52:18

标签: oracle

如何在oracle中看到以下代码的输出并调用它?

DECLARE
       c_id e.id%type;
       c_name e.name%type;
       CURSOR c_e is
          SELECT id, name FROM e;
    BEGIN
       OPEN c_e;
       LOOP
          FETCH c_e into c_id, c_name;
        dbms_output.put_line(c_id||' '||c_name);
         EXIT WHEN c_e%notfound;
      END LOOP;
      CLOSE c_e;
   END;
   /

1 个答案:

答案 0 :(得分:0)

create or replace procedure test_out
begin
   DECLARE
       c_id e.id%type;
       c_name e.name%type;
       CURSOR c_e is
          SELECT id, name FROM e;
    BEGIN
       OPEN c_e;
       LOOP
          FETCH c_e into c_id, c_name;
          dbms_output.put_line(c_id||' '||c_name);
          EXIT WHEN c_e%notfound;
      END LOOP;
      CLOSE c_e;
   END;
end;
exec test_out;