update a column in input file by taking value from Database in perl.
- by Rahul Singh
input file:
1,a,USA,,
2,b,UK,,
3,c,USA,,
i want to update the 4th column in the input file from taking values from one of the table.
my code looks like this:
my $customer_dbh = DBI-connect("DBI:Oracle:$INST", $USER, $PASS ) or die "Couldn't
connect to datbase $INST";
my $cust_smh;
print "connected \n ";
open FILE , "+$input_file" or die "can't open the input file";
print "echo \n";
while(my $line=)
{
my @line_a=split(/\,/,$line);
my $customer_id=$line_a[3];
print "$customer_id\n";
$cust_smh = $customer_dbh-prepare("SELECT phone_no from book where number = $line_a[0]");
$cust_smh-execute() or die "Couldn't execute stmt, error : $DBI::errstr";
my $number = $cust_smh-fetchrow_array();
$line_a[3]=$number;
}