| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: [PL/SQL] Help - Select into from a variable tablename?
In article <5j97k7$1pn_at_news1-alterdial.uu.net>,
David & Janet Harris <music_at_waymark.com> wrote:
>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.
I just had this discussion at work...I don't think you can use a variable as the "from" part of the select ...if you find out otherwise, please let me know how you did it...
I believe we resorted to writing a Pro*C program and built the sql statement dynamically...let me know if you find out how to do it in a stored procedure.
Dara
--
Talk to you later!
Dara
__\/__
/ ^ ^ \
(\| (o)(o) |/)
------------------oOOOo--oo--oOOOo-------------------------
| Dara Fong e-mail: fongda<at>netcom<dot>com |
-----------------------------------------------------------
| Any unsolicited commercial e-mail and/or the inclusion |
| of my user-id in any mailing list without my express |
| prior written approval, including the receipt of a mass|
| e-mail message and/or the unauthorized reselling of |
| this user-id to mailing list vendors, will be met with |
| a complaint to your internet provider. It is |
| recommended you do not attempt these practices. Should |
| you choose to ignore this warning, you will be subject |
| to any remedy which may be exercised by your internet |
| provider. You have been warned. |
-----------------------------Oooo.-------------------------
.oooO ( )
( ) ) /
\ ( (_/
\_)
Received on Sat Apr 19 1997 - 00:00:00 CDT
![]() |
![]() |