generatedKey in Postgres

I have an app that runs fine with Lucee & MariaDB but I need it to run with PostgreSQL also. The current issue is when inserting records into the DB the generatedKey field is coming back with the ID and all of the inserted values.

Example:

INSERT INTO table ( username ) VALUES ( 'bsmith' );
generatedKey = "3,bsmith"

Don’t forget to tell us about your stack!

OS: Arch Linux
Java Version: OpenJDK 11.0.6
Jetty Version: 9.4.26.v20200117
Lucee Version: 5.3.4.80

if u can use sql-dialect for postgres u can use:
RETURNING

<cfquery name="q">
INSERT INTO table ( username ) VALUES ( 'bsmith' )
RETURNING id
</cfquery>

last id is in #q.id# var

1 Like