473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

AutoCommit

imf...@yahoo.com Dec 24, 5:47 am show options

Newsgroups: comp.lang.perl.modules
From: imf...@yahoo.com - Find messages by this author
Date: 24 Dec 2004 05:47:04 -0800
Local: Fri, Dec 24 2004 5:47 am
Subject: AutoCommit
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I am writting an application in MS Access/VBA. I have an event that
will enter information into (so far) two tables via dynamic SQL
scripts:
1. INSERT info. into table A
2. INSERT info. into table B
But, I want to somehow turn an AutoCommit off and Commit when I want it
to commit.
Whereas if the INSERT into table B fails for some add reason. I just
want to exit the event and not have the INSERT into table A already
commited. I want to commit it when all INSERTS have done their job.
Thanks...

Nov 13 '05 #1
2 6462
Steven wrote:
imf...@yahoo.com Dec 24, 5:47 am show options

Newsgroups: comp.lang.perl.modules
From: imf...@yahoo.com - Find messages by this author
Date: 24 Dec 2004 05:47:04 -0800
Local: Fri, Dec 24 2004 5:47 am
Subject: AutoCommit
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I am writting an application in MS Access/VBA. I have an event that
will enter information into (so far) two tables via dynamic SQL
scripts:
1. INSERT info. into table A
2. INSERT info. into table B
But, I want to somehow turn an AutoCommit off and Commit when I want
it to commit.
Whereas if the INSERT into table B fails for some add reason. I just
want to exit the event and not have the INSERT into table A already
commited. I want to commit it when all INSERTS have done their job.
Thanks...


You need to use a transaction. Here is a sample from the Access 97 help file.

Sub BeginTransX()

Dim strName As String
Dim strMessage As String
Dim wrkDefault As Workspace
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset

' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees")

' Start of outer transaction.
wrkDefault.BeginTrans
' Start of main transaction.
wrkDefault.BeginTrans

With rstEmployees

' Loop through recordset and ask user if she wants to
' change the title for a specified employee.
Do Until .EOF
If !Title = "Sales Representative" Then
strName = !LastName & ", " & !FirstName
strMessage = "Employee: " & strName & vbCr & _
"Change title to Account Executive?"

' Change the title for the specified employee.
If MsgBox(strMessage, vbYesNo) = vbYes Then
.Edit

!Title = "Account Executive"
.Update
End If
End If

.MoveNext
Loop

' Ask if the user wants to commit to all the changes
' made above.
If MsgBox("Save all changes?", vbYesNo) = vbYes Then
wrkDefault.CommitTrans
Else
wrkDefault.Rollback
End If

' Print current data in recordset.
.MoveFirst
Do While Not .EOF
Debug.Print !LastName & ", " & !FirstName & _

" - " & !Title
.MoveNext
Loop

' Roll back any changes made by the user since this is
' a demonstration.
wrkDefault.Rollback
.Close
End With

dbsNorthwind.Close

End Sub
Nov 13 '05 #2
Steven wrote:
But, I want to somehow turn an AutoCommit off and Commit when I want it
to commit.


Use a transaction. It is a method of the Workspace object.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marcus | last post by:
Hello, I have 2 questions regarding InnoDB tables: 1. In the MySQL manual, it states that "MySQL begins each client connection with autocommit mode enabled by default. When autocommit is...
0
by: jy2003 | last post by:
Below is what I got by using MySQL's --log startup option. The original Java(with JDBC driver) program that creates the queries at runtime was coded by other people, and unfortunately, they are not...
0
by: Scott Mills | last post by:
Hi all, I've got MySQL 4.1.3 installed on RH 7.3... everything's fine so far except for getting the init_connect string to work. I followed the instructions on...
1
by: Lynn.Tilby | last post by:
Hi, Please see the history below... Does AUTOCOMMIT as used here functionally replace VACUUM ANALYZE? If I turn on AUTOCOMMIT is every transaction commited as it is executed? If this is...
4
by: Christian Traber | last post by:
Hi, thanks for the new great version! Only one small problem, how can I disable autocommit in Postgres 7.4 in libpgtcl and psql? I found something about .psqlrc but how is the syntax and how...
1
by: Carmen Gloria Sepulveda Dedes | last post by:
Hola. He instalado postgres 7.4, y vi que ya no es posible hacer un "alter database ... set autocommit = off" Leyendo la documentacion de 7.4, encontre lo siguiente: Note: The...
0
by: Carmen Gloria Sepulveda Dedes | last post by:
Hello. I have installed postgres 7.4, and I see that it's not possible to do "alter database ... set autocommit = off" In the documentation, I found: Note: The autocommit-on mode is...
1
by: Matt Van Mater | last post by:
I'm looking to get a little more performance out of my database, and saw in the docs a section about disabling autocommit by using the BEGIN and COMMIT keywords. My problem is this: I enforce...
33
by: John Sidney-Woollett | last post by:
With the advent of postgres v8, would it be possible to change the default behaviour of psql from AUTOCOMMIT=ON to AUTOCOMMIT=OFF ? Although this might break backward compatibility, it might be...
2
by: Jia Lu | last post by:
Hi all. I use cx_Oracle to connect to an Oracle9i DB. And I want to turn on AUTOCOMMIT function. I see that cur.execute("SET AUTOCOMMIT ON") cannot work. Is there any method to do that ?? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.