I write a simple procedure. I try to store selection result in variable. I use "SELECT INTO" query but I can not doing this.
Example:
DECLARE
v_employeeRecord employee%ROWTYPE;
BEGIN
SELECT * INTO v_employeeRecord
FROM Employee WHERE Salary > 10;
END;
You have a couple options. You could turn that query into a cursor:
Or, you can create a
TABLE
variable:I haven't tried these samples in Oracle, so you may get compiler errors...
IF your SELECT returns more than one row, you won't be able to use the SELECT INTO synthax.
You will need to build a loop to navigate through the resulte set:
Adam demonstrated how you would use an explicit cursor and a bulk collect loop. I will show how you can build the simplest loop possible (implicit cursor, doesn't need a DECLARE section):