Function StackDatabasePostgresExamples
Update Returns
Example 1: Update and Return
In this example, we'll use the Postgres Execute function with the Type set to Update Returns
to modify data and return the id
of the updated row.
Add Postgres Execute Function
Start by adding the Postgres Execute function. Give it a Result Name and set the Type to Update Returns
.
Write the SQL Query
Write the update query you want to run. Since we want to return the updated row's id
, use the RETURNING
clause.
Assume we have a users
table and want to update the name
of a user by their id
:
Update query with returning:
Define a Type
Since the query returns the id
, you need to define a primitive type like Int64
to capture it.