Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^4: DBD::ORacle: Not able to insert into Database

by slayedbylucifer (Scribe)
on Jul 30, 2012 at 08:40 UTC ( #984391=note: print w/replies, xml ) Need Help??

in reply to Re^3: DBD::ORacle: Not able to insert into Database
in thread DBD::ORacle: Not able to insert into Database

mje, here is my code after following your suggestions.

sub upload { my ($csv_file, $table, $col1, $col2, $col3) = ($_[0], $_[1], $ +_[2], $_[3], $_[4]); my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot us +e CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", $csv_file or die " $!"; <$fh>; ### this is to remove the column headers. my $dbh = DBI->connect ("dbi:Oracle:host=<hostname>t;sid=SID;p +ort=1526", 'username', 'password', { RaiseError => 1, AutoCommit => 1, Tr +aceLevel => 0 }) or die "Cannot create Database Handle: + $DBI::errstr()"; my $sth = $dbh->prepare ("INSERT INTO $table ($col1, $col2, $c +ol3) VALUES (?,?,?)"); while ( my $row = $csv->getline ($fh)) { $sth->execute ($row->[0], $row->[1], $row->[2]); } $sth->finish(); $dbh->disconnect(); close $fh; }

Thank you very much for guiding me.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984391]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-09-19 12:57 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (114 votes). Check out past polls.