Click to See Complete Forum and Search --> : Ora-00942


Nikee
12-18-2002, 10:56 AM
Hello,

The system is responding with the ORA-00942 error message when I ran the following code. Please help me..

---------------------------------------------------

DECLARE
Tname varchar2(30);
CURSOR C1 IS SELECT table_name FROM dba_tables where chain_cnt > 0;

BEGIN
Open C1;
Loop
Fetch C1 into Tname;
dbms_output.put_line( 'Analying the table: ' || Tname );
execute immediate 'analyze table Tname list chained rows';
EXIT WHEN C1%NOTFOUND;
End Loop;
CLOSE C1;
End;
/

---------------------------------------------------
Here is the error message:

ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 10

---------------------------------------------------

Thanks,
Seenu

slimdave
12-18-2002, 11:02 AM
You are missing the table owner out, and ...

execute immediate 'analyze table Tname list chained rows';

... should be ...

execute immediate 'analyze table '||Towner||'.'||Tname||' list chained rows';

Nikee
12-18-2002, 11:18 AM
Thank you.

-Seenu

Nikee
12-18-2002, 01:49 PM
Hello,

I have one last quick question.
The system is responding with the ORA-00904 error message when I ran the following code:
--------------------------------------------------------
DECLARE
Tname varchar2(30);
CURSOR C1 IS SELECT table_name FROM dba_tables where chain_cnt > 0;

BEGIN
Open C1;
Loop
Fetch C1 into Tname;

Execute Immediate 'CREATE table migrated_rows as SELECT orig.* FROM ' || Tname || ' orig, chained_rows cr WHERE orig.rowid = cr.head_rowid AND cr.table_name = upper('||Tname||')';

EXIT WHEN C1%NOTFOUND;
End Loop;
CLOSE C1;
End;
/

--------------------------------------------------------
Error Message:

ERROR at line 1:
ORA-00904: invalid column name
--------------------------------------------------------

Kind regards,
Seenu

stecal
12-18-2002, 01:57 PM
select orig.*? Interesting technique; however, this is not in Oracle's functional skill set.

Nikee
12-18-2002, 02:00 PM
Hello steven,

The CREATE table migrated_rows as SELECT orig.* FROM command works when I execute it individually at he SQL prompt.

Thanks,
Seenu