Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When table another_schema.Dw_table used in store procedure only to fetch the data its working there but when I used in Insert statement it throws PL/SQL: ORA-00942 table or view does not exist.

What I have tried:

create or replace procedure tpk.sp_Test_proc
IS
   err_code      NUMBER;
   err_msg       VARCHAR (500);
   v_tbl_cnt     NUMBER;
   v_tbl_valid   NUMBER;
Begin
SELECT COUNT(*) INTO v_tbl_cnt  FROM USER_TABLES 
  WHERE TABLE_NAME IN (UPPER('Tbl1'),UPPER('tbl2'),UPPER('tbl3'));

IF(v_tbl_cnt =3) THEN

EXECUTE IMMEDIATE 'TRUNCATE TABLE Tbl1';
    EXECUTE IMMEDIATE 'TRUNCATE TABLE Tbl2'; 
    EXECUTE IMMEDIATE 'TRUNCATE TABLE Tbl3';

    EXECUTE IMMEDIATE 'DROP TABLE Tbl1';
    EXECUTE IMMEDIATE 'DROP TABLE Tbl2'; 
    EXECUTE IMMEDIATE 'DROP TABLE Tbl3';

EXECUTE IMMEDIATE
    'CREATE global temporary TABLE tbl1
    ( Id Integer... )'

Insert into tbl1
Select * from another_schema.Dw_table /* In this line it throws error Table does not exist */
end if;
end;
Posted
Updated 22-Jul-18 9:23am
Comments
RossMW 19-Jul-18 22:28pm    
I'm not a Oracle person, but wouldn't you need to commit the table create before you can use it...
CHill60 20-Jul-18 8:05am    
I'm with RossMW - it's tbl1 that it's complaining about

1 solution

How about:

WHERE UPPER(TABLE_NAME) IN (UPPER(…))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900