Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL+: Using a variable name for the table name

Re: SQL+: Using a variable name for the table name

From: Andy Thompson <AndrewT_at_MedImpact.com>
Date: Wed, 4 Aug 1999 20:52:36 -0700
Message-ID: <37a90a7d@news1.jps.net>


Nigel,

   You will have to use dynamic SQL to accomplish what you are trying to do. Check
the docs on the DBMS_SQL (Oracle supplied)package.

Good Luck,
Andy

nigel_tufnel_at_my-deja.com wrote in message <7oagqg$617$1_at_nnrp1.deja.com>...
>Here's my problem. There are about 28 tables that I need to modify, all
>of them in exactly the same way, so I was hoping to put all the table
>names in a temporary table (MY_TABLE_LIST), and then scroll through the
>names in it.
>
>My problem is that I can't get SQL Plus to acknowledge the table name.
>Here's a small test case that doesn't work:
>
>DECLARE
> cursor T is
> select table_name from MY_TABLE_LIST;
> TAB_REC T%rowtype;
>
>BEGIN
> open T;
> loop
> fetch T into TAB_REC;
> exit when T%notfound;
> select count(*) from TAB_REC.TABLE_NAME;
> end loop;
> commit;
> close T;
>END;
>
>It says that TAB_REC.TABLE_NAME is not a table. I have tried other
>test cases to insure that the string is getting set correctly, and it
>is, but maybe I need to truncate it? Help!
>
>table_name is defined as varchar(30) just like in dba_tab_columns.
>
>Thanks,
>
>Nigel
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Wed Aug 04 1999 - 22:52:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US