Jonathan, You are of course right.
I read the word transaction but saw the select and missed the do to begin a transaction. My comments were based on a simple select outside a transaction. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com On Tue, 2006-07-11 at 09:18 -0700, Jonathan Leffler wrote: > > > On 7/11/06, Martin J. Evans <[EMAIL PROTECTED]> wrote: > > On 11-Jul-2006 Jimmy Li wrote: > > Can I end a transaction as soon as I call execute()? > > Yes > > Depends on the statement, of course, and the AutoCommit mode. For > something other than a cursor-based statement (fetch, or sometimes > some versions of SQL function calls), that will terminate the > transaction immediately if AutoCommit is on. > > > > or do I have to wait > > until I finish fetching all the rows? > > No > > > For example, I have: > > > > ---------- > > $dbh->do("start transaction"); > > > > my $groups_query = $dbh->prepare(qq{select id, name from > staff_grp}); > > $groups_query->execute; > > > ># place1 > > $groups_query->finish if (want_to_stop_here); > > That finishes the statement (or closes the cursor) - it does not > directly do anything to the transaction. To finish the transaction, > you call $dbh->commit or $dbh->rollback. If AutoCommit is on, then > maybe the transaction is completed on finish. > > > > while (my @one_group = $groups_query->fetchrow_array) > > { > > print @one_group; > > } > > > >#place 2 > > > > ---------- > > > > Can I end the transaction in #place1 or do I have to wait > until #place2? > > See above. > > > -- > Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h> > Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org > "I don't suffer from insanity - I enjoy every minute of it."