Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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]
[Corion]: Discipulus: Being out in nature is great, at least as long as you have a dry place to sleep and a warm fire ;)
[Discipulus]: my whishlist include more "elements" anyway

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2017-02-24 09:20 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (353 votes). Check out past polls.