Execute marks end of transaction?
Execute marks end of transaction?
am 11.07.2006 05:37:59 von vanjiminster
------=_Part_15321_26998829.1152589079488
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Can I end a transaction as soon as I call execute()? or do I have to wait
until I finish fetching all the rows?
For example, I have:
------------------------------------------------------------ ------------------------------------------------------------ ----------------------------------------------
$dbh->do("start transaction");
my $groups_query = $dbh->prepare(qq{select id, name from staff_grp});
$groups_query->execute;
# place1
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?
------=_Part_15321_26998829.1152589079488--
RE: [dbi] Execute marks end of transaction?
am 11.07.2006 12:37:39 von Martin.Evans
On 11-Jul-2006 Jimmy Li wrote:
> Can I end a transaction as soon as I call execute()?
Yes
> 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);
>
> 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.
Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com
Re: [dbi] Execute marks end of transaction?
am 11.07.2006 18:18:53 von jonathan.leffler
------=_Part_25707_28107449.1152634733093
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 7/11/06, Martin J. Evans 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 #include
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."
------=_Part_25707_28107449.1152634733093--
Re: Execute marks end of transaction?
am 11.07.2006 20:33:26 von Martin.Evans
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 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 #include
> Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
> "I don't suffer from insanity - I enjoy every minute of it."