Topic: SQL*Plus and PL/SQL >> Can I avoid repetition in NVL?
|
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: Can I avoid repetition in NVL? |
| shake |
Posted: Jul 03, 2009 06:56:41 AM |
Total Post: 96
Joined: Jun, 2008
|
Can someone suggest any solution for avoiding the same query get repeated inside an NVL statement?.
To be more specific, consider this piece in a query.
SELECT MEM.MEM_ID,
NVL(
(SELECT PAY.DUE_AMOUNT FROM T_MST_PAYMENTS PAY
WHERE PAY.PAYEE_ID=MEM.MEM_ID),
null, 0,
(SELECT PAY.DUE_AMOUNT FROM T_MST_PAYMENTS PAY
WHERE PAY.PAYEE_ID=MEM.MEM_ID)
)
FROM T_MST_MEMBERS MEM
WHERE
...
...
Here, in this query I'm calculating if the due amount is null; if so then I display 0; but if it is not, the default value which is fetched by the query is displayed.
Now, I want to know how I can avoid repeating the same query second time but I need to display the actual value in case non-null value is returned.
Suggest a solution... This tortures me a lot when I handle big subqueries inside a NVL. |
|
|
Babu |
| Posted: Jul 10, 2009 05:43:31 AM | |
|
Total Post: 98
Joined: Oct, 2007
|
Yout answer or still locking?
Babu
|
|
|
|
|
Vish |
| Posted: Jul 15, 2009 02:29:49 PM | |
|
Total Post: 320
Joined: Jan, 2007
|
|
|
|
|
| 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 |
| menon srivalsala kumar | 638 |
| positive fanatic | 613 |
| Gitesh Trivedi | 482 |
| Jayanta Sur | 480 |
| Vinoth Kumar | 436 |
| Vigyan Kaushik | 394 |
| Gopu Gopi | 352 |
| Vishant Sanghavi | 320 |
|
|