In my oracle stored procedure,I need to create temporary table. I want to insert rows in temporary table based on some logic and return this rows from stored procedure.
My database is in oracle 11G. I am using oracle sql developer for creating stored procedure.
Getting below error while trying to fetch multiple rows.
Error(6,4): PLS-00428: an INTO clause is expected in this SELECT statement
CREATE OR REPLACE PROCEDURE TestStoredP AS
stmt varchar2(1000);
BEGIN
select emp_id,empname INTO AAA,BBB from EMPLOYEE;
stmt := 'create global temporary table temp(id number(10))';
EXECUTE IMMEDIATE stmt;
stmt := 'insert into temp values(1)';
EXECUTE IMMEDIATE stmt;
stmt := 'select * from temp';
EXECUTE IMMEDIATE stmt;
execute immediate ' drop table temp';
END TOPS;
Please suggest how to implement this.
intoclause, as the error suggests. You should not create a table (or usually do any DDL) in a procedure. You can use a PL/SQL collection if you really need temporary storage of interim results, or an SQL type, depending on what and how you want to 'return'. You have no out parameters, and you'd usually return data from a function not a procedure, so it isn't clear what you really need. - Alex Poole