I think your concept of how cftransaction works is faulty. The way this is set up it is not keeping 2 Select max(acctno) happening prior to inserting a new record.
Adam H On Mon, 7 Mar 2005 23:00:02 -0500, Tony Weeg <[EMAIL PROTECTED]> wrote: > hi there... > > i have this section of code... that is enrobed in a cftransaction block > that somehow today, was caught in a race condition... meaning... > > i have two records with the same acctNo, and there should only > be one! > > my first thought, now that i look over the code... would it be better > for me to use the request scope for the setting of the newAcctNo? > > help... thanks! > > tony > > <cftransaction> > > <cfquery name="getNewAcctNo" datasource="webCollect"> > select max(acctNo) as thisAccountNumber from accts > </cfquery> > > <!--- sets the new acct number, which is simply, highest current one, > plus one. ---> > <!--- this is different than the identity id field... so that i can > move it to something > else someday :) ---> > <cfset newAcctNo = getNewAcctNo.thisAccountNumber + 1> > > <!--- this query adds the new account information. ---> > <cfquery name="addAccount" datasource="webCollect"> > insert into accts > (acctNo, clientNumber, debtorNumber, dateIncurred, > dateAssigned, > dateLastPayment, amountLastPayment, attyFee_actual, principal, > preJudgementInt, countyId, balance, attyFeeClaimed, csrId) > values > (#newAcctNo#,#form.clientNumber#,#form.debtorNumber#,'#form.dateIncurred#','#form.dateAssigned#','#form.dateLastPayment#',#form.amountLastPayment#,#request.attyFee_actual#,#form.principal#,#form.preJudgementInt#,#countyId#,#form.principal#, > #form.attyFeeClaimed#, #form.csrId#) > </cfquery> > > <!--- i commit it at this point, so that any future requests will not > take my new number, and frankly > im done with it... another request would be valid at this point, and > they could get at it... ---> > <cftransaction action = "commit"/> > > <!--- i then use this to get the new identity value ---> > <cfquery name="getNewId" datasource="webCollect"> > select @@identity as newAcctId from accts > </cfquery> > <!--- and finally get the acct number to validate that it was in fact > a good transaction ---> > <cfquery name="getNewAccountNumber" datasource="webCollect"> > select acctNo from accts where id = #getNewId.newAcctId# > </cfquery> > > </cftransaction> > > -- > tony > > Tony Weeg > > macromedia certified coldfusion mx developer > email: tonyweeg [at] gmail [dot] com > blog: http://www.revolutionwebdesign.com/blog/ > cool tool: http://www.antiwrap.com > > "He who makes a beast of himself saves himself the > pain of being a man..." > > --Hunter S. Thompson. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197808 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

