1 message in com.mysql.lists.win32Transaction Workaround
FromSent OnAttachments
Zack Jones07 Sep 2000 21:31 
Subject:Transaction Workaround
From:Zack Jones (jone@pacbell.net)
Date:09/07/2000 09:31:08 PM
List:com.mysql.lists.win32

I have recently been revamping an old system that was using an access database
and coldfusion to use Mysql and coldfusion insted for added database flexability and stability.
I managed to convert the DB sucessfully over to mysql and get mostly everything
running. But i''ve hit a roadblock, The problem is i'm using a transaction
function, CFTRANSACTION, in order to add an order to the Database and then get
the orderID that was created (autoincrement) for this order using

SELECT Max(OrderID) AS LastOrder

This is all within transaction tags and looks like this

<CFTRANSACTION> <CFQUERY datasource="#attributes.dsn#"> INSERT INTO Orders (CustomerID, OrderDate, ShipMethodID, ShippingFirstName, ShippingLastName, ShippingAddress, ShippingCity, ShippingState, ShippingPostalCode, ShippingSchoolBusiness, ReferralID)

VALUES (#Form.CustomerID#, #OrderDate#, '#Form.ShipMethodID#', '#Form.ShippingFirstName#', '#Form.ShippingLastName#', '#Form.ShippingAddress#', '#Form.ShippingCity#', '#Form.ShippingState#', '#Form.ShippingPostalCode#', '#Form.ShippingSchoolBusiness#', '#Form.ReferralID#') </CFQUERY>

<cfquery name="getLastOrder" datasource="#attributes.dsn#">

SELECT Max(OrderID) AS LastOrder FROM Orders

</cfquery> <CFSET Form.OrderID = '#getLastOrder.LastOrder#'> </CFTRANSACTION>

This is because i don't want a order placed inbetween the time it inserts the
new order, and gets the last orderID, to make it get the wrong one Now this code has an error since i've switch over to Mysql which doesn't use
transactions. I read

here :
http://www.mysql.com/documentation/mysql/commented/manual.php?section=Missing_Transactions

that it does in fact have support for something that is just as good or better
then transactions but it diddn't realy tell my any, spicific to my case,
information about implaminting this. So if anyone out there is using coldfussion
and MySql and know a way i could work this out please email me!. I should think
that the solution would involve some SQL code but since i'm not realy adept at
advanced Sql code i haven't the faintest idea what it is. I'm running WinME and
ColdFussion 4.51 with Mysql 3.23.23 beta.