Help with Oracle IF statment

Hi All,

I am looking to extract a date from a notes box which will always appear after the # symbol. I have achieved this with the following line of code

SUBSTR (FINE_NOTES,(INSTR (FINE_NOTES, '#')+1)) AS "Received Date",

I am now attempting to take it one stage further to return NULL if the # symbol is not present as there is other text in the notes box which I do not require. I have tried with the following code but am getting errors and I am struggling to see the issue.


Any help greatly appreciated,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try
 select case when INSTR(FINE_NOTES, '#') >0 then SUBSTR (FINE_NOTES,(INSTR (FINE_NOTES, '#')+1))  else null  end as "Received Date"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nitin SontakkeDeveloperCommented:
Or hopefully...

IIF(INSTR (FINE_NOTES, '#') != 0, SUBSTR(INSTR (FINE_NOTES, '#')+1),  NULL) AS "Received Date", 

Open in new window

I am more of a T-SQL developer than PL/SQL one, so please take it with table-spoon of salt!
kaleesAuthor Commented:
Perfect solution, many thanks
PortletPaulEE Topic AdvisorCommented:
FYI only:

To my knowledge up till now IIF() is not supported by PL/SQL and (I think) also isn't part f the SQL standards either.
Which is why I always prefer case expressions even for T-SQL.
Nitin SontakkeDeveloperCommented:
I googled and found it here. So pasted the solution. Only after seeing your posted I noticed that it is part of MDX and not of PL/SQL.

Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.