[DB-SIG] MS SQL Server and odbc getting 'None'
Andy Todd
andy47 at halfcooked.com
Tue Aug 17 18:01:21 CEST 2004
Carey David SSgt 109CF/SCBJ wrote:
> Ok, I believe I see. If I'm doing multiple updates/inserts inside a loop,
> is it better to commit inside the loop with each execute, or outside the
> loop and commit just once? I would assume that committing outside the loop
> would be the best.
>
> I hope I made that clear.
>
> Thanks
> Dave
>
[snip]
The answer is, of course, it depends. If each of your updates/inserts is
independent then commit within the loop. If they all have to make it to
the database or none do commit after the loop. Essentially you commit
after each 'atomic' piece of work.
People worry about the processing overhead of a commit. It does, after
all, add at least a couple of processor cycles. But unless your
throughput is of the order of many thousands of records a second you are
unlikely to notice the extra effort of a commit after each operation.
Modern relational databases are quite good at this kind of thing after all.
Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
More information about the DB-SIG
mailing list