Accessing Pervasive.SQL With Perl

Page Last Modified:

Home Links ODBC (DBI) Contact

DBI + ODBC - Fetching Examples 1 - simple example

A simple fetching example:

use strict;
use warnings;
use DBI;

my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '');
my $stHandle = $dbHandle->prepare('SELECT Name,Description FROM Course ORDER By Name');

my $ret = $stHandle->execute();

while(my @returnRow = $stHandle->fetchrow_array())
print "Name: $returnRow[0], description: $retnRow[1]\n";


None of the method calls are being properly checked for errors (the database handle's PrintError attribute should be set to 1, so warnings will get printed), which is rarely a good thing, so the next code sample includes some error handling.

Home Links ODBC (DBI) Contact

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