Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> decode

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: decode
 Muks  Posted: Jun 03, 2008 02:55:31 AM

 Total Post: 47
 Joined: Jan, 2007






 Hi,

when i am using the following query

select DECODE(sal*10/100+sal,880,2)
REVISED_SALARY
FROM emp;
it runs fine but if i use operator in it, it fails to run ....my question here is can we use operator in decode

select DECODE(((sal*10/100+sal)>(2695)),880,2)
REVISED_SALARY
FROM emp;

 Nehru
Posted: Jun 03, 2008 03:08:47 AM  

 Total Post: 46
 Joined: Jul, 2007






 
Hi,
We can't use Operators in DECODE.
Just exact matchings only.

select decode(<variable_name>, <matching>, <then this one>, <else this one>) from dual;

Any one let me know if am wrong
Take Care
Nehru

 Azaz
Posted: Jun 03, 2008 09:02:14 AM  

 Total Post: 84
 Joined: Mar, 2008






 
We cannot use operators in DECODE conditions



 Azaz
Posted: Jun 03, 2008 09:25:17 AM  

 Total Post: 84
 Joined: Mar, 2008






 
It is better to use CASE statements in SQL for such operations rather than DECODE
For example

SELECT title, price,
Budget = CASE price
WHEN price > 20.00 THEN 'Expensive'
WHEN price BETWEEN 10.00 AND 19.99 THEN 'Moderate'
WHEN price < 10.00 THEN 'Inexpensive'
ELSE 'Unknown'
END,
FROM titles



 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi327
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software