views:

345

answers:

3

I tried to register a schema in Oracle the other day to validate an XML document. The code I used was fairly simple:

dbms_xmlschema.registerSchema(schemaURL => 'http://www.myCompany.com/schema',
                              schemaDoc => :schemaCLOB);

At first, everything seemed to work well, as far as validation goes. I noticed though, that there were dozens of new database objects: tables, triggers and types (a few dowsn tables and triggers, but probably many hundreds of types). I tried to delete the schema like this:

dbms_xmlschema.deleteSchema(schemaURL => 'http://www.myCompany.ca/schema',
                            delete_option => dbms_xmlschema.DELETE_INVALIDATE);

That de-registered the schema, but all of the objects were left behind.

I RTFM'd a little too late and discovered that the extra objects were created by leaving default values in the call to registerSchema, so I realized I would have to manually remove the extra objects.

Now when I try to remove the objects, Oracle tells me they don't exist. I can't select from them and my IDE (PL/SQL Developer) shows them as being invalid (a little red "X" beside them). I also can't find any info on these tables in all_tables. How do I get rid of these?

A: 

Hi,

I'm probably missing something obvious but looking at the documentation could you not use the DELETE_CASCADE or DELETE_CASCADE_FORCE options?

carpenteri
In theory, yes, and that's probably what I'll do going forward (as well as use FALSE for gentables and gentypes).I tried running my delete script and tried both of these options. It ran for over an hour (close to 2 I think) and the DBA just told me now to kill it and he'll see if he can purge these things.
FrustratedWithFormsDesigner
Got access to metalink? If so check to see if you are affected by:Bug 8498273: DBMS_XMLSCHEMA.DELETESCHEMA HANGS FOREVERor Bug 3581743: DBMS_XMLSCHEMA.DELETESCHEMA FAILED LEAVING SCHEMA OBJECTS THAT CAN'T BE DELETED
carpenteri
No, what's metalink? Can you post a URL for those two bugs?
FrustratedWithFormsDesigner
As Marco has said it's Oracle's support site. Unfortunately due to clause(s) in the metalink contract I'm not allowed to post more details of the bugs.
carpenteri
A: 

Metalink is Oracle's support site (http://support.oracle.com) but you would need a customer support ID(entifier) to enter the protected site.

If on 11g use DBMS_XMLSCHEMA.PURGESCHEMA to get rid of the objects. If on 10gRx use

dbms_xmlschema.deleteSchema(schemaURL => 'http://www.myCompany.ca/schema', delete_option => dbms_xmlschema.DELETE_CASCADE_FORCE);

or

dbms_xmlschema.deleteSchema('http://www.myCompany.ca/schema',4);

If that doesn't help bounce the database after using force delete and try again. If that doesn't help, delete the schema via a delete statement based on user_xml_schemas (last option is not supported).

Marco Gralike
We're on 10.2g here. Most likely we will restore from the backup for my schema from Monday (no major losses if I do).I'm not even sure where I would delete the schema from if I were to do it manually, based on user_xml_schemas.
FrustratedWithFormsDesigner
A: 

Solution was: restored from previous day's backup. In the future, I'll be setting gentables and gentypes to FALSE ALWAYS, and delete with DELETE_CASCADE_FORCE. Anything doesn't work with that, I'll probably post a new question.

FrustratedWithFormsDesigner