#!/usr/bin/perl -w use strict; use Text::CSV; use DBI; my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", "test.csv" or die " $!"; <$fh>; ### this is to remove the column headers. my $dbh = DBI->connect ("dbi:Oracle:host=;sid=;port=1526", 'username', 'password', { RaiseError => 1, AutoCommit => 1, TraceLevel => 0 }) or die "Cannot create Database Handle: $DBI::errstr()"; while ( my $row = $csv->getline ($fh)) { my $col1 = $dbh->quote ("$row->[0]"); my $col2 = $dbh->quote ("$row->[1]"); my $col3 = $dbh->quote ("$row->[2]"); $dbh->do ("INSERT INTO CLUSTER_MAPPING (VM, FARM, DMZ) VALUES ($col1, $col2, $col3)"); } $dbh->disconnect(); close $fh;