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});

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

print "Running insert...\n";
my $ret = $stHandle->execute();
print "$ret row(s) inserted...\n";

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});

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

print "Running insert...\n";
my $ret = $stHandle->execute();
print "$ret row(s) inserted...\n";

print "Disconnecting...\n";
$dbHandle->disconnect();
1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

DBI + ODBC - Insert Example