Home > database >  Oracle cursor back again after use
Oracle cursor back again after use

Time:09-28

The create or replace procedure up_test out sys_refcursor (o) is
The begin
The open o for the select * from lq_test;
The fetch... Haven't had the data after return, don't want to repeatedly query
end;

CodePudding user response:

The create or replace procedure up_test out sys_refcursor (o) is
The begin
The open o for the select * from lq_test;
end;


Can write directly, when you call a stored procedure, allowing it to assign a value to a cursor, and then the data is ok

CodePudding user response:

Need to take out the judgement of data processing, and then return to the content of the original cursors

CodePudding user response:

You must know how to handle? What kind of results to return?

CodePudding user response:

The create or replace the function test () is
O sys_refcursor;
R a, % rowtype.
The begin
The open o for the select * from a, where id=5.
Into the fetch o r;
If o % fount then
Insert into b (m) values (r.k);
end if;
The return o;
end; Does not return data, please advise

CodePudding user response:

The create or replace procedure pr_test (p_id varchar2)
As
O sys_refcursor;
R emp % rowtype;
The begin
The open o for the select * from a where id=p_id;
LOOP
Into the fetch o r;
Exit the when o % notfound;
Insert into b (m) values (r.k);
Dbms_output. Put_line (r.k);
End loop;
The end;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The begin
Pr_test (5);
end;



This

CodePudding user response:

Repeat the post
1, through the dbms_output. Put_line (r.k); Can view the cursor to retrieve data, PS, perform set serveroutput on
2, if in the other session, pay attention to the execution of the statement to commit
3, as far as possible don't function to insert, update and other operations, Suggestions on the process
  • Related