Home » SQL & PL/SQL » SQL & PL/SQL » Need equivalent Decode for this Case (11)
Need equivalent Decode for this Case [message #573850] Thu, 03 January 2013 10:59 Go to next message
cplusplus1
Messages: 40
Registered: October 2012
Location: usa
Member
Can you please provide an equivalent decode for the below case logic.

case when Ord_Type like '%PT%' then 'Y'
when Ord_Type like '%DG%' then 'Y'
when Ord_Type like '%DMD%' then 'Y'
when Ord_Type like '%DPD%' then 'Y'
else 'N'
end PLAT_T3

Thank you very much for teh helpful info.
Re: Need equivalent Decode for this Case [message #573854 is a reply to message #573850] Thu, 03 January 2013 11:14 Go to previous messageGo to next message
Littlefoot
Messages: 19345
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Something like this, perhaps?
decode(sign(instr(ord_type, 'PT')), 1, 'Y',
       decode(sign(instr(ord_type, 'DG')), 1, 'Y',
              decode(sign(instr(ord_type, 'DMD')), 1, 'Y',
                     decode(sign(instr(ord_type, 'DPD')), 1, 'Y', 'N'))))

What do you need it for?

[Updated on: Thu, 03 January 2013 11:17]

Report message to a moderator

Re: Need equivalent Decode for this Case [message #573856 is a reply to message #573854] Thu, 03 January 2013 11:21 Go to previous messageGo to next message
cplusplus1
Messages: 40
Registered: October 2012
Location: usa
Member
LittleFoot, Thank you very much for the help. Question: does this take care of Wild card '%PT%' or is it fixed.
Re: Need equivalent Decode for this Case [message #573858 is a reply to message #573856] Thu, 03 January 2013 11:24 Go to previous messageGo to next message
cplusplus1
Messages: 40
Registered: October 2012
Location: usa
Member
Thanks a lot it is working good.
Re: Need equivalent Decode for this Case [message #573859 is a reply to message #573850] Thu, 03 January 2013 11:24 Go to previous message
Michel Cadot
Messages: 58638
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why do you want to use DECODE when it is not appropriate?
You can do it, it is a good excercise, but no one will be able to read and maintain it afterwards.

Regards
Michel
Previous Topic: ORA-06508: PL/SQL: could not find program unit being called:
Next Topic: PDF to Oracle table
Goto Forum:
  


Current Time: Thu Jul 31 17:19:46 CDT 2014

Total time taken to generate the page: 0.09345 seconds