Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Use variables in a SELECT INTO FROM command

485251Sep 15 2010 — edited Sep 15 2010
Hi,

How do I use variables within a select into from command? I want to loop through SYS.DBA_TABLES using a cursor and count the number of rows in a
selection of tables an then insert into a cardinality table.

The count of rows will be stored in a variable called CNT, that bit is easy however I need a variable in the FROM clause because that
value changes with every iteration of the cursor.

e.g.

CNT := 0;
TN := "MyTable";

select count(*) into CNT FROM TN;
insert into cardinality (table_name, row_count) values (TN, CNT);


This is Oracle 9i and I need the row counts in a separate table as they are shipped over to a different environment for analysis purposes.

Any ideas?

Regards
Dave

Edited by: Yorky001 on Sep 15, 2010 10:32 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2010
Added on Sep 15 2010
14 comments
3,227 views