Solved

Using DECODE to determine Table for Select Statement

Posted on 2004-04-28
2
1,466 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

726 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