28 November 2019

When you have primary keys generated by the database not by the application, then you might need it to be returned. In postgres you have to use RETURNING function in your sql query in order to have anything returned after insert. This example shows you how to use it, load the results as you do with regular select query.

Source code viewer
  1. INSERT INTO files (name, uri, type, size) VALUES ($1, $2, $3, $4) RETURNING id;
Programming Language: PostgreSQL