Helping fixing the code.

Hi Experts,
Help me fix the code below :

BEGIN
for i IN (SELECT owner, table_name, constraint_name
FROM dba_constraints
WHERE constraint_type ='R'
AND OWNER IN ('BO','CCRC', 'IA', 'MOMENTUM', 'ODS', 'PB', 'UFMS','UF_ODS', 'VSS', 'VSWMAUDIT', 'WFWMAUDIT', 'WMAUDIT', 'WORKFLOW')
AND status = 'ENABLED')
loop
EXECUTE IMMEDIATE 'alter table ' ||i.table_name|| ' disable constraint ' ||i.constraint_name;
end loop i;
End;
/


When I run the code above I get,

BEGIN
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 8

However, when I run the embeded Select statement, it runs successfully and I get 1650 rows.
Kamal AgnihotriAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
try changing:
EXECUTE IMMEDIATE 'alter table ' ||i.table_name|| ' disable constraint ' ||i.constraint_name;

To:
EXECUTE IMMEDIATE 'alter table ' || i.owner ||'.' ||i.table_name|| ' disable constraint ' ||i.constraint_name;
0
Kamal AgnihotriAuthor Commented:
Hi Slightwv,

Your sugestion worked, but when I make a slight change in the where clause, "WHERE constraint_type <>'R' " I get the same error.


SYS@ufms033>> BEGIN
  2  for i IN (SELECT owner, table_name, constraint_name
  3  FROM dba_constraints
  4  WHERE constraint_type <>'R'
  5  AND OWNER IN ('BO','CCRC', 'IA', 'MOMENTUM', 'ODS', 'PB', 'UFMS','UF_ODS', 'VSS', 'VSWMAUDIT',
'WFWMAUDIT', 'WMAUDIT', 'WORKFLOW')
  6  AND status = 'ENABLED')
  7  loop
  8  EXECUTE IMMEDIATE 'alter table '|| i.owner ||'.' ||i.table_name|| ' disable constraint ' ||i.co
nstraint_name;
  9  end loop i;
 10  END;
 11  /
BEGIN
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 8

Thanks alot.

Sincerely,

Kamal
0
slightwv (䄆 Netminder) Commented:
Technically a different question.

I'm not where I can verify this but is it possible to have a constraint on a table in a different schema?  Check the constraint types and owners and table owners.

There is either a different owner or a constraint type that isn't against a table.  I can't look it up now but this should really be a different question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.