Using DECODE to determine Table for Select Statement

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?
LVL 42
frodomanAsked:
Who is Participating?
 
seazodiacCommented:
Use if ...then instead, my friend.

DECODE won't work here in your particular case.
0
 
frodomanAuthor Commented:
I was afraid that was the answer but was hoping someone knew of a trick.

Thanks for the quick response!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.