Skip to content

Instantly share code, notes, and snippets.

@christophervigliotti
Created June 1, 2022 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophervigliotti/43f44057fa11a4fca7abddf01903d3b9 to your computer and use it in GitHub Desktop.
Save christophervigliotti/43f44057fa11a4fca7abddf01903d3b9 to your computer and use it in GitHub Desktop.
ColdFusion => Get ID of inserted record when using cfscript.
<cfscript>
// given
var queryObject = new Query(
name = "resultsQuery",
sql = "
INSERT
INTO …
"
);
// Execute the query first using
result = queryObject.execute();
// and then get the generated key
generated_key = result.getPrefix().generatedKey;
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment