Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Beginners question : How to use varchar2 within a sql statement ?
Dear Oracle experts,
I have a beginners question concerning development of Stored Procedures in a Oracle 10g database.
I tried to use a procedure like below, where I gave a varchar2 called
tablename.
If I try to use the variable tablename in a select statement I get the
the error
"invalid table name" during compilation of the SP.
But how can I use a variable to type a tablename into the SP externally
?
Best regards,
Daniel
CREATE OR REPLACE PROCEDURE SA.SELECTFROMTABLE
(modus BOOLEAN, tablename varchar2 ) AS
cursor tabledata is
select * from tablename ;
BEGIN
if modus = true then
for i in tabledata
LOOP
dbms_output.put_line(i.ID);
END LOOP;
else
dbms_output.put_line(tablename);
end if;
END;
Received on Thu Jun 01 2006 - 08:56:26 CDT