Short answer. Yes J

 

My mistake in being verbose. I should have just done ‘insert into ….’

 

Pat

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Macpherson
Sent: Thursday, 29 July 2004 3:08 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Identifying the record you have just created

 

to be pedantic won't

 

    attrib1 == val1

 

in your example?

 

should be

 

<cftransaction>

            <cfquery name=”qryinsert”>

            Insert into myTable (attrib2,attrib3) values (#val2,#val3#)

            </cfquery>

 

            <cfquery name=”qrySelect”>

                        Select max(attrib1) as new ID

From myTable

            </cfquery>

<cftransaction>

           

<cfoutput>#qrySelect.newID#</cfoutput>

 

where attrib1 is an autonumber or whatever access calls em

 

- J

 

 

 

 -----Original Message-----
From: Patrick Branley [mailto:[EMAIL PROTECTED]
Sent: Thursday, 29 July 2004 3:08 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Identifying the record you have just created

Hi Tom

 

There are a number of ways of doing this and some people would probably tell you to use UUID ‘s instead of an incremental number. But that’s another story….

 

In SQLServer  you can do this

 

<cftransaction>

            <cfquery name=”qryinsert”>

            Insert into myTable (attrib1,attrib2,attrib3) values (#val1#,#val2,#val3#)

            Select @@identity as newID

            </cfquery>

<cftransaction>

           

<cfoutput>#qryinsert.newID#</cfoutput>

 

In MSAccess and other db’s….

 

<cftransaction>

            <cfquery name=”qryinsert”>

            Insert into myTable (attrib1,attrib2,attrib3) values (#val1#,#val2,#val3#)

            </cfquery>

 

            <cfquery name=”qrySelect”>

                        Select max(attrib1) as new ID

From myTable

            </cfquery>

<cftransaction>

           

<cfoutput>#qrySelect.newID#</cfoutput>

 

Hope this helps.

 

Pat

 

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom MacKean
Sent: Thursday, 29 July 2004 2:52 PM
To: CFAussie Mailing List
Subject: [cfaussie] Identifying the record you have just created

 

Hi all,

I have a form that passes data to an INSERT INTO action page. That page creates a new record with an incremented ID number (primary key). Is there a way to find out what that ID number is so that it can be used for another query on the same page?

I have a bodgy workaround whereby I set a value in a special field to true, then cflocation to another page that searches for that true value and picks up the ID number from the record. Then I set the record to false once I have the number. There has to be a better way.

TIA,

Tom

NOTICE: Medical and scientific information provided in print and electronically by Sydney IVF might not be relevant to your own circumstances and should always be discussed with your own doctor before you act on it. This communication is confidential and may contain copyright or otherwise protected information of Sydney IVF Limited or a third party. If you are not the intended recipient of this communication please immediately let us know by reply email or telephone us on +61 2 9221 5964, delete the communication and destroy all copies. ---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to