Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Beginners question : How to use varchar2 within a sql statement ?

Beginners question : How to use varchar2 within a sql statement ?

From: Daniel Wetzler <Daniel.Wetzler_at_sig.biz>
Date: 1 Jun 2006 06:56:26 -0700
Message-ID: <1149170186.017146.288660@y43g2000cwc.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US