Re: table name substitution in pl/sql

From: Ana C. Dent <anacedent_at_hotmail.com>
Date: Wed, 01 Oct 2003 17:27:20 -0700
Message-ID: <GhKeb.43688$Ms2.16007_at_fed1read03>


Suresh wrote:
> how can we use a variable in the place of a tablename?
>
> towner=scott
> ttable_name=emp
> select count(*) into totrows from towner.ttable_name;
>
> ERROR at line 18:
> ORA-06550: line 18, column 49:
> PLS-00201: identifier 'TOWNER.TTABLE_NAME' must be declared
> ORA-06550: line 18, column 15:
> PL/SQL: SQL Statement ignored
>
> I need to substitute different table names. How do I pass variable
> names as table names? Towner and ttable_names are declared in the
> declare section.
>
> Thanks
>
> Suresh

Use Dynamic SQL, such as EXECUTE IMMEDIATE Received on Thu Oct 02 2003 - 02:27:20 CEST

Original text of this message