From 8c6c84062e8f94eb2257bc3c5be88afa5d732a7c Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Sun, 13 Mar 2016 15:30:46 +0100 Subject: [PATCH] Fix case where a LOB is NULL and ora2pg reports error : DBD::Oracle::db::ora_lob_read: locator is not of type OCILobLocatorPtr LOB initialised with EMPTY_CLOB() are also exported as NULL intead of \\x --- lib/Ora2Pg.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Ora2Pg.pm b/lib/Ora2Pg.pm index 3c4d44bb..3282fd11 100644 --- a/lib/Ora2Pg.pm +++ b/lib/Ora2Pg.pm @@ -10291,7 +10291,7 @@ sub _extract_data # Then foreach row use the returned lob locator to retrieve data # and all column with a LOB data type, extract data by chunk for (my $j = 0; $j <= $#$stt; $j++) { - if ($stt->[$j] =~ /LOB/) { + if (($stt->[$j] =~ /LOB/) && $row[$j]) { my $lob_content = ''; my $offset = 1; # Offsets start at 1, not 0 if ( ($self->{parallel_tables} > 1) || (($self->{oracle_copies} > 1) && $self->{defined_pk}{"\L$table\E"}) ) { @@ -10309,7 +10309,15 @@ sub _extract_data $lob_content .= $lobdata; } } - $row[$j] = $lob_content; + if ($lob_content) { + $row[$j] = $lob_content; + } else { + $row[$j] = undef; + } + } elsif (($stt->[$j] =~ /LOB/) && !$row[$j]) { + # This might handle case where the LOB is NULL and might prevent error: + # DBD::Oracle::db::ora_lob_read: locator is not of type OCILobLocatorPtr + $row[$j] = undef; } } push(@rows, [@row]);