Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PL/SQL Function for If Statement

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
Good day ..

Would like a little assistance on writting a function. In one table, I need to look at 5 seperate columns labeled:
allowed, denied, copay, hold, misc.

Basically I need to create a function that will determine which column is filled and return that result. One of the columns will always be filled. I would like to do something like:

I would think that you would use a nested If statement, but just not sure how to do it in PL/SQL. Any help is appreciated.
 
SELECT allowed, denied, copay, hold, misc
INTO a,d,c,h,m
FROM....

Return Nvl(a, Nvl(d, Nvl(c, Nvl(h,m))));
 
nvl(allowed,nvl(denied,nvl(copay, nvl(hold, misc))))
 
If your're using Oracle 9i:
SELECT COALSECE(allowed,denied,copay,hold,misc) FROM...

Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top