Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
kt03 #1
rollback or commit?
I have the index.cfm page that contain the delete and insert statement. Every
time I run this page, It's delete all the old records and insert the new
records in to the database. My code is working fine, howver, I just noticed
that what happend if my insert statement is faild and the delete stament is
work then I lost all the records. Is there the way to do the rollback or
commit the records back again?
thanks
==============
<cfquery name="getlog" datasource="#db#">
select u_user, aff
from log
where u_user <> ''
</cfquery>
<cfoutput>
<cfquery name="del" datasource="#db#">
delete from test
</cfquery>
<cfloop query="getlog">
<cfquery name="insert" datasource="#db#">
insert into test(u_user, aff)
values('#u_user#', '#aff#')
</cfquery>
</cfloop>
</cfoutput>
kt03 Guest
-
database commit
When is a database insert committed? Immediately or is it committed at the end of a transaction, and if so, what are transaction end points? Terry... -
Commit ... Rollback in Access
Hi All I know I keep going on about this, but could somebody post the routine to do commit .. rollback ASP transactions with an Access DB. I... -
Commit on closing connection?
Hi there, using a Java program on OS390 and DB2 version 7, we have the following problem: After creating a connection using... -
Commit Control
My company is porting some software that we have running on Oracle and DB2 to SQL Server. For our big batch programs(Microfocus COBOL) we have a... -
Commit inner transaction rollback outer
If you nest transaction you are stuck with this, but have you considered using savepoints (SAVE TRANSACTION)? Kresimir Radosevic,SQL MVP ... -
Kronin555 #2
Re: rollback or commit?
Wrap your queries in a <cftransaction>
<cftransaction>
<cfquery name="del" datasource="#db#">
delete from test
</cfquery>
<cfloop query="getlog">
<cfquery name="insert" datasource="#db#">
insert into test(u_user, aff)
values('#u_user#', '#aff#')
</cfquery>
</cfloop>
</cftransaction>
[url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-c15.htm#wp1104164[/url]
Kronin555 Guest
-
kt03 #3
Re: rollback or commit?
But how do you do the rollback? what happend if your insert staement fis failed?
kt03 Guest
-
Kronin555 #4
Re: rollback or commit?
In CFMX 6.1, if an error is thrown inside a <cftransaction> block, the
transaction is rolled back.
If the end of the <cftransaction> block is reached without an error being
thrown, the transaction is committed.
Note that your database has to support transactions for this tag to work
correctly.
Read here:
[url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/[/url]
wwhelp.htm?context=ColdFusion_Documentation&file=p art_cfm.htm
"If you do not specify a value for the action attribute, automatic transaction
processing proceeds as follows:
* If the cfquery operations within the transaction block complete without
an error, the transaction is committed.
* If a cfquery tag generates an error within a cftransaction block, all
cfquery operations in the transaction roll back."
Also, if this is homework, I suggest you take the erroneous <cfoutput> out, as
it's a total giveaway that the code is copied.
Kronin555 Guest
-
-
Kronin555 #6
Re: rollback or commit?
You need Flash installed to view the online CF7 documentation.
Kronin555 Guest
-
kt03 #7
Re: rollback or commit?
I was able to view the document at this url:
[url]http://jsc-web-dev7.jsc.nasa.gov/cfdocs/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm[/url]
kt03 Guest



Reply With Quote

