Tim Bunce wrote:
On the occasion of the 1st anniversary - where did the time go?
> When a batch is first executed the statement handle appears exactly
> as if the batch only contained the first sub-statement.
> The only exception is that the $sth->{NUM_OF_PARAMS} attribute
> equals the total number of placeholders in the entire statement.
>
> The $sth->more_results method is used to move to the results of the
> next sub-statement in the batch. If more_results() returns true then
> the statement handle appears exactly as if the batch only contained
> the next sub-statement. And so on. The $sth->more_results() method
> I<appears> to have the effect of preparing and executing the next
> sub-statement within the batch.
That means, more_results() updates the $sth?
If the batch contains multiple SELECT's and the number of
fields differ, then we need to change NUM_OF_FIELDS. But
that's not allowed:
if (DBIc_NUM_FIELDS(imp_sth) > 0) /* don't change NUM_FIELDS! */
croak("NUM_OF_FIELDS already set to %d", DBIc_NUM_FIELDS(imp_sth));
> sub more_results {
> my ($sth) = @_;
> my $statements = $sth->{statements}
> or return undef; # doesn't have multiple statements
> next_results:
> my $Statement = shift @$statements
> or return undef; # no more statements left
> $sth->prepare($Statement)
-------------
What a $sth->prepare? Do you mean $sth->{Database}->SUPER::prepare?
(But, in this case, we have a new $sth!)
> or return 0; # prepare failure
> my @params = splice @{ $sth->{parameters} }, 0, $sth->{NUM_OF_PARAMS};
> my $rv = $sth->execute(@params)
-------------
Do you mean $sth->SUPER::execute?
Steffen