in reply to Re: DBI Error Trapping
in thread DBI Error Trapping

I've changed it to:
$db3->{RaiseError}=0; unless ($sth_minus = $db3->prepare_cached(" SELECT $column_list FROM $ +database_user_1.$table_names_r->[0]".'@'."$config{database_dblink_1} MINUS SELECT $column_list FROM $ +database_user_2.$table_names_r->[0]".'@'."$config{database_dblink_2} ")) {warn $@ if $@;}
but the program still dies. Any suggestions?

Replies are listed 'Best First'.
Re: Re: Re: DBI Error Trapping
by htoug (Deacon) on Dec 19, 2001 at 12:15 UTC
    Try something like:
    { local $db3->{RaiseError}=0; $sth_minus = $db3->prepare_cached(" SELECT $column_list FROM $database_user_1.$table_names_r->[0]". +'@'."$config{database_dblink_1} MINUS SELECT $column_list FROM $database_user_2.$table_names_r->[0]". +'@'."$config{database_dblink_2} "); warn "prepare fails with $db3->errstr" if $db3->err; }
    The errorcode is returned in $db3->err and the string in $db3->errstr not in $@.

    Localising $db3->{RaiseError} is a way of locally setting the RaiseError attribute without having to rembember the state (probably not needed here, but it is a useful idiom :-).

Re: Re: Re: DBI Error Trapping
by runrig (Abbot) on Dec 19, 2001 at 23:14 UTC
    The error string will be in $@ if you set RaiseError to 1 AND eval the prepare statement. Or do what htoug suggests above. Sorry if I was unclear :)