Re: PLSQL and variable TABLE Name
Date: Sat, 21 Jul 2001 21:54:19 GMT
Message-ID: <31ff53d1.0106180949.6bffb34_at_posting.google.com>
You should use dynamic SQL in order to pass a table name as a parameter.
If you have Oracle 8.1 or higher you could use native dynamic SQL:
declare
type my_type is ref cursor;
my_cur my_type;
var integer;
table_name varchar2(30) := 'tabelle';
begin
open my_cur for 'select count(*) from ' || table_name;
fetch my_cur into var;
close my_cur;
end;
Otherwise you have to use dbms_sql package.
"Annett Tempel" <annett.tempel_at_gmx.de> wrote in message news:<9gd51p$ngk$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
Received on Sat Jul 21 2001 - 23:54:19 CEST