I need to capture the Identity field after inserting a record. I was told to use the @@IDENTITY ( function. So I have this:
<cfquery name="InsertRequest" datasource="#db#">
INSERT INTO tbl_SchedJobs
(Station, TestProfile, TestCategory, BusinessGroup, RequestorWWID, ProductCode,
NumUnits, TestComments, RequestStartDate, RequestEndDate, Status, Funded)
VALUES
(#Station#, #Profile#, #Category#, #GetCustomerData.GroupCode#, '#WWID#', '#Product#',
#NumUnits#, '#Comments#', '#RequestStartDate#', '#RequestEndDate#', '#Status#', #GetCustomerData.FundingUnit#)
SELECT @@IDENTITY as 'ID'
</cfquery>
<cfset ID = #InsertRequest.ID#>
and I get an error setting the ID:
An error occurred while evaluating the expression:
ID = #InsertRequest.ID#
Error near line 73, column 8.
------------------------------------------------------------
Error resolving parameter INSERTREQUEST.ID
If I run my query in SQL Query Analyzer it returns the ID.
Any ideas on what's wrong?
<cfquery name="InsertRequest" datasource="#db#">
INSERT INTO tbl_SchedJobs
(Station, TestProfile, TestCategory, BusinessGroup, RequestorWWID, ProductCode,
NumUnits, TestComments, RequestStartDate, RequestEndDate, Status, Funded)
VALUES
(#Station#, #Profile#, #Category#, #GetCustomerData.GroupCode#, '#WWID#', '#Product#',
#NumUnits#, '#Comments#', '#RequestStartDate#', '#RequestEndDate#', '#Status#', #GetCustomerData.FundingUnit#)
SELECT @@IDENTITY as 'ID'
</cfquery>
<cfset ID = #InsertRequest.ID#>
and I get an error setting the ID:
An error occurred while evaluating the expression:
ID = #InsertRequest.ID#
Error near line 73, column 8.
------------------------------------------------------------
Error resolving parameter INSERTREQUEST.ID
If I run my query in SQL Query Analyzer it returns the ID.
Any ideas on what's wrong?