Home » SQL & PL/SQL » SQL & PL/SQL » ORA-00942:Table or View does not exist-Store procedure (Oracle 10g)
ORA-00942:Table or View does not exist-Store procedure [message #612891] Sun, 27 April 2014 08:11 Go to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member

CREATE OR REPLACE procedure CORE.WCC_UPDATE_REC_OMEGA1(
v_account_nbr IN NUMBER,
v_schema_name IN VARCHAR2)

IS

[b]s varchar2(20) :=v_schema_name;[/b]

BEGIN

UPDATE omega_contact NOLOGGING
       SET customername = 'DELETED CUSTOMER',
           contactno =
                    (CASE
                        WHEN contactno IS NOT NULL
                           THEN '0000000000'
                        ELSE contactno
                     END
                    ),
           feedbackdetail =
              (CASE
                  WHEN feedbackdetail IS NOT NULL
                     THEN 'DELETED NOTE'
                  ELSE feedbackdetail
               END
              )
     WHERE accountno IN (
              SELECT UNIQUE account_nbr
                       [b][/b]FROM s.cor_customers[b][/b]
                      WHERE code_external_credit_ref = '@'
                        AND COALESCE (v_account_nbr, cor_customers.account_nbr) =
                                                         cor_customers.account_nbr)
       AND countrycode = v_country_code;
COMMIT; 

 END WCC_UPDATE_REC_OMEGA1;
/


please look into the above procedure with the bolded ones.
when i am trying to compile this Proc ,by giving database schema name directly say nzl.cor_customers it runs properly.
if the same i do with passing the schema name as parameter (v_schema_name) doen't works.

Getting error as "ORA-00942:Table or View does not exist"

Please pardon me,ihave given only the problamatic statment from the big Proc.

The above proc is created under CORE schema and cor_customers table present under NZL schema.

I tried a lot to fix this,Expecting your help and i would be highly appreciating it.

Re: ORA-00942:Table or View does not exist-Store procedure [message #612892 is a reply to message #612891] Sun, 27 April 2014 08:23 Go to previous messageGo to next message
John Watson
Messages: 8989
Registered: January 2010
Location: Global Village
Senior Member
What you are trying to do is impossible: PL/SQL is a compiled language, and the objects have to be known at compile time. You could use dynamic SQL to construct and the statement at run time, but that is usually a very bad idea. You probably need to look your relational analysis (or lack thereof): I would guess that your data is not properly normalized if you need to do this sort of thing.
Re: ORA-00942:Table or View does not exist-Store procedure [message #612893 is a reply to message #612891] Sun, 27 April 2014 08:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68769
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Schema name in a statement cannot be a variable.
Either use a dynamic statement (bad option) or use a synonym (correct option) to avoid the usage of this schema name.
Why have you to pass the schema name?

Re: ORA-00942:Table or View does not exist-Store procedure [message #612895 is a reply to message #612893] Sun, 27 April 2014 08:32 Go to previous messageGo to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
Thank yu John and Michael..

My intention here was to create this procedure in a common schema and to call this proc from 7 different schemas(Like NZL there are other schemas SIN,MAL,NZL)..so that to avoid multiple procedure with the same content just differs with schema name alone...

Please advice for this do i need to have procedures seperately in each schema
Re: ORA-00942:Table or View does not exist-Store procedure [message #612898 is a reply to message #612895] Sun, 27 April 2014 09:11 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Please advice for this do i need to have procedures seperately in each schema

It depends upon what the procedure needs to do.

What is the downside to having the same code in every schema?
Re: ORA-00942:Table or View does not exist-Store procedure [message #612902 is a reply to message #612898] Sun, 27 April 2014 09:26 Go to previous messageGo to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
Hello Black,

There is no downside of this..But the requirent given was having a procedure in common to be used by multiple schemas by passing their schema names while compiling PROC.

So my understanding from all yours responce is, inside the proc statement there can't be schema name passed with variable name.

please correct if my understanding is wrong?

Thanks once agian.

[Updated on: Sun, 27 April 2014 09:32]

Report message to a moderator

Re: ORA-00942:Table or View does not exist-Store procedure [message #612903 is a reply to message #612902] Sun, 27 April 2014 09:31 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
You can pass schema name as a string variable.
You can poke yourself in the eye with a sharp pencil.
You are advised to avoid doing either action above.

see URL below for reasons why.
http://www.orafaq.com/forum/mv/msg/192533/612893/#msg_612893
Re: ORA-00942:Table or View does not exist-Store procedure [message #612904 is a reply to message #612903] Sun, 27 April 2014 09:39 Go to previous messageGo to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
Smile

Thanks Black,John and Michael
Re: ORA-00942:Table or View does not exist-Store procedure [message #612923 is a reply to message #612904] Sun, 27 April 2014 18:07 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
You have this problem due to a design flaw & the fact that the data is not normalized.
You should not have a separate schema for each customer.
A "CUSTOMER" column should be added to "every" table so that a query can only return rows associated with one specific customer.
Previous Topic: Cannot refresh Materialized View with Join in Oracle 12c 12.1.0.1.0 after Create
Next Topic: spotting errors (merged 2)
Goto Forum:
  


Current Time: Tue Sep 02 09:33:43 CDT 2025