简体   繁体   中英

How to do an Upsert operation using WSO2 CEP and Siddhi Query Language

I have an userStream having username,ipaddress,timestamp

I want to store this details in UserDetailsTable (In memory table) and need to do an upsert . How could I able to update the row if username and ipaddress are same and insert otherwise as a new row.

For example:

Ist userStream is "Rockey","192.15.12.11","10-10-2015 10.32"
2nd userStream is "Jose","192.15.12.21","10-10-2015 10.33"
3rd userStream is "Rockey","192.15.12.11","10-10-2015 10.34"

Result of UserDetailsTable is below

"Jose","192.15.12.21","10-10-2015 10.33"   (New row)
"Rockey","192.15.12.11","10-10-2015 10.34" (Update the existing row)

You can use following method.

from userStream
select username, ipaddress ,timestamp
update UserDetailsTable
on UserDetailsTable.username == username

Please not that stream attributes and event tables attributes needs to be same. Hope this helps.

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM