Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------
- --**Drop temp_smartnodelist_full if it exists and then create
- DROP IF exists temp_smartnodelist_full
- create temp table temp_smartnodelist_full (
- txid varchar(64)
- ,index int
- ,status varchar(100)
- ,protocol int
- ,address varchar(34)
- ,lastseen int
- ,activeseconds int
- ,lastpaidtime int
- ,lastpaidblock INT
- ,ip varchar(20)
- ,PRIMARY KEY(address, txid)
- );
- ------------------------------------------------------------------------------
- ---**Merge into smartnodelist_full on address and txid and insert when exists
- MERGE into smartnodelist_full sf
- USING (SELECT txid
- ,index
- ,status
- ,protocol
- ,address
- ,lastseen
- ,activeseconds
- ,lastpaidtime
- ,lastpaidblock
- ,ip
- FROM temp_smartnodelist_full
- ) AS tsf
- ON tsf.address = sf.address
- and tsf.txid=sf.txid
- WHEN MATCHED
- UPDATE SET --Balance = Balance - TransactionValue
- sf.index=tsf.index
- ,sf.status=tsf.status
- ,sf.protocol=tsf.protocol
- ,sf.lastseen=tsf.lastseen
- ,sf.activeseconds=tsf.activeseconds
- ,sf.lastpaidtime=tsf.lastpaidtime
- ,sf.lastpaidblock=tsf.lastpaidblock
- ,sf.ip=tsf.ip
- WHEN NOT MATCHED
- INSERT (sf.txid
- ,sf.index
- ,sf.status
- ,sf.protocol
- ,sf.address
- ,sf.lastseen
- ,sf.activeseconds
- ,sf.lastpaidtime
- ,sf.lastpaidblock
- ,sf.ip )
- VALUES( tsf.txid
- ,tsf.index
- ,tsf.status
- ,tsf.protocol
- ,tsf.address
- ,tsf.lastseen
- ,tsf.activeseconds
- ,tsf.lastpaidtime
- ,tsf.lastpaidblock
- ,tsf.ip
- )
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement