Unix Technical Forum

Re: Rookie Question

This is a discussion on Re: Rookie Question within the Oracle Miscellaneous forums, part of the Oracle Database category; --> > Hello, > possibly it is a very simple "rookie" question but: > This statement don't work. why? > ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-07-2008, 08:54 AM
Rene Nyffenegger
 
Posts: n/a
Default Re: Rookie Question


> Hello,
> possibly it is a very simple "rookie" question but:
> This statement don't work. why?
>
> DECLARE
> CURSOR c1 IS
> SELECT a.tablename FROM info_tablerows a;
> rows number;
> BEGIN
> FOR r IN c1 LOOP
> SELECT count(*) INTO rows FROM r.tablename;
> UPDATE info_tablerows SET rowcount = rows WHERE tablename =
> r.tablename;
> END LOOP;
> END;
> /
>
> At "SELECT count(*) INTO rows FROM r.tablename;" the message
> "identifier r.tablename must be declared" appears.
> Isn't it possible to reference my tablename?
>
> regards ruediger


Ruediger,

You might want to try dmbs_stats.gather_table_stats alternatively:


create table t1 (a number);

begin
for i in 100 .. 110 loop
insert into t1 values (i);
end loop;
end;
/

create table t2 (a number);

begin
for i in 1000 .. 1100 loop
insert into t2 values (i);
end loop;
end;
/

create table t3 (a number);
begin
for i in 2000 .. 2200 loop
insert into t3 values (i);
end loop;
end;
/

commit;


create table info_tablerows (
tablename varchar2(30) primary key
);

insert into info_tablerows values ('t1');
insert into info_tablerows values ('t2');
insert into info_tablerows values ('t3');

commit;

declare
cursor c is select tablename from info_tablerows;
begin
for r in c loop
dbms_output.put_line(r.tablename);
dbms_stats.gather_table_stats(user,r.tablename);
end loop;
end;
/

create view v_num_rows as
select num_rows, table_name from
user_tables u, info_tablerows i where
u.table_name = upper(i.tablename);

select * from v_num_rows;



hth
Rene Nyffenegger

--
Projektleitung und Entwicklung in Oracle/C++/C# Projekten
http://www.adp-gmbh.ch/cv.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:13 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com