ColdFusion Software Development Company ColdFusion Software Development Company

ColdFusion 8 Can Return Identity Values

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta …
NOTE: This is my personal blog, and the opinions and statements voiced here are my own. 

ColdFusion 8 Can Return Identity Values
Here’s another ColdFusion 8 goodie that I just learned about yesterday …
If you are using a database table with an identity (auto-increment) field, ColdFusion 8 can automatically return the newly created field value for you, without needing a trigger or a subsequent <CFQUERY>. All you need to do is look in the <CFQUERY> optional RESULT structure, and if available the value will just be there. This feature is very DBMS and driver specific (and unfortunately does not seem to be supported by Apache Derby), and the name of the structure member containing the generated value is different based on the DBMS being used. Here are the ones you should be aware of:

SQL Server: result.IDENTITYCOL
Oracle: result.ROWID
Sybase: result.SYB_IDENTITY
Informix: result.SERIAL_COL
DB2: result.KEY_VALUE
MySQL: result.GENERATED_KEY (MySQL 4 and 5 only, MySQL 3 does not support this feature)
Very nice indeed!

 Ben Forta


We would love to help.
Give us a call:

(718) 793-2828

Get a free project estimate:

Recent Comments