Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
i have two questions regarding the above pseudocode:eval { #table A foreach line (...) { prepare, execute, commit } #table B prepare, execute, commit } if ( $@ ) { rollback; }
1) after loading 1552 rows into table A, sqlserver generates a "String or binary data would be truncated" error. The code jumps out of the eval block and hits the rollback statement. the end result is that table A has 1552 rows and table B has 0 rows. Shouldn't table A be rolled back to 0? this leads me to question #2
2) Should the pseudocode look more like below:
iow, should i be committing after each execute or after performing all executes? The latter seems like it would be alot more efficient, but is it possible?eval { #table A foreach line (...) { prepare, execute } #table B prepare, execute } if ( $@ ) { rollback } else { commit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI and transactions
by hiseldl (Priest) on Jul 10, 2002 at 18:33 UTC | |
|
Re: DBI and transactions
by perrin (Chancellor) on Jul 10, 2002 at 18:24 UTC | |
|
Re: DBI and transactions
by mpeppler (Vicar) on Jul 10, 2002 at 19:35 UTC | |
|
Re: DBI and transactions
by zaimoni (Beadle) on Jul 10, 2002 at 22:39 UTC |