Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PLSQL and variable Table Names
"Annett Tempel" <annett.tempel_at_gmx.de> wrote in message
news:9gd72i$ta0$1_at_news.nrw.net...
> Hi,
>
> I have a short question.
> I have to write a SQL-Statement where I count the records.
> thats no problem.
>
> Code:
> CURSOR zaehler_cursor (tab_xx VARCHAR2:=tabelle) IS
> SELECT COUNT(*)
> FROM tab_xx;
>
> you see that I'll give the tablename with a parameter.
> But there is a mistake and I dont know where?
> Can you help me?
>
> Thanks and sorry for my english
> Annett
>
>
>
>
You need to use dynamic sql.
This would involve using the dbms_sql package in Oracle 7 and 8.0
and opening a ref cursor with Native Dynamic Sql in 8i and beyond.
Hth,
Sybrand Bakker, Oracle DBA Received on Fri Jun 15 2001 - 11:02:30 CDT