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 :-).