[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Update or insert record based on table column

Asked by ksummers in PL / SQL, Oracle Database, Oracle 10.x

Tags: allroundautomations, PL/SQL Developer, 7.0.2.1076

I have a stored procedure which inserts records into a table and then needs to insert and/or update records in the table.  I am assuming that I need a if-then-else clause or a loop of some sort, but how do I do this based on a key column?

Basically, if the loan number exists in the table, then I want to update it.  If it does not exist, then I want to insert it.  See soe of my SQL below.  Thanks for your help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
Insert Into Next_Action_By_Days_Detail
			  (Job_ID_Key,
  			 Processing_timeStamp,
	  		 Organization_Number,
		  	 Lender_Number,
			   Days,
  			 Property_State_Abbreviation,
	  		 Loan_Number,
		  	 Payee_Code,
			   ZC_Jurisdiction_LDesc,
  			 Payee_Parcel_Number,
	  		 Next_Action_Date,
		  	 Next_Action_Type_MLDesc,
			   Contact_Notes)
  		Select
	  	    GenerateData.Job_ID_Key,
		  	  vCurrDate,
          GenerateData.Organization_Number,
			    l.Lender_Number,
  			  nvl(dp.Next_Action_Date, vCurrDate) - vCurrDate as Days,
	    		l.Property_State_Abbreviation,
          l.loan_number,
		    	lpp.Payee_Code,
  		  	j.ZC_Jurisdiction_LDesc,
	  		  dp.Payee_Parcel_Number,
  		  	dp.Next_Action_Date,
	  		  dp.Next_Action_Type_MLDesc,
  	  		dp.Notes
  	  From
		    	Loan l,
			    Delq_Parcel dp
			   Left Join Lender_Payee_Profile lpp on
			      lpp.Lender_Payee_Code = dp.Lender_Payee_Code
            and nvl(lpp.Inactive_ind,'NO') = 'NO'
  			  Left Join ZC_Jur_List j on
	  		    j.ZC_Jurisdiction_Code = Lpp.Payee_Code
            and nvl(j.Inactive_ind,'NO') = 'NO',
  		  Lender lr
  	  Where
          Dp.delq_loan_key=l.delq_loan_Key
		  and nvl(l.inactive_ind,'NO') = 'NO'
      and nvl(lr.inactive_ind,'NO') = 'NO'
	    And nvl(Dp.Next_Action_type_MLDesc,'@#$%^') <> '@#$%^'
		  And Upper(dp.Next_Action_Type_MLDesc)  not like
                         vTempDesc
  	  And lr.Organization_Number = GenerateData.Organization_Number
	  	And ((vLender_Number <=  0
			     And l.Lender_Number = lr.Lender_Number)
  		  Or (vLender_Number > 0
	  	     And l.Lender_Number = vLender_Number
           And lr.lender_number = l.Lender_Number))
		  And lpp.Lender_Number = l.Lender_Number;
 
      commit;
      
      Insert Into Next_Action_By_Days_Detail
			  (Job_ID_Key,
  			 Processing_timeStamp,
	  		 Organization_Number,
		  	 Lender_Number,
			   Days,
  			 Property_State_Abbreviation,
	  		 Loan_Number,
		  	 Payee_Code,
			   ZC_Jurisdiction_LDesc,
  			 Payee_Parcel_Number,
	  		 Next_Action_Date,
		  	 Next_Action_Type_MLDesc,
			   Contact_Notes)
  		Select
	  	    GenerateData.Job_ID_Key,
		  	  vCurrDate,
          GenerateData.Organization_Number,
			    l.Lender_Number,
  			  nvl(dp.Next_Action_Date, vCurrDate) - vCurrDate as Days,
	    		l.Property_State_Abbreviation,
          l.loan_number,
		    	lpp.Payee_Code,
  		  	j.ZC_Jurisdiction_LDesc,
	  		  dp.Payee_Parcel_Number,
  		  	dp.Next_Action_Date,
          dp.ccsd_status_desc,
  	  		dp.Notes
  	  From
		    	Loan l,
			    Delq_Parcel dp
			   Left Join Lender_Payee_Profile lpp on
			      lpp.Lender_Payee_Code = dp.Lender_Payee_Code
            and nvl(lpp.Inactive_ind,'NO') = 'NO'
  			  Left Join ZC_Jur_List j on
	  		    j.ZC_Jurisdiction_Code = Lpp.Payee_Code
            and nvl(j.Inactive_ind,'NO') = 'NO',
  		  Lender lr
  	  Where
          Dp.delq_loan_key=l.delq_loan_Key
		  and nvl(l.inactive_ind,'NO') = 'NO'
      and nvl(lr.inactive_ind,'NO') = 'NO'
	    And nvl(Dp.ccsd_status_desc,'@#$%^') <> '@#$%^'
		  And Upper(dp.ccsd_status_desc)  not like
                         vTempDesc
  	  And lr.Organization_Number = GenerateData.Organization_Number
	  	And ((vLender_Number <=  0
			     And l.Lender_Number = lr.Lender_Number)
  		  Or (vLender_Number > 0
	  	     And l.Lender_Number = vLender_Number
           And lr.lender_number = l.Lender_Number))
		  And lpp.Lender_Number = l.Lender_Number;
      
      commit;
[+][-]07/14/08 09:32 AM, ID: 21999622Accepted Solution

Your question has an Asker Certified™ answer! ksummers verified that this solution worked for them--which means it will likely work for you, too. Click to view the solution free for 30-days now.

About this solution

Zones: PL / SQL, Oracle Database, Oracle 10.x
Tags: allroundautomations, PL/SQL Developer, 7.0.2.1076
Sign Up Now!
Solution Provided By: jwittenm
Participating Experts: 3
Solution Grade: A
 
[+][-]07/14/08 10:32 AM, ID: 22000189Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07/16/08 12:20 AM, ID: 22013857Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20100215-EE-VQP-121 / EE_QW_2_20070628