Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

procedure which gets tablenames as parameter-values

Status
Not open for further replies.

mokesql

Programmer
Sep 6, 2001
30
0
0
AT
hi!

i want to write a procedure with tablenames as parameter-values. it schould work so that i type procedure(tab1, tab2)
tab1 should be the in parameter and tab2 the out parameter. i want that the procedure coppies the values of tab1 in tab2. the tables will have the same structure. i thought about making this then with cursers over the whole table but i don`t realy know if this is going to work. please help me and thank you

kemo
 
If I undertstand your question correctly and you're using 8i, the following should work:

create or replace procedure copytables(tab1 VARCHAR2, tab2 VARCHAR2) AS
command_line VARCHAR2(2000) := 'INSERT INTO '||tab2||' SELECT * FROM '||tab1';

BEGIN
execute immediate command_line;
commit;
END;

I haven't tested this, but it should get you within striking distance. If you are using 8.0, you will need to use dbms_sql to accomplish this, but the basic idea is the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top