This has been driving me crazy for days.
The below SQL string when printed and pasted into SQL Plus works lovely,
yet fails when attempted to run via PERL.
Oh yeah and it fails quietly, no errors, no warnings.
I tried this:
my $query = <<"SQL"; insert into swma_temp_table (m_serial,m_start,m_end,m_stat,m_product) select '$serialno',to_date('$row->[5]', 'YYYY-MM-DD'),to_date('$row->[ +6]', 'YYYY-MM-DD'),'$row->[17]','$row->[9]' from dual where exists (select NULL from servers where host_serial='$serialno') SQL my $rv = $dbh->do($query) or die "prepare failed: " . $dbh->errstr(); #print $query.";\n -- \n";
I also tried this:
my $query = <<"SQL"; insert into swma_temp_table (m_serial,m_start,m_end,m_stat,m_product) select '$serialno',to_date('$row->[5]', 'YYYY-MM-DD'),to_date('$row->[ +6]', 'YYYY-MM-DD'),'$row->[17]','$row->[9]' from dual where exists (select NULL from servers where host_serial='$serialno') SQL my $stmt = $dbh->prepare($query) or die "prepare failed: " . $dbh->errstr(); $stmt->execute() or die "That serial number is not in our database +: " . $stmt->errstr(); #print $query.";\n -- \n";
if your curious here is my connect statement:
my $dbh = DBI->connect("dbi:Oracle:host=superdb;sid=ora46t;port=1522", + 'nunya','beezwax') or die ("connect failed: " . $DBI::errstr. "\n"); $dbh->{AutoCommit} = 1; $dbh->{PrintError} = 1; $dbh->{RaiseError} = 0; $dbh->{ora_check_sql} = 1; $dbh->{RowCacheSize} = 16;
The variables in the above query get populated from a CSV file.
Here is some sample output when I enable the print command:
insert into swma_temp_table (m_serial,m_start,m_end,m_stat,m_product) select '10-1D48H',to_date('2009-09-21', 'YYYY-MM-DD'),to_date('2011-07 +-31', 'YYYY-MM-DD'),'Active','694275P' from dual where exists (select NULL from servers where host_serial='10-1D48H') ; -- insert into swma_temp_table (m_serial,m_start,m_end,m_stat,m_product) select '10-2D65H',to_date('2008-04-25', 'YYYY-MM-DD'),to_date('2011-07 +-31', 'YYYY-MM-DD'),'Active','694273H' from dual where exists (select NULL from servers where host_serial='10-2D65H') ; -- insert into swma_temp_table (m_serial,m_start,m_end,m_stat,m_product) select '10-2D65H',to_date('2008-04-25', 'YYYY-MM-DD'),to_date('2011-07 +-31', 'YYYY-MM-DD'),'Active','694275O' from dual where exists (select NULL from servers where host_serial='10-2D65H') ;
In reply to Oracle Insert with DBI by simply seth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |