Previously, I answered some questions from some netizens about how to wear a collection of returned records in www.linuxidc.comlinux2012-0765117.htm. Presumably
Before in The Post http://www.linuxidc.com/Linux/2012-07/65117.htm answered some netizens on how to wear a collection of returned records stored procedures. Presumably
In the previous post, I answered some questions from some netizens about how to wear a stored procedure that returns a set of records. I think many netizens already understand this. I will not talk about it more here.
How to call a stored procedure with a cursor in sqlplus
How Does Oracle execute the process with a cursor?
Here is an example.
-- Use the cursor (the cursor is actually a temporary table in the memory)
Declare
Money cms3_simcard.card_1_% type: = 0; -- Define the same type as the table Field
Cursor mycursor is -- defines the cursor
Select * from cms3_simcard
Where return_flag = 1 and msisdn like '000000 ';
My_record mycursor % rowtype; -- defines the cursor record type
Counter int: = 0;
Begin
Open mycursor; -- open the cursor
If mycursor % isopen then -- determines whether the open is successful
Loop -- Obtain Record Sets cyclically
Fetch mycursor into my_record; -- get records in the cursor
If mycursor % found then -- the cursor's found attribute determines whether a record exists
Dbms_output.put_line (my_record.card_logs );
Else
Exit;
End if;
End loop;
Else
Dbms_output.put_line ('cursor not opened ');
End if;
Close mycursor;
End;
If you want to ask me how to call the program, you should not ask because there are too many people who know it. No more nonsense.
First, let's look at the table structure of t1.
Check the data in Table T1.
As with the previous post, create a package first
Creating a stored procedure with a cursor is a stored procedure that returns a set of records.
All the data is available, and the focus is on it. A collection of records returned when a stored procedure is called