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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

build / execute string in stored procedure 1

Status
Not open for further replies.

vadimg

IS-IT--Management
Oct 25, 2001
152
US
hi gurus.
Newbie to Oracle.

I need to pass a table name as a parameter to a stored procedure and then select from that table.

In sql server this would require building / executing a string (code below). What would be the equivalent syntax in pl-sql?

Alternatively, can you use a variable table name in a select statement in pl-sql?

Code:
create procedure blah @table nvarchar(255)
as
declare @command varchar(8000)
select  @command = 'select * from '+@table
exec sp_executesql @command

thanks!
 
About the same:
Code:
create procedure blah (table varchar2)
is
command varchar(8000);
Begin
 command:= 'select * from '||table;
 execute immediate command into ...;
End;
...




----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top