Thursday, October 2, 2008

Installing DBI and Using ORACLE with Perl in Linux

You will learn in this tutorial how to install the DBI (the Perl interface to databases) in RedHat Linux 7.0 and above. There is another version for Windows here. You can obtain a more detailed introduction to DBI by reading its FAQ. You can see below the basic DBI model. The scripts are written in Perl using standard Perl variables, commands and syntax. The DBI has methods and handles which are database software independent. You program to access, change or query a database using the standard SQL language, combined with the DBI methods and handles. You install as many DBD::type modules as you need to support the different database software you may have, but you Perl script will be the same.

You will also see in this tutorial the basics of using DBI to perform queries, and display the results. Once you learn the basics you can use Perl to program the other SQL commands we saw briefly in our class on MySQL, and you should have learned in more details in the DB course. Please note that we have on reserve at the Library the book Programming the Perl DBI, the authoritative reference to DBI.

Hướng dẫn cài DBI và DBD

1. Test máy đã cài DBI chưa
perl -e 'use DBI; print $DBI::VERSION,"\n";'

2. Test máy đã cài DBD chưa
perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'



Install DBINếu cài báo lỗi
cc1: invalid option `tune=pentium4'

Tìm trong file Makefile bỏ dòng này
OPTIMIZE = -O2 -g -pipe -m32 -march=i386 -mtune=pentium4



Install DBD:Oracle

Simply download, gunzip, and untar the DBD module into a temporary directory and make it. Below is a quick guide to installing DBD:


1. Cài xong Test lại DBI

perl -e 'use DBI; print $DBI::VERSION,"\n";'

1. Cài xong Test lại DBD
perl -e 'use DBD::Oracle; print $DBD::Oracle::VERSION,"\n";'

No comments: