1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
my $dbh = DBI->connect("dbi:Informix:$db\@$server", "$user", "$pw");
$dbh->{ix_WithoutReplication} = 1;
$dbh->{AutoCommit} = 0;
$sth = $dbh->prepare('BEGIN WORK') or die $DBI::errstr."\n";
$sth->execute();
undef $sth;
open(loadfile,"<data.unl");
foreach $line (<loadfile>)
{
chomp();
@all_cols = split(/\\|/,$line);
if (! defined $sth) # is executed only one time
{
$sth = $dbh->prepare_cached("INSERT INTO mytable VALUES(?,?,?,?,?)") or die "Error: ".$DBI::errstr."\n";
}
$sth->execute(@all_cols) or die "Error: \"".$DBI::errstr."\"\n";
$x++;
}
$sth = $dbh->prepare('COMMIT WORK') or die "Error: ".$DBI::errstr."\n";
$sth->execute();