Simple:
--创建procedure
create or replace procedure sql_test(out_return out sys_refcursor) is
begin
open
out_return
for
‘select * from tgp_funds‘
;
end;
Https://zhidao.baidu.com/question/922899782581115539.html http://blog.csdn.net/xwq911/article/details/ 46278901 Guidance: Oracle does not support separate SELECT statements if a SELECT statement is used in the Oracle database stored procedure, either using a "SELECT INTO variable" statement or using a cursor.
Let's look at this stored procedure:
Create or replace procedure Pro_test
Is
Begin
SELECT * from T_test;
End Pro_test;
Is this stored procedure correct?
It was a long time since yesterday. (a SELECT statement was used in a stored procedure, but neither a cursor nor an into) was used.
In a stored procedure (Oracle database) If a SELECT statement is used, either using a "SELECT INTO variable" statement or using a cursor, Oracle does not support a separate SELECT statement (as stated in the wrong statement).
Select into is relatively simple, but if you return a result set, you will not be able to meet the requirements.
Cursors are divided into cursor-type cursors and Sys_refcursor-type cursors.
Cursor type cursors--cannot be used for parameter passing
Create or Replace procedure Pro_test () is
Cusor_1 Cursor is select field name from table name where condition;
(or
Select Class_name into cursor_2 from class where ...;
Another use of the cursor, which needs to be written between Begin and end)
Begin
Select Class_name into cursor_2 from class where ...;
can use
for XXX in cursor
Loop
....
End Loop; --Traversal of the cursor
End Pro_test;
Sys_refcursor-Type Cursors
Create or Replace procedure Pro_test (Rscursor out Sys_refcursor) is
Cursor sys_refcursor;
Name Varhcar (20);
Begin
Open cursor for
Select name from student where ...; --open to assign by using open
--Traversal
Loop
Fetch cursor into name--fetch into to open traversed each piece of data
Exit when Cursor%notfound; --No record information found
Dbms_output.putline (xxxx);
End Loop;
Rscursor: = cursor;
End Pro_test;
Http://www.cnblogs.com/sc-xx/archive/2011/12/03/2275084.html
Return SQL RET