If I interpreted the POD right the code below should work, but it doesn't. The Oracle source table contains 14 rows of which 2 with field dataareaid = 'lil' and 2 with field dataareaid = 'bol'. The PostgreSQL target table has a insert trigger that raises an exception for inserted records where dataareaid is either 'lil' (exception message contains the string 'foutje') or 'bol' (exception message contains the string 'nog een foutje'). So I would expect the code to print each message twice. Instead one of the messages is printed 4 times. So what am I doing wrong?
I replaced $sel->fetchrow_arrayref by my $ary_ref = $sel->fetchrow_arrayref; return $ary_ref; That way I could test in my debugger whether all source records get processed, and they do. If I uncomment #print "my method: ".$dbh_pg->errstr."\n" if $dbh_pg- >err; I get the expected 2 + 2 exception messages. So I do have a workaround but it seems to me the code from the POD should work too. Thanks for any help #!/usr/bin/perl use DBI; $query = "SELECT * FROM AddressFormatHeading WHERE dataareaid = 'lil'"; $target = 'INSERT INTO afh_test (addrformat, name, dataareaid, recid) VALUES (?,?,?,?)'; my $dbh_ora = DBI- >connect('dbi:Oracle:database=bmssa;host=firev120-1.indicator.be;sid=mars', 'bmssa', '********') or die "Couldn't connect to database: " . DBI->errstr; my $dbh_pg = DBI- >connect('dbi:PgPP:dbname=defrevdev;host=10.100.1.21;port=2345', 'defrevsys', '********', {PrintError => 0}) or die "Couldn't connect to database: " . DBI->errstr; my $sel = $dbh_ora->prepare($query) or die "Couldn't prepare statement: " . $dbh_ora->errstr; $sel->execute; my $ins = $dbh_pg->prepare($target) or die "Couldn't prepare statement: " . $dbh_pg->errstr; my $fetch_tuple_sub = sub { my $ary_ref = $sel->fetchrow_arrayref; #print "my method: ".$dbh_pg->errstr."\n" if $dbh_pg->err; return $ary_ref; #$sel->fetchrow_arrayref }; my @tuple_status; my $rc = $ins->execute_for_fetch($fetch_tuple_sub, [EMAIL PROTECTED]); if ($dbh_pg->err) { print $dbh_pg->errstr."\n"; my @errors = grep { ref $_ } @tuple_status; foreach my $error (@errors) { print $error->[1]; } } $dbh_ora->disconnect; $dbh_pg->disconnect;