Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 8 of 8 total |
Update and return updated value |
Thu, Apr 14 2016 1:22 PM | Permanent Link |
Ideal Software Systems | Is it possible to write an update statement that returns the updated value?
Something like: update mytable set field1=field1+1 where keyfield=123 returns field1 |
Fri, Apr 15 2016 4:24 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | I don't think so. You could investigate a script though.
Roy Lambert |
Fri, Apr 15 2016 7:49 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << Is it possible to write an update statement that returns the updated value? >>
No. I could look into adding this, but it would require: 1) That the UPDATE statement only update a single row. 2) The UPDATE statement is parameterized Tim Young Elevate Software www.elevatesoft.com |
Fri, Apr 15 2016 12:55 PM | Permanent Link |
Ideal Software Systems | << Is it possible to write an update statement that returns the updated value? >>
> No. I could look into adding this, but it would require: > 1) That the UPDATE statement only update a single row. > 2) The UPDATE statement is parameterized Those are acceptable restrictions |
Fri, Apr 15 2016 1:06 PM | Permanent Link |
Ideal Software Systems | > I don't think so. You could investigate a script though.
Script won't work. The point is to do the update and read of value atomically so as to get the new value as updated before someone else changes it. You would have to use transactions to make that work in multiple statements which introduces extra locking issues. If you can do it in a single statement, it solves a lot of problems. |
Fri, Apr 15 2016 1:11 PM | Permanent Link |
Uli Becker | > << Is it possible to write an update statement that returns the updated value? >>
A simple procedure or script with an additional output param will do it: SCRIPT BEGIN EXECUTE IMMEDIATE 'CREATE PROCEDURE "GetNewValue" (IN "FID" INTEGER, IN "FOffset" INTEGER, OUT "FResult" INTEGER) BEGIN Execute Immediate ''UPDATE MyTable SET Counter = Counter + ? WHERE ID = ?'' USING FOffset, FID; Execute Immediate ''SELECT Counter INTO ? FROM MyTable WHERE ID = ?'' USING FResult, FID; END VERSION 1.00'; END Uli |
Fri, Apr 15 2016 2:04 PM | Permanent Link |
Ideal Software Systems | > A simple procedure or script with an additional output param will do it:
Not atomically. |
Mon, Apr 18 2016 10:20 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << Those are acceptable restrictions >> I'll look into sneaking it into the next build. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, May 14, 2024 at 07:14 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |