Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Handling when a table does not exist.

2729403Jan 9 2015 — edited Jan 15 2015


I have a query that pulls relevant configuration codes from the database.  Because I run this code against different releases of the database and some of the older releases do not have all the tables the newer ones do, I want to see if I can write a clause to handle if the table does not exist.  Example shown below is only two of 75 unioned queries.  If one of the 75 tables is not in the release, the entire script fails.

Is there a way to do Case when SYT_SYSTEM_TABLE does not include table, then skip else run the query?  What every I end up with, it has to be self correcting, because the query is embedded into an Excel Spreadsheet data connection and the user can't make modifications.

Using Oracle 11g.  Can not use PLSQL.

SELECT 'ANC' AS WB, 'NCR' AS TBL, NCR_CODE AS CODE, NCR_DESC AS DESCRIPTION, 'NA' AS MEANING, NCR_RECORD_STATUS AS STATUS FROM NCR_NEW_CASE_RESPONSE

UNION

SELECT 'CMDM' AS WB, 'PDR' AS TBL, PDR_CODE AS CODE, PDR_DESC AS DESCRIPTION, 'NA' AS MEANING, PDR_RECORD_STATUS AS STATUS FROM

PDR_PROG_DISENROLLMENT_REASON

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2015
Added on Jan 9 2015
8 comments
3,053 views