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.
|
|
|
|
| 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 |
Send this thread to your friend |
|
|
|
|
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 Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gopu Gopi | 327 |
| Gitesh Trivedi | 322 |
| Vinoth Kumar | 264 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|