Does Vantiq allow you to use “SET” in an “UPDATE” statement?

Hi all,

When we use SQL, we can sometimes use a statement like this:

UPDATE order_detail SET amount = amount + 100 WHERE id = 123

In VANTIQ, is there any similar way to do this?

Thanks.

Posted: April 30, 2021 at 4:24 pm
Replies: 2
Apr 30, 2021
Posted by VANTIQ Support

Vantiq does not support this kind of update syntax currently in VAIL so you have to do a SELECT ONE, followed by the UPDATE, like this:

var current = SELECT EXACTLY ONE FROM order_detail where id == 123

UPDATE order_detail(amount: current.amount + 100) where id == 123

 

Apr 30, 2021
Posted by Brett Rudenstein

It’s worth pointing out that if you had to do this to several records you can use streaming syntax.

SELECT ONE FROM order_detail AS item where <SOME CLAUSE>{
var amount = item.amount + 100
UPDATE order_detail(amount:amount) where id == item.id
}

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
© Vantiq 2024 All rights reserved  •  Vantiq Corporation’s Privacy Policy and Cookie Policy