|
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 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/ |
- [cfaussie] Re: Identifying the record you have just creat... Ben Smith
- [cfaussie] RE: Identifying the record you have just ... KNOTT, Brian
- [cfaussie] Re: Identifying the record you have just ... Patrick Branley
- [cfaussie] Re: Identifying the record you have just ... Tom MacKean
- [cfaussie] RE: Identifying the record you have just ... TRACEY, Darren
- [cfaussie] RE: Identifying the record you have just ... James Macpherson
- [cfaussie] Re: Identifying the record you have just ... Barry Beattie
- [cfaussie] RE: Identifying the record you have just ... Patrick Branley
- [cfaussie] RE: Identifying the record you have just ... Tom MacKean
- [cfaussie] RE: Identifying the record you have just ... Chris Dawes
- [cfaussie] RE: Identifying the record you have just ... TRACEY, Darren
- [cfaussie] RE: Identifying the record you have just ... Tom MacKean
