not getting identity value from insert
Can you spot where I am off? Please help... GO insert into #request.sqlobjectprefix#TblEmailRecovery ( guid, emailaddress ) VALUES ( cfqueryparam cfsqltype=cf_sql_varchar value=#variables.newguid#, cfqueryparam cfsqltype=cf_sql_varchar value=#qry_emailToPK.emailaddress# ); GO SELECT @@IDENTITY AS 'Identity'; GO ~| 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:358685 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: not getting identity value from insert
On Tue, May 27, 2014 at 1:34 PM, Matthew Smith chedders...@gmail.comwrote: SELECT @@IDENTITY AS 'Identity' You might try using IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') http://msdn.microsoft.com/en-us/library/ms175098.aspx Otherwise, what are you looking for? Until Later! C. Hatton Humphrey http://www.eastcoastconservative.com Every cloud does have a silver lining. Sometimes you just have to do some smelting to find it. ~| 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:358686 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: not getting identity value from insert
Actually the issue here is the GO between the insert and the select @@identity. Using go between them makes them in to two separate unrelated batches. Steve -Original Message- From: C. Hatton Humphrey [mailto:chumph...@gmail.com] Sent: Tuesday, May 27, 2014 1:39 PM To: cf-talk Subject: Re: not getting identity value from insert On Tue, May 27, 2014 at 1:34 PM, Matthew Smith chedders...@gmail.comwrote: SELECT @@IDENTITY AS 'Identity' You might try using IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') http://msdn.microsoft.com/en-us/library/ms175098.aspx Otherwise, what are you looking for? Until Later! C. Hatton Humphrey http://www.eastcoastconservative.com Every cloud does have a silver lining. Sometimes you just have to do some smelting to find it. ~| 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:358687 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: not getting identity value from insert
still not working. hmm... cfif qry_emailToPK.recordcount cfset variables.newguid = CreateUUID() cfquery name=qry_CREATETOKEN datasource=#variables.datasource# insert into #request.sqlobjectprefix#TblEmailRecovery ( guid, emailaddress ) VALUES ( cfqueryparam cfsqltype=cf_sql_varchar value=#variables.newguid#, cfqueryparam cfsqltype=cf_sql_varchar value=#qry_emailToPK.emailaddress# ); SELECT IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') as mynewidentity; go /cfquery cfelse cfoutputSorry, your email was not found.a href=/index.cfm/fuseaction/authentication.go/cfid/#cfid#/cftoken/cftoken/index.cfmPlease click here to create an account./a/cfoutput /cfif On Tue, May 27, 2014 at 2:13 PM, DURETTE, STEVEN J sd1...@att.com wrote: Actually the issue here is the GO between the insert and the select @@identity. Using go between them makes them in to two separate unrelated batches. Steve -Original Message- From: C. Hatton Humphrey [mailto:chumph...@gmail.com] Sent: Tuesday, May 27, 2014 1:39 PM To: cf-talk Subject: Re: not getting identity value from insert On Tue, May 27, 2014 at 1:34 PM, Matthew Smith chedders...@gmail.com wrote: SELECT @@IDENTITY AS 'Identity' You might try using IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') http://msdn.microsoft.com/en-us/library/ms175098.aspx Otherwise, what are you looking for? Until Later! C. Hatton Humphrey http://www.eastcoastconservative.com Every cloud does have a silver lining. Sometimes you just have to do some smelting to find it. ~| 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:358688 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: not getting identity value from insert
still not working. hmm... cfif qry_emailToPK.recordcount cfset variables.newguid = CreateUUID() cfquery name=qry_CREATETOKEN datasource=#variables.datasource# insert into #request.sqlobjectprefix#TblEmailRecovery ( guid, emailaddress ) VALUES ( cfqueryparam cfsqltype=cf_sql_varchar value=#variables.newguid#, cfqueryparam cfsqltype=cf_sql_varchar value=#qry_emailToPK.emailaddress# ); SELECT IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') as mynewidentity; go /cfquery Are you sure this table even has an identity column? If so, why do you also need a GUID? Normally, you'd have one or the other, but not both. Dave Watts, CTO, Fig Leaf Software 1-202-527-9569 http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ~| 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:358689 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: not getting identity value from insert
I am sorry. The email address was not in there and I had the code improperly nested. Thank you all for the help. I am sorry for the carelessness. Good day. On Tue, May 27, 2014 at 3:25 PM, Dave Watts dwa...@figleaf.com wrote: still not working. hmm... cfif qry_emailToPK.recordcount cfset variables.newguid = CreateUUID() cfquery name=qry_CREATETOKEN datasource=#variables.datasource# insert into #request.sqlobjectprefix#TblEmailRecovery ( guid, emailaddress ) VALUES ( cfqueryparam cfsqltype=cf_sql_varchar value=#variables.newguid#, cfqueryparam cfsqltype=cf_sql_varchar value=#qry_emailToPK.emailaddress# ); SELECT IDENT_CURRENT('#request.sqlobjectprefix# TblEmailRecovery') as mynewidentity; go /cfquery Are you sure this table even has an identity column? If so, why do you also need a GUID? Normally, you'd have one or the other, but not both. Dave Watts, CTO, Fig Leaf Software 1-202-527-9569 http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ~| 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:358690 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm