Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ADO: do I need to explicitly run a "commit" statement during or after a transaction?

Posted on 2009-07-10
1
Medium Priority
?
339 Views
Last Modified: 2013-12-19
Hi Experts:

    In a piece of Python code using ADO, I execute a sql statement execution command inside a transaction for 500000 times like the following code. Theoretically I guess the changes will  be saved after the transaction without explicitly running con.Execute("commit") during or after the transaction.

1. Is my guess correct true?
2. Will there be any problem caused by this "LARGE" transaction if I do it this way?

Thank you!


# Python code 1:
# con is an ADO connection object, i is an integer
con.BeginTrans()
i = 0
while (i<500000):
    con.Execute("insert into table_name (field_a, field_b) values (1,2)")
    i = i + 1
con.CommitTrans()

Open in new window

0
Comment
Question by:huangs3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 2000 total points
ID: 24827537
I see you have con.CommitTrans() already. I do not know ADO / Python so well, but if that is what I think it is, there is no need for an explicit "commit". Actually all APIs I know have a Commit() function or overall transaction API, you never have to say "commit"

One large transaction is fine, especially if the operation is supposed to be atomic. It depends on what you want to happen if you get an error (roll back?).

Too many commits will degrade performance, but too large / long running transactions can also use UNDO space if there are other queries running against the dataset that is being changed. I could commit in batches of say 50000, but I would just leave it alone and commit at the end unless you otherwise see some sort of problem.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question