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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Assigning a variable to a table name in FROM statement ???

Re: Assigning a variable to a table name in FROM statement ???

From: Jim Kennedy <kennedy-family_at_home.com>
Date: Mon, 09 Apr 2001 13:25:49 GMT
Message-ID: <xLiA6.696986$U46.21790944@news1.sttls1.wa.home.com>

You need to use the dbms_sql package or if you are using 8i then the execute immediate.
Jim

"Bernhard Acke" <ba_at_metropolis.de> wrote in message news:3ad1a9f4$1_at_netnews.web.de...
> I want to get the number of datasets from a different tables,
> where table names are stored in a separate table.
>
>
> Is it possible to assign the table name dynamically in the
> FROM-Part of the SELECT-Statement (as a variable), so can do
> this with a loop.
>
>
> I thought of something like this, but it doesnt work:
>
>
> DECLARE
> actual_scheme_name VARCHAR(30) := 'students';
> actual_table_name VARCHAR(30) := 'adresses';
> number_of_datasets_entered NUMBER(10) := 0;
> BEGIN
> actual_table := actual_scheme_name || '.' || actual_table_name;
> SELECT count (rowid)
> INTO number_of_datasets_entered
> FROM actual_table;
> ============
> DBMS_OUTPUT.PUT_LINE(number_of_datasets_entered);
> EXCEPTION
> END;
>
>
>
> Any Ideas?
>
>
> Thank you,
>
>
> Bernhard
>
>
>
> --
> _____________________________________________________________
> NewsGroups Suchen, lesen, schreiben mit http://netnews.web.de
Received on Mon Apr 09 2001 - 08:25:49 CDT

Original text of this message

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