2011-08-25

Slitaz -- Oracle XE 10g - perl


1.
oracle@slitaz:~$ perl oraxe-query.pl
Beijing
Bern
Bombay
Geneva
Hiroshima
London
Mexico City
Munich
Oxford
Roma
Sao Paulo
Seattle
Singapore
South Brunswick
South San Francisco
Southlake
Stretford
Sydney
Tokyo
Toronto
Utrecht
Venice
Whitehorse

2.
oracle@slitaz:~$ cat oraxe-query.pl
#!/usr/bin/perl

use DBI;
use strict;
use vars qw($dbh $sth);

# get a database handle
$dbh = DBI->connect('dbi:Oracle:', 'hr@localhost/XE', 'oracle');

# get a statement handle
$sth=$dbh->prepare('SELECT city FROM locations');

# execute the statement handle
$sth->execute();

# loop through the results
while (my ($r_city) = $sth->fetchrow())
{
print " $r_city \n";
}

$sth->finish();
$dbh->disconnect();
oracle@slitaz:~$

3.
Extract from

An Introduction to DBD::Oracle
[..]
4 Using DBI and DBD::Oracle
4.1 Understanding DBI

Since its inception by Tim Bunce in 1994, DBI (DataBase Interface) has been the de facto standard for interfacing databases with the Perl language. Thanks to the designers' foresight, DBI is database-independent, with methods, variables, and conventions that provide a consistent programming interface, no matter what database management system is being used.

As an API, DBI is just an interface to a database driver--in our case, DBD::Oracle--so you can think of DBI as the glue that links the Perl language to a specific database driver, as seen in the diagram below.



DBD::Oracle Diagram

.