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: PL/SQL variables in the "from" part of a select statement

Re: PL/SQL variables in the "from" part of a select statement

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Fri, 22 Nov 2002 17:21:15 GMT
Message-ID: <fItD9.2707$ev1.82062475@newssvr14.news.prodigy.com>


rac wrote:
> Does anyone know if it is possible to access a variable in the "from
> table" section of a query?
> I have the following code (not exact)
>
> DECLARE
> local_var VARCHAR2(30);
> count1 NUMBER;
>
> CURSOR list_tables is
> select table_name from all tables;
>
>
> BEGIN
> open list_tables;
> LOOP
> FETCH list_tables INTO local_var;
>
> select count(*) into count1 from local_var;
>
>
> Error resulting is:
> ORA-06550: line .......
> PLS-00201: identifier 'LOCAL_VAR' must be declared.
>
>
> Any suggestions??
>
> Thanks.

You might want to make it something like this:

execute immediate 'select count(*) into count1 from ' || local_var; Received on Fri Nov 22 2002 - 11:21:15 CST

Original text of this message

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