Accessing Pervasive.SQL With Perl

Page Last Modified:

Home Links ODBC (DBI) Contact

use strict;
use warnings;
use DBI;

eval {
print "Connecting to database...\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});

print "Preparing statement 1...\n";
my $stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL01', 'Introduction to Perl', 2, 'Computing')");

print "Running insert 1...\n";
$stHandle->execute();

print "Preparing statement 2...\n";
$stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL02', 'Intermediate Perl', 4, 'Computing')");

print "Running insert 2...\n";
$stHandle->execute();

print "Committing transaction...\n";
$dbHandle->commit();

print "Disconnecting...\n";
$dbHandle->disconnect();

1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

use strict;
use warnings;
use DBI;

eval {
print "Connecting to database...\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});

print "Preparing statement 1...\n";
my $stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL01', 'Introduction to Perl', 2, 'Computing')");

print "Running insert 1...\n";
$stHandle->execute();

print "Preparing statement 2...\n";
$stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL02', 'Intermediate Perl', 4, 'Computing')");

print "Running insert 2...\n";
$stHandle->execute();

print "Committing transaction...\n";
$dbHandle->commit();

print "Disconnecting...\n";
$dbHandle->disconnect();

1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2017

use strict;
use warnings;
use DBI;

eval {
print "Connecting to database...\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});

print "Preparing statement 1...\n";
my $stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL01', 'Introduction to Perl', 2, 'Computing')");

print "Running insert 1...\n";
$stHandle->execute();

print "Preparing statement 2...\n";
$stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL02', 'Intermediate Perl', 4, 'Computing')");

print "Running insert 2...\n";
$stHandle->execute();

print "Committing transaction...\n";
$dbHandle->commit();

print "Disconnecting...\n";
$dbHandle->disconnect();

1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

use strict;
use warnings;
use DBI;

eval {
print "Connecting to database...\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});

print "Preparing statement 1...\n";
my $stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL01', 'Introduction to Perl', 2, 'Computing')");

print "Running insert 1...\n";
$stHandle->execute();

print "Preparing statement 2...\n";
$stHandle = $dbHandle->prepare("INSERT INTO Course (Name, Description, Credit_Hours, Dept_Name) VALUES ('PERL02', 'Intermediate Perl', 4, 'Computing')");

print "Running insert 2...\n";
$stHandle->execute();

print "Committing transaction...\n";
$dbHandle->commit();

print "Disconnecting...\n";
$dbHandle->disconnect();

1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

DBI + ODBC - Transaction Example