![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
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? Thanks for hints. regards ruediger |
#2
| |||
| |||
|
|
Hi Rüdiger you can do it with "execute immediate" execute immediate 'SELECT count(*) FROM '||r.tablename into rows; execute immediate 'UPDATE info_tablerows SET rowcount ='|| rows || 'WHERE tablename = '|| r.tablename ; It's not possible with normal SQL Rgds Dirk "Ruediger Tams" <ruediger.tams (AT) komtel (DOT) net> schrieb im Newsbeitrag news:3F0D6CAF.9B59D538 (AT) komtel (DOT) net... 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? Thanks for hints. regards ruediger |
#3
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |