Solved

Using DECODE to determine Table for Select Statement

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

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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 shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to take different types of Oracle backups using RMAN.

759 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

25 Experts available now in Live!

Get 1:1 Help Now