[Dbix-class] Re: Catching DBI errors, without eval?

Christopher H. Laco claco at chrislaco.com
Mon Nov 13 00:25:58 GMT 2006


Josef Karthauser wrote:
> On Sun, Nov 12, 2006 at 05:47:49PM -0500, Len Jaffe wrote:
>> At the DBI level, you use the RaiseError option at connect time to deter=
mine
>> whether DBI should raise
>> an exception.  It has a sister option PrintError, which determines wheth=
er
>> the error message ($DBI::errstr)
>> is printed to SDTERR.
>>
> =

> Ok, I'm now connecting to the database as follows:
> =

>         my $schema =3D __PACKAGE__->connect($DSN, $username, $password,
>             { PrintError =3D> 0, RaiseError =3D> 0 } );
> =

> However I'm still getting errored out when I try and delete this row:
> =

>     DBIx::Class::Relationship::CascadeActions::delete(): Error executing
>     'DELETE FROM contact WHERE ( contactid =3D ? AND owner =3D ? )': Cann=
ot
>     delete or update a parent row: a foreign key constraint fails at
>     test3.pl line 21
> =

> I've added cascade_delete =3D> 0 to all the has_many() declarations.
> Shouldn't that switch this off?
> =

> Joe

It should, but to be honest, I've never had good luck with those two
flags. Somewhere along the line, it gets lost in DBI and only some
strange incantations of local have ever fixed it for me.

What version of DBI are you using?

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061112/0f=
a77acd/signature.pgp


More information about the Dbix-class mailing list