Or you can do it in CF like this:
<cfquery name="sel_data" datasource="sys_db" dbtype="ODBC">
SET NOCOUNT ON
INSERT INTO TAUX_001 (DSC_CHKLST , IND_STATUS)
VALUES ('OBS' , 20)
SELECT @@IDENTITY AS COD_REQ
SET NOCOUNT OFF
</cfquery>
<cfset New_COD_REQ = "#sel_data.COD_REQ#">
Marianne Daye
Programmer/Analyst
Information Delivery Systems (IDS)
http://ids.rti.org
-----Original Message-----
From: Allan Pichler [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 11, 2002 8:40 AM
To: CF-Talk
Subject: RE: SQL Help
or you can add a trigger to the sql server that runs on insert
statements to
that table
SELECT @@IDENTITY as newID
@llan
-----Original Message-----
From: Stuart Miller [mailto:[EMAIL PROTECTED]]
Sent: 11. januar 2002 14:32
To: CF-Talk
Subject: RE: SQL Help
Your query will run in Query Analyzer because analyzer uses transact
sql.
If you're interested in getting the primary key of a record you have
just
inserted in your CF application, I use <cftransaction>. Like this:
<cftransaction>
<cfquery name="insert_data" datasource="sys_db" dbtype="ODBC">
INSERT INTO TAUX_001
(DSC_CHKLST , IND_STATUS)
VALUES
('OBS' , 20)
</cfquery>
<cfquery name="sel_data" datasource="sys_db" dbtype="ODBC">
SELECT MAX(COD_REQ) AS ThePrimaryKey
FROM TAUX_001
</cfquery>
</cftransaction>
-----Original Message-----
From: Waldemiro Junior [mailto:[EMAIL PROTECTED]]
Sent: 11 January 2002 11:27
To: CF-Talk
Subject: SQL Help
Hi again folks...
How can I output a variable that was set within a CFQUERY containing
first a insert statement, then a select statement?
This is my query:
<cfquery name="sel_data" datasource="sys_db" dbtype="ODBC">
INSERT INTO TAUX_001
(DSC_CHKLST , IND_STATUS)
VALUES
('OBS' , 20)
SELECT @@IDENTITY AS 'COD_REQ'
</cfquery>
When I try to output COD_REQ, Coldfusion returns an error, but when
using the Query Analyzer it works fine...
Best regards,
Waldemiro Junior
ADDTechnologies Web Developer
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists