Home » SQL & PL/SQL » SQL & PL/SQL » how to trapping error in SQL using SYS.DBMS_XMLGEN (oracle 11g redhat)
how to trapping error in SQL using SYS.DBMS_XMLGEN [message #640201] Thu, 23 July 2015 09:47 Go to next message
Freewilly3d
Messages: 2
Registered: July 2015
Junior Member
the following query is part of a more complex query I'm using to streamline testing dimensional integrity of a data warehouse and will fail when a table in my source table is not found in the schema; I get an error like:

Error during Execute
S1000(19202)[Oracle][ODBC][Ora]ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1

I would like to do something like an iferror() ...

SELECT TABLE_NAME,
TO_NUMBER(EXTRACTVALUE(XMLTYPE(DBMS_XMLGEN.GETXML('SELECT COUNT(*) CNT FROM '||TABLE_NAME )),'/ROWSET/ROW/CNT')) AS COUNT
FROM pldsbx.wstandketest2
where
table_name like 'WC%F'
AND FKTABLE_NAME <> 'IGNORE'
group by table_name
Re: how to trapping error in SQL using SYS.DBMS_XMLGEN [message #640202 is a reply to message #640201] Thu, 23 July 2015 09:51 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Hi,

Welcome to the forum!

Please read and follow the OraFAQ Forum Guide and How to use [code] tags and make your code easier to read..
Re: how to trapping error in SQL using SYS.DBMS_XMLGEN [message #640203 is a reply to message #640201] Thu, 23 July 2015 09:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Just add in the WHERE clause "and table_name in (select table_name from user_tables)".

What is the purpose of "group by"?

Re: how to trapping error in SQL using SYS.DBMS_XMLGEN [message #640213 is a reply to message #640203] Thu, 23 July 2015 10:53 Go to previous messageGo to next message
Freewilly3d
Messages: 2
Registered: July 2015
Junior Member
The source table has rows for every dimension associated with the fact table. I only want one row that I can compare to all the dimension row counts.
Thanks, I thought of that just after I posted.
Re: how to trapping error in SQL using SYS.DBMS_XMLGEN [message #640214 is a reply to message #640213] Thu, 23 July 2015 10:55 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Do you mind posting a test case.
Previous Topic: how to clear the output data using utl_file?
Next Topic: SUM & Cursor
Goto Forum:
  


Current Time: Wed Apr 24 13:57:21 CDT 2024