I've heard Ben Forta say several times that the following way of
determining the just-inserted value of an autonumber field is
unnecessary and unreliable. He said that databases have built-in ways
of returning the value.
So what is the database method, triggers? If so, how can you get at
this information with CF? Can MSAccess (I know it sucks) return such a
value?
Here is the method that Forta advocates against, but he has been vague
about the better alternative:
<cftransaction>
<cfquery name="add" datasource="#dsn#">
INSERT INTO SALES (FIRSTNAME)
VALUES ('temp')
</cfquery>
<cfquery name="max" datasource="#dsn#">
SELECT max (SALEID) as maxid
FROM SALES
</cfquery>
<cfset SALEID=#max.maxid#>
</cftransaction>
Thanks,
Jamie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists