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 >> 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






 
User PL/SQL

 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
  menon srivalsala kumar638
  positive fanatic613
  Gitesh Trivedi482
  Jayanta Sur480
  Vinoth Kumar436
  Vigyan Kaushik394
  Gopu Gopi352
  Vishant Sanghavi320






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor