I'm looking for a way for my query to return a value that it increments in a table.
For example:
UPDATE Items SET Clicks = Clicks + 1
I need this query to return the new value of "Clicks" that it has set.
The T-SQL Output Clause seems to suit my purposes, but I can't find a DB2 equivalent. Is there a way I could accomplish this in DB2, without using a second query?
You can do this by using FINAL TABLE data change table reference:
SELECT Clicks
FROM FINAL TABLE ( UPDATE Items SET Clicks = Clicks + 1 )
You can view more documentation here .
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.