Home » SQL & PL/SQL » SQL & PL/SQL » decode function help (oracle 10g/SQL navigator)
decode function help [message #423871] Mon, 28 September 2009 16:51 Go to next message
singhz
Messages: 1
Registered: September 2009
Junior Member
Hi All,

I am new to pl/sql and need some help on the decode function. my problem is i need to set a flag ABC to Y if the itemtype is 'XYZ' and itemstatus is 'PQR' how can i write this using a decode? Since decode only compares one value at a time. Should i use 2 decodes for setting the value of the same flag? Please help me.Thanks in advance. awaiting reply.
Re: decode function help [message #423872 is a reply to message #423871] Mon, 28 September 2009 17:02 Go to previous messageGo to next message
vesile_taskiran
Messages: 66
Registered: August 2008
Location: Turkey
Member
" SELECT DECODE(:NAME,'JOHN','JOHN1','JANE','JANE1','TOM','TOM1','NONAME')
FROM DUAL "

Run this one and give the name
Re: decode function help [message #423873 is a reply to message #423871] Mon, 28 September 2009 17:03 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
concatenate the two fields
Re: decode function help [message #423877 is a reply to message #423871] Mon, 28 September 2009 23:21 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use CASE instead.

Regards
Michel
Re: decode function help [message #423906 is a reply to message #423877] Tue, 29 September 2009 03:42 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
As Michel says - definitely use CASE.

Your code would be
CASE WHEN itemtype = 'XYZ' AND itemstatus = 'PQR' then 'Y'
     ELSE 'N'
     END
Previous Topic: Drop all table under a user without dropping user
Next Topic: What am I making wrong
Goto Forum:
  


Current Time: Sun Dec 04 02:56:43 CST 2016

Total time taken to generate the page: 0.07537 seconds