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

Home -> Community -> Usenet -> c.d.o.misc -> Re: [PL/SQL] Help - Select into from a variable tablename?

Re: [PL/SQL] Help - Select into from a variable tablename?

From: Jim Smith <jim_at_jimsmith.demon.co.uk>
Date: 1997/04/19
Message-ID: <VmuzKHAEmOWzEwlp@jimsmith.demon.co.uk>#1/1

In article <5j97k7$1pn_at_news1-alterdial.uu.net>, David & Janet Harris <music_at_waymark.com> writes
>I need some help selecting into from a variable tablename.
>Example:
>
> Procedure CountTable(tbl char) is
> cnt number;
> BEGIN
> select count(*) into cnt from tbl;
> dbms_output.put_line (tbl || ' ' || cnt);
> end;
>
>PL/SQL interprets tbl as an existing table and fails. I would like to have a
>loop call this routine for each table in a user's schema yielding these
>results:
>
>Tablename Cnt
>--------- ---
>TABLE1 234
>TABLE2 823
>.
>.
>.
>
>Any ideas? Thanks in advance.

You can use the DBMS_SQL package to do dynamic sql in PL/SQL.

-- 
Jim Smith
Received on Sat Apr 19 1997 - 00:00:00 CDT

Original text of this message

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