Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. ------------------------------------------------------------------------------
  2. --**Drop temp_smartnodelist_full if it exists and then create
  3. DROP IF exists temp_smartnodelist_full
  4. create temp table temp_smartnodelist_full (
  5. txid varchar(64)
  6. ,index int
  7. ,status varchar(100)
  8. ,protocol int
  9. ,address varchar(34)
  10. ,lastseen int
  11. ,activeseconds int
  12. ,lastpaidtime int
  13. ,lastpaidblock INT
  14. ,ip varchar(20)
  15. ,PRIMARY KEY(address, txid)
  16. );
  17. ------------------------------------------------------------------------------
  18. ---**Merge into smartnodelist_full on address and txid and insert when exists
  19. MERGE into smartnodelist_full sf
  20.  
  21. USING (SELECT txid
  22. ,index
  23. ,status
  24. ,protocol
  25. ,address
  26. ,lastseen
  27. ,activeseconds
  28. ,lastpaidtime
  29. ,lastpaidblock
  30. ,ip
  31. FROM temp_smartnodelist_full
  32. ) AS tsf
  33.  
  34. ON tsf.address = sf.address
  35. and tsf.txid=sf.txid
  36.  
  37. WHEN MATCHED
  38. UPDATE SET --Balance = Balance - TransactionValue
  39. sf.index=tsf.index
  40. ,sf.status=tsf.status
  41. ,sf.protocol=tsf.protocol
  42. ,sf.lastseen=tsf.lastseen
  43. ,sf.activeseconds=tsf.activeseconds
  44. ,sf.lastpaidtime=tsf.lastpaidtime
  45. ,sf.lastpaidblock=tsf.lastpaidblock
  46. ,sf.ip=tsf.ip
  47.  
  48. WHEN NOT MATCHED
  49. INSERT (sf.txid
  50. ,sf.index
  51. ,sf.status
  52. ,sf.protocol
  53. ,sf.address
  54. ,sf.lastseen
  55. ,sf.activeseconds
  56. ,sf.lastpaidtime
  57. ,sf.lastpaidblock
  58. ,sf.ip )
  59. VALUES( tsf.txid
  60. ,tsf.index
  61. ,tsf.status
  62. ,tsf.protocol
  63. ,tsf.address
  64. ,tsf.lastseen
  65. ,tsf.activeseconds
  66. ,tsf.lastpaidtime
  67. ,tsf.lastpaidblock
  68. ,tsf.ip
  69. )
  70. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement