Home » Open Source » Programming Interfaces » insert the records into table perl (oracle10g)
insert the records into table perl [message #685952] Wed, 04 May 2022 07:45
arun888
Messages: 100
Registered: June 2015
Location: INDIA
Senior Member
I am trying to insert the records into the table and getting the error. I have tried the below way and not sure that is the correct way.


sub copy2 {
    my ($inpfile1, $week, $ret_code, $record_list) = @_;
    open FILE, $inpfile1 or die "Unable to open $inpfile1 : $!";
    open OUT1, ">>/ret/lit/shell2/files.uk.$week.$ret_code.WEEKLY1" or die "Unable to open OUT1 file: $!";
    my $dbh = DBI->connect('dbi:Oracle:bmfpuk', 'usd', 'night', {AutoCommit => 0, RaiseError => 1})
    or die "Unable to connect to Oracle: $!"
    my $sth = $dbh->prepare(qq{ insert into imputed_records (retailer_code, record, week) values (?, ?, ?)});
    while (my $line = <FILE>) {
        chomp $line;
        my ($nae, $recordno, $vol, $val, $price) = split(/\s+/, $line);
        if ( defined $$record_list{$recordno} )
        {
           $sth->execute ($ret_code, $recordno, $week);
           print "the record is $recordno\n";
           printf OUT1 "%013s\t%s\t\t\t%s\t%s\t%s\n", $nae, $recordno, $vol, $val, $price
               or die "Unable to write to OUT1 file : $!";
        }
    }
    close OUT1  or die "Unable to close OUT1 file: $!";
    close FILE  or die "Unable to close $inpfile1: $!";
    $dbh->disconnect;
}


Previous Topic: error in query
Next Topic: perl database access (7 merged)
Goto Forum:
  


Current Time: Sat Dec 21 09:47:00 CST 2024