Home » SQL & PL/SQL » SQL & PL/SQL » How to read the variable value for table name in pl/sql
How to read the variable value for table name in pl/sql [message #36438] Wed, 28 November 2001 00:11 Go to next message
Cherilyn Tan
Messages: 2
Registered: November 2001
Junior Member
Hi,
I need to know is it possible for me to read an assigned variable for a table name, that i am using for an insert statement in pl/sql. Here's the code.

BEGIN
new_tablename := 'arch_'|| s_tDBTableName;
curr_tablename := s_tDBTableName;

INSERT INTO new_tablename
(SELECT * FROM curr_tablename
WHERE XmID = n_vmXmID AND XmType = s_vmXmType);
...

END;

Cause when I compile the stored procedure, I get this error message.
PLS-00201: identifier 'NEW_TABLENAME' must be declared

Please advise.

----------------------------------------------------------------------
Re: How to read the variable value for table name in pl/sql [message #36441 is a reply to message #36438] Wed, 28 November 2001 01:17 Go to previous messageGo to next message
tinel
Messages: 42
Registered: November 2001
Member
try something like this

BEGIN
new_tablename := 'arch_'|| s_tDBTableName;
curr_tablename := s_tDBTableName;

EXECUTE IMMEDIATE 'INSERT INTO ' || new_tablename || ' (SELECT * FROM ' || curr_tablename || 'WHERE XmID = n_vmXmID AND XmType = s_vmXmType)';
...

END;

----------------------------------------------------------------------
Re: How to read the variable value for table name in pl/sql [message #37178 is a reply to message #36438] Tue, 22 January 2002 13:42 Go to previous message
Hugo Martinez
Messages: 1
Registered: January 2002
Junior Member
I

I have already tried with EXECUTE IMMEDIATE command and it seems not to be working.

I wonder if some else has any other idea

Thanks for any help
Previous Topic: order by
Next Topic: Re: trigger trouble
Goto Forum:
  


Current Time: Mon Aug 02 09:59:29 CDT 2021