Accessing Pervasive.SQL With Perl

Page Last Modified:

Home Links ODBC (DBI) Contact

DBI + ODBC - Insert Example

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";
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 - 2018