CFQuery – Results Attribute
If you’re working on a legacy application or indeed a new application and your either not sure what going on in the CFQuery especially when you use CFQueryParam. Then there is a variable that is returned from CFQuery that contains some very useful information.
In your CFQuery if you set the result=”insertQueryResults” you’ll get a structure giving you information about the query which has just been run, along with the actual SQL. This can be handy if you have IF Statements in the SQL and want to see what was sent to the database, there is also the all the params sent along when using CFQueryParam.
In addition if your doing an Insert statement you can get your new ID back. The name of the variable returned will depend on your flavor of DB
result_name.IDENTITYCOL
SQL Server only. The ID of an inserted row.
result_name.ROWID
Oracle only. The ID of an inserted row. This is not the primary key of the row, although you can retrieve rows based on this ID.
result_name.SYB_IDENTITY
Sybase only. The ID of an inserted row.
result_name.SERIAL_COL
Informix only. The ID of an inserted row.
result_name.GENERATED_KEY
MySQL only. The ID of an inserted row. MySQL 3 does not support this feature.
Some duplicate information is also returned that you get in the stand CFQuery Structure, but you can also get the execution times and if the query was cached or not which can again help when trying to debug an application.
Sponsored Links
Twitter
Recent Comments
- Dale Hans on dropBoxCFC – DropBox API
- Dale Hans on dropBoxCFC – DropBox API
- DEFOE on dropBoxCFC – DropBox API
- DEFOE on dropBoxCFC – DropBox API
- Richard Herbert on How I have been managing my work inbox for 2012.
Categories
Archives








