It does work and thats the way to do it.  Are you 100% it's an auto inc field?

http://cookbooks.adobe.com/post_Generated_key___Get_the_ID_of_the_inserted_record-16593.html

Paul.


On Jun 5, 2011, at 9:35 AM, Robert Rhodes wrote:

> 
> That's for MYSQL.  I am using SQL Server 2005.  The docs say "identityCol"
> 
> But I will give it a try......
> 
> Nope., didn't work.  Thanks, though. :)
> 
> On Sat, Jun 4, 2011 at 6:56 PM, Jason Durham <[email protected]> wrote:
> 
>> 
>> It's theResult.generatedKey
>> On Jun 4, 2011 4:46 PM, "Robert Rhodes" <[email protected]> wrote:
>>> 
>>> I am frustrated. :(
>>> 
>>> In the cf9 docs, it says that cfquery is supposed to return, in the
>> result
>>> variable, the identity column value of the inserted record. However it is
>>> not working from me.
>>> 
>>> Would one of you kind souls point out my mistake?
>>> 
>>> <cfquery datasource="someDsn" name="insertRecord" result="theResult">
>>> INSERT INTO
>>> someTable
>>> (
>>> firstName,
>>> lastName
>>> )
>>> VALUES
>>> (
>>> <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="20"
>>> value="#arguments.firstName#">,
>>> <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="20"
>>> value="#arguments.lastName#">
>>> )
>>> </cfquery>
>>> 
>>> <cfoutput>#theResult.identityCol#</cfoutput>
>>> 
>>> When I run this, identityCol is not there.
>>> 
>>> I am indeed using an autonumbering identity column in the database.
>>> 
>>> Yes, I know I can just add a select to this query to get at it, but I
>> really
>>> want this to work, dammit!
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345080
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to