Home » SQL & PL/SQL » SQL & PL/SQL » Passing table as parameter into a procedure
Passing table as parameter into a procedure [message #2356] Tue, 09 July 2002 12:49 Go to next message
Sudha
Messages: 29
Registered: November 2000
Junior Member
I want to pass a table as a parameter through a procedure. i tried using dynamic sql but i keep getting the error that the variable i am using for tablename must be declared. Can you help me with this giving an example???
Re: Passing table as parameter into a procedure [message #2359 is a reply to message #2356] Tue, 09 July 2002 13:41 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
This is just an example of how you would incorporate the parameter into an EXECUTE IMMEDIATE statement and a cursor.

create or replace procedure p(
  p_table_name in user_tables.table_name%type)
is
  type rc is ref cursor;
  v_rc  rc;
begin
  execute immediate 'truncate table ' || p_table_name;
  open v_rc for 'select c1 from ' || p_table_name;
  close v_rc;
end;
/
Previous Topic: JOINT ISSUE - PLEASE HELP!!
Next Topic: Database Copy
Goto Forum:
  


Current Time: Thu Mar 28 19:04:42 CDT 2024