I'm pretty new when it comes to PL/SQL, and I have to modify someone else's stored procedure.
Is it possible to add an if statement in the middle of a select? The procedure I have tries to open a cursor and select a bunch of stuff from different tables into it (don't ask me why they didn't use a join) and return the cursor. The thing I'm trying to do is, there are two columns with similar data that can never both be populated in the same time. So if one is null, the other should have a value, and the cursor needs the value from whichever is populated. So... if statement inside the select?
I won't post the actual code, cause it'll make your eyeballs bleed, but it looks something like...
open rc for
select l.data1 as ld1, l.data2 as ld2, b.data1 as bd1,
b.data2 as bd2, c.data1 as as c_d1, c.data2 as cd2
from tablel l, tableb b, tablec c
where blahblahblah
and c.data1 = [b.data3 if b.data4 is null, else b.data4]?
I can't seem to get the syntax, if it's possible.