In search of ParamValues in error handler after a do call fails

In search of ParamValues in error handler after a do call fails

am 27.06.2006 17:37:24 von Martin.Evans

Hi,

I am trying to locate the parameter values passed to a do method call in an
error handler called when the do method fails. I know about ParamValues
attribute but in this case I cannot locate a valid ParamValues array. All the
code uses a single connection handle. The code does:

begin transaction
prepare(select1)
execute(select1)
do(update1)
do(insert1)
do(insert2)
do(update2)
do(update3)
selectrow_array(select 2)
do(update4)
do(update5)

and finally

do (insert3) which fails.

The error handler is called with a db handle and what follows is all I can
currently find out:

msg passed to error handler indicates error on insert3
handle passed to error handler has:
value of DBIx::Log4perl::db=HASH(0x9b22398)
Type => db
Kids => 1
ActiveKids => 0
Statement => insert3 SQL
ChildHandles => 64 handles, 1 of which is non-null
Active => 1
DBI::lasth is DBIx::Log4perl::db=HASH(0x9b229f8)
! $DBI::lasth->{Statement} is select1 and not insert3
DBI::lasth->{Type} = db
The one sth in db's ChildHandles which is not null has:
Statement => select1
ParamValues => :p1 => '1' (which is correct for select1)
Active => undef
Executed => 1

So where are the ParamValues for insert3 - the actual "do" which failed?

Any ideas?

NOTE: I am using DBIx::Log4perl.

Thanks

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com

Re: In search of ParamValues in error handler after a do call fails

am 27.06.2006 22:16:18 von Tim.Bunce

On Tue, Jun 27, 2006 at 04:37:24PM +0100, Martin J. Evans wrote:
> Hi,
>
> I am trying to locate the parameter values passed to a do method call in an
> error handler called when the do method fails.

> The error handler is called with a db handle and what follows is all I can
> currently find out:
>
> msg passed to error handler indicates error on insert3
> handle passed to error handler has:
> value of DBIx::Log4perl::db=HASH(0x9b22398)
> Type => db
> Kids => 1
> ActiveKids => 0
> Statement => insert3 SQL
> ChildHandles => 64 handles, 1 of which is non-null
> Active => 1
> DBI::lasth is DBIx::Log4perl::db=HASH(0x9b229f8)
> ! $DBI::lasth->{Statement} is select1 and not insert3
> DBI::lasth->{Type} = db
> The one sth in db's ChildHandles which is not null has:
> Statement => select1
> ParamValues => :p1 => '1' (which is correct for select1)
> Active => undef
> Executed => 1
>
> So where are the ParamValues for insert3 - the actual "do" which failed?

The statement handle has been destroyed by then.

The subclass probably needs to use the HandleSetErr attribute to
capture the error as it's being recorded by the driver.

Tim.

Re: In search of ParamValues in error handler after a do call fails

am 27.06.2006 22:32:29 von Martin.Evans

Tim Bunce wrote:
> On Tue, Jun 27, 2006 at 04:37:24PM +0100, Martin J. Evans wrote:
>
>>Hi,
>>
>>I am trying to locate the parameter values passed to a do method call in an
>>error handler called when the do method fails.
>
>
>>The error handler is called with a db handle and what follows is all I can
>>currently find out:
>>
>>msg passed to error handler indicates error on insert3
>>handle passed to error handler has:
>> value of DBIx::Log4perl::db=HASH(0x9b22398)
>> Type => db
>> Kids => 1
>> ActiveKids => 0
>> Statement => insert3 SQL
>> ChildHandles => 64 handles, 1 of which is non-null
>> Active => 1
>>DBI::lasth is DBIx::Log4perl::db=HASH(0x9b229f8)
>> ! $DBI::lasth->{Statement} is select1 and not insert3
>>DBI::lasth->{Type} = db
>>The one sth in db's ChildHandles which is not null has:
>> Statement => select1
>> ParamValues => :p1 => '1' (which is correct for select1)
>> Active => undef
>> Executed => 1
>>
>>So where are the ParamValues for insert3 - the actual "do" which failed?
>
>
> The statement handle has been destroyed by then.
>
> The subclass probably needs to use the HandleSetErr attribute to
> capture the error as it's being recorded by the driver.

That makes sense, I'll investigate. Thanks.

Martin