----- Original Message -----
From: "Joseph Thompson" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, November 15, 2000 11:54 AM
Subject: Re: Autonumbers, inserts and queries
> this is something I have used in the past
>
> <cfquery datasource="u8ntcn0">
> Insert into events(EventName)
> Values('testing')
> </cfquery>
>
>
> <cfquery datasource="u8ntcn0" name="test">
> select @@identity as ID_num
> </cfquery>
>
>
> <cfoutput query="test">
> #ID_num#
> </cfoutput>
How safe is this? I believe it's already been established that in a busy
environemt, using the following in Access is not gauranteed to retrieve the
most recently inserted record id:
<cftransaction>
<cfquery datasource="#mydsn#">
INSERT INTO mytable (field1, field2)
VALUES ('#blah1#', '#blah2#')
</cfquery>
<cfquery name="last" datasource="#mydsn#">
SELECT Max(mytableid) AS id
FROM mytable
</cfquery>
</cftransaction>
Now someone is suggesting running the query for @@identity without
designating a table? This may be the way Access does things, but what
assurance do you have that it's even going to return an ID from the table
you want?
Another question I've had, concerning the CFTRANSACTION-enclosed queries...
If this doesn't work in Access, it suggests that CFTRANSACTION may have no
affect when working with Acess databases. Anyone know whether this is true
or not?
Jim
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]