Solved

Using DECODE to determine Table for Select Statement

Posted on 2004-04-28
2
1,463 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to recover a database from a user managed backup

809 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