I am having trouble creating a large table using perl DBI do and/or prepare execute. The table being created is approximately 2.2B records. When the code is executed the tables is created in my oracle 11.2g database but code dies if do(sql) or die / execute(sql) or die. However, errstr is null if you try to print the error message. If we reduce the number of rows created, the script runs fine.
use strict;
use DBI;
###build connection strings
my $HOST=`hostname`;
my $sid="$ENV{ORACLE_SID}";
my $dbh;
my $ctas_sql = q(create table perl_test_tb as select a.lvl
from
(select level lvl from dual connect by level <= 100000
+00) a
,(select level lvl from dual connect by level <= 220)
+b
);
connect_to_db();
sub connect_to_db {
my $errormessage;
# get the base filename for this script
my $user = 'fdsglobal';
my $pass = 'snafu';
# Just connect to the db.
my $connection = qq(dbi:Oracle:host=$HOST;sid=$sid);
$dbh = DBI->connect("$connection", "$user", "$pass",
{PrintError => 0,
PrintWarn => 0,
LongReadLen => 2000000100 # add 100 to the longest possible long,
+ as per DBI man page
})
or die "Could Not Connect To Database: ". $DBI::errstr;
}
my $rows = $dbh->do($ctas_sql) or die "Cannot run code: $ctas_sql \n".
+ $dbh->errstr ."\n\n";
my $ctas_error = $dbh->errstr;
print "perl test table created with $rows rows\n";