Solved

Using DECODE to determine Table for Select Statement

Posted on 2004-04-28
2
1,462 Views
Last Modified: 2007-12-19
Using Oracle 8i.  I'm trying to do something like this:

open refcur for
  select a.field, b.field
  from DECODE(in_program, 'fpd', tablea1, tablea2) a,
          tableb b
  where a.pk = in_param
      and a.fk = b.pk;

Basically one of the tablenames needs to change based on a parameter being passed to the stored procedure.  I could use IF..THEN syntax to open the reference cursor but I'll have 8 different possiblities so I'm trying to come up with something cleaner.

Any ideas?
0
Comment
Question by:frodoman
2 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 500 total points
ID: 10940039
Use if ...then instead, my friend.

DECODE won't work here in your particular case.
0
 
LVL 42

Author Comment

by:frodoman
ID: 10940072
I was afraid that was the answer but was hoping someone knew of a trick.

Thanks for the quick response!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 107
Outer Query not returning data - SQL HELP 16 50
Migrating an SQL 2008 database to Oracle 12c 3 90
Export table into csv file in oracle 10 46
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now