On Wed, Apr 28, 2010 at 5:34 PM, nvc 1 <[email protected]> wrote:
>
> so is this reliable?
>
>
> <cftransaction isolation="serializable">
> <cfquery datasource="#dsn#" name="insertQuery">
> insert into mytable(acolumn) values(1)
> </cfquery>
> <cfquery datasource="#dsn#" name="getid">
> select max(id) as maxid from mytable
> </cfquery>
> </cftransaction>
>
>
It's way simpler!
This is totally transaction safe since you are only interested in the ID
form "one" table not many and are running MS SQL server 2005 or above. On
2000 you can't use output clause.
<cfquery NAME="request.qName" DATASOURCE="#request.dsn#">
INSERT INTO TableName
(Stuff)
OUTPUT inserted.ID, inserted.Stuff
VALUES
(<cfqueryparam cfsqltype="cf_sql_varchar" value="#request.stuff#">)
</cfquery>
<cfdump var="#request.qName#">
As you see, you can output any column you just inserted, and they are
returned in a query
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333204
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm