I'm trying to insert records in two related tables: Requests, and
RequestDetails. "ReqID" is the primary key for Requests, and a foreign key
in RequestDetails.
To simplify things, I'm using static data for userID, ReqDate, and ProductID
in the code below.
----------------------------------------------------------------------------
---
<cftransaction>
<cfquery name="qAddRequest" datasource="#application.ds#" dbtype="ODBC">
INSERT INTO Requests (userID, ReqDate)
VALUES (17, '5/3/2001') ;
</cfquery>
<cfquery name="qGetReqID" datasource="#application.ds#" dbtype="ODBC">
SELECT Max(ReqID) AS CurrentReqID
FROM Requests;
</cfquery>
<cfquery name="qAddRequestDetail" datasource="#application.ds#"
dbtype="ODBC">
INSERT INTO RequestDetails (RequestID, ProductID)
VALUES (#CurrentReqID#, 99002);
</cfquery>
</cftransaction>
----------------------------------------------------------------------------
---
If I output the value of #CurrentReqID# I get the correct value.
I get the following error, indicating that CF can't figure out the value of
#CurrentReqID# in my second INSERT.
What the heck am I doing wrong?
Error Diagnostic Information
An error occurred while evaluating the expression:
#CurrentReqID#
Error near line 16, column 10.
Error resolving parameter CURRENTREQID
ColdFusion was unable to determine the value of the parameter. This problem
is very likely due to the fact that either:
1.. You have misspelled the parameter name, or
2.. You have not specified a QUERY attribute for a CFOUTPUT, CFMAIL, or
CFTABLE tag.
The error occurred while processing an element with a general identifier of
(#CurrentReqID#), occupying document position (16:9) to (16:22).
-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org