On 7/11/06, Martin J. Evans <martin.evans@easysoft.com> 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 <jonathan.leffler@gmail.com> #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."
Thread Previous
|
Thread Next