Another way might be with a <cfset... between your SELECT query and your 2nd
INSERT query like this:

<cfset var.CurrentReqID = #qGetReqID.CurrentReqID#>

Then in your INSERT query insert the value: #var.CurrentReqID#

============================================
Gary L. Alford
Supplier Product Assurance
Bell Helicopter Textron
Phone: (817) 280-6233
Fax: (817) 278-6233
mailto:[EMAIL PROTECTED]
============================================


-----Original Message-----
From: Bruce Sorge [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 10, 2001 10:31 PM
To: [EMAIL PROTECTED]
Subject: Re: Insert Query


Try putting the query name in your where statement like this:

<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 (#qGetReqID.CurrentReqID#, 99002);
> </cfquery>

----- Original Message -----
From: "Michael Bean" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 10, 2001 10:19 PM
Subject: Insert Query


> 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
>



-------------------------------------------------------------------------
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

-------------------------------------------------------------------------
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

Reply via email to