NeonN
Neon3y ago
2 replies
full-green

Use transaction query result in next query?

I checked here (https://github.com/neondatabase/serverless/blob/main/CONFIG.md#transaction-function) and didn't see an option, but:

Is it possible for a query in a transaction set to reference a returned value from a previous query? E.g.:

await sql.transaction([
  sql`INSERT INTO xyz(...) RETURNING id`,
  sql({ id } => `INSERT INTO abc(...) VALUES(..., ${id})`),
]
GitHub
Connect to Neon PostgreSQL from serverless/worker/edge functions - neondatabase/serverless
serverless/CONFIG.md at main · neondatabase/serverless
Was this page helpful?