Friday, March 23, 2012

No Commit at end of program processing on 2005

Hi All,
I have written some ETL software that allows the user to turn off
autocommit and then set the commit frequency. It is C++ talking via
ODBC.
We are testing on an SQL Server 2005 machine and the behavior we are
seeing is that the rows written after the last commit issued by the
program are not being reflected into the database. These are the
error messages...
It seems like 2005 is not performing a commit when the program
terminates successfully. So rows written between the last commit
issued by the program and program close are not showing up in the
database.
This seems strange as 2000 did issue a commit for these message at the
end of processing...that is...if we used autocommit turned off and
committed every say 10,000 rows...the messages that were written
after the last commmit have always been there...same on oracle and
other databases..
Is there a database level option to make a commit happen at the end of
processing? Or perhaps an option for the MSFT SQL Server ODBC driver
to commit when the connection is closed?
Thanks
Peter
www.peternolan.com
Hi Peter
"Peter Nolan" wrote:

> Hi All,
> I have written some ETL software that allows the user to turn off
> autocommit and then set the commit frequency. It is C++ talking via
> ODBC.
> We are testing on an SQL Server 2005 machine and the behavior we are
> seeing is that the rows written after the last commit issued by the
> program are not being reflected into the database. These are the
> error messages...
> It seems like 2005 is not performing a commit when the program
> terminates successfully. So rows written between the last commit
> issued by the program and program close are not showing up in the
> database.
> This seems strange as 2000 did issue a commit for these message at the
> end of processing...that is...if we used autocommit turned off and
> committed every say 10,000 rows...the messages that were written
> after the last commmit have always been there...same on oracle and
> other databases..
> Is there a database level option to make a commit happen at the end of
> processing? Or perhaps an option for the MSFT SQL Server ODBC driver
> to commit when the connection is closed?
> Thanks
> Peter
> www.peternolan.com
>
I am not sure why you are setting autocommit off!! If you have not
explicitly started a transaction or you are using implicit transaction any
data changed after the transaction (implicitly or explicitly) started will be
rolled back. If you allowed autocommit to be on and you did not explicitly
start the transaction then the data changed will be committed.
I don't think this behaviour has changed, but you it is not good practice to
assume that a feature of the driver is going be a shortcut to handling the
transactions properly.
John

No comments:

Post a Comment