Home » SQL & PL/SQL » SQL & PL/SQL » parameter in SQL command
parameter in SQL command [message #10097] Mon, 05 January 2004 09:44 Go to next message
Deb
Messages: 17
Registered: November 2001
Junior Member
Does any one know how to pass a parameter to a SQL cmd.

For example, I wanna do this.

SELECT table_name INTO a_tab FROM dba_tables WHERE ........

Now I want to alter the table in a_tab using
ALTER TABLE 'table_name' command. How do I substitute the 'table_name' in the ALTER TABLE command with my a_tab?

Any inputs will be greatly appreciated.

Thx
Re: parameter in SQL command [message #10098 is a reply to message #10097] Mon, 05 January 2004 09:50 Go to previous message
sverch
Messages: 582
Registered: December 2000
Senior Member
declare
a_tab varchar2(10);

begin

select table_name into a_tab from USER_tables where table_name='T1';

EXECUTE IMMEDIATE 'TRUNCATE TABLE '||a_tab;

END;
Previous Topic: Scheduling job every 3 hours using DBMS_JOB
Next Topic: To get the value returned from a proc/Function with in a shell script
Goto Forum:
  


Current Time: Tue Apr 23 13:51:59 CDT 2024