Function StackDatabasePostgresExamples
Delete Returns
Example 1: Delete and Return Data
In this example, we'll use the Postgres Execute function with the Type set to Delete Returns
to remove data and return specific values from the deleted rows.
Add Postgres Execute Function
Start by adding the Postgres Execute function. Give it a Result Name and set the Type to Delete Returns
.
Write the SQL Query
In the function configuration, write the SQL query with a RETURNING
clause to get the deleted data.
Assume we have a users
table and want to delete users where id > 15
. We also want to return their name
. The table schema looks like this:
Now write the following query:
Define a Type
Next, define a primitive type like String
to hold the result.