Guest User

Untitled

a guest
Mar 20th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. addr_id emp_id emp_name email1 isprimary
  2. --------- ------ -------- ----------------- ----------
  3.  
  4. 201 101 John John@gmail.com 1
  5. 202 101 John John_1@gmail.com 0
  6. 203 101 John John_2@gmail.com 0
  7. 205 104 Bond Bond@gmail.com 1
  8. 206 104 Bond Bond_4@gmail.com 0
  9. 207 104 Bond Bond_5@gmail.com 0
  10.  
  11. update x_addr_table1
  12. set email1=(select P1.priemail1
  13. from x_primary_email_table2 P1, x_profilepay_email_table3 P2
  14. where P1.emp_id=P2.emp_id )
  15. from x_addr_table1 a
  16. inner join x_primary_email_table2 T1
  17. on a.address_id=T1.address_id
  18. where a.emp_id=T1.emp_id
  19.  
  20. MERGE x_addr_table1 A
  21. USING (select T2.addr_id,T2.email1,T2.emp_id from x_primary_email_table2 T2, x_profilepay_email_table3 T3 where T2.emp_id=T3.emp_id and upper(T2.email1)!=upper(T3.email1)) as Source
  22. ON (a.addr_id=Source.addr_id and a.emp_id=source.emp_id)
  23. WHEN MATCHED THEN
  24. UPDATE SET a.email1=Source.email1
  25.  
  26. update x_addr_table1 a
  27. set email1=
  28. (
  29. select T2.priemail1
  30. from x_primary_email_table2 T2
  31. where T2.emp_id=a.emp_id
  32. )
  33. where a.addr_id in
  34. (
  35. select T2.addr_id
  36. from x_primary_email_table2 T2
  37. )
  38. and a.emp_id in
  39. (
  40. select T2.emp_id
  41. from x_primary_email_table2 T2, x_profilepay_email_table3 T3
  42. where t2.emp_id=t3.emp_id
  43. and upper(T2.priemail1)!=upper(T3.payemail1)
  44. )
Add Comment
Please, Sign In to add comment