วันพฤหัสบดีที่ 20 ธันวาคม พ.ศ. 2555

ติดตั้ง DBD:Oracle กับ oracle-instantclient

หลังจากที่ห่างหายไปนานมาก ...วันนี้จำเป็นต้องเขียน Perl เพื่อติดต่อ Oracle Database แต่ปัญหาคือต้องทำอย่างไรบ้าง ติดตั้งอะไรบ้าง เพราะว่าเครื่องที่เขียน Perl ไม่ได้มี Oracle Software เลย งั้นเริ่มเลยละกัน ...ผมใช้ Oracle Linux 5.7 (X86) เราต้องรู้ว่า OS เราคืออะไร และ ARCH เป็น 32bit หรือ 64bit
1. ดาวน์โหลด oracle-instantclient ... http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
ผมต้องใช้ 3 ตัวด้วยกัน
oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
oracle-instantclient11.2-devel-11.2.0.3.0-1.i386.rpm
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.i386.rpm
จากนั่นมาเริ่มติดตั้งกัน

[root@linuxtest ~]# uname -a
Linux linuxtest 2.6.18-274.el5 #1 SMP Mon Jul 25 13:06:57 EDT 2011 i686 i686 i386 GNU/Linux
[root@linuxtest ~]# ls -al oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
-rw-r--r-- 1 root root 57765315 Dec 20 01:42 oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
[root@linuxtest ~]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@linuxtest ~]# ls /usr/lib/oracle/11.2/client
bin  lib
[root@linuxtest ~]# ls -la /usr/lib/oracle/11.2/client/lib/
total 172132
drwxr-xr-x 2 root root      4096 Dec 20 01:44 .
drwxr-xr-x 4 root root      4096 Dec 20 01:44 ..
-rw-r--r-- 1 root root  43621159 Sep 18  2011 libclntsh.so.11.1
-rw-r--r-- 1 root root   7058839 Sep 18  2011 libnnz11.so
-rw-r--r-- 1 root root   1881900 Sep 18  2011 libocci.so.11.1
-rw-r--r-- 1 root root 118400194 Sep 18  2011 libociei.so
-rw-r--r-- 1 root root    152433 Sep 18  2011 libocijdbc11.so
-rw-r--r-- 1 root root   2095932 Sep 18  2011 ojdbc5.jar
-rw-r--r-- 1 root root   2714189 Sep 18  2011 ojdbc6.jar
-rw-r--r-- 1 root root     66779 Sep 18  2011 xstreams.jar
[root@linuxtest ~]# ln -s /usr/lib/oracle/11.2/client/lib/libclntsh.so.11.1 /usr/lib/oracle/11.2/client/lib/libclntsh.so
[root@linuxtest ~]# ln -s /usr/lib/oracle/11.2/client/lib/libocci.so.11.1 /usr/lib/oracle/11.2/client/lib/libocci.so
[root@linuxtest ~]# ls -la /usr/lib/oracle/11.2/client/lib/
total 172140
drwxr-xr-x 2 root root      4096 Dec 20 01:45 .
drwxr-xr-x 4 root root      4096 Dec 20 01:44 ..
lrwxrwxrwx 1 root root        49 Dec 20 01:45 libclntsh.so -> /usr/lib/oracle/11.2/client/lib/libclntsh.so.11.1
-rw-r--r-- 1 root root  43621159 Sep 18  2011 libclntsh.so.11.1
-rw-r--r-- 1 root root   7058839 Sep 18  2011 libnnz11.so
lrwxrwxrwx 1 root root        47 Dec 20 01:45 libocci.so -> /usr/lib/oracle/11.2/client/lib/libocci.so.11.1
-rw-r--r-- 1 root root   1881900 Sep 18  2011 libocci.so.11.1
-rw-r--r-- 1 root root 118400194 Sep 18  2011 libociei.so
-rw-r--r-- 1 root root    152433 Sep 18  2011 libocijdbc11.so
-rw-r--r-- 1 root root   2095932 Sep 18  2011 ojdbc5.jar
-rw-r--r-- 1 root root   2714189 Sep 18  2011 ojdbc6.jar
-rw-r--r-- 1 root root     66779 Sep 18  2011 xstreams.jar
[root@linuxtest ~]#
[root@linuxtest ~]# vi /etc/profile
[root@linuxtest ~]# tail /etc/profile
tail: cannot open `3' for reading: No such file or directory
==> /etc/profile <==
            . $i >/dev/null 2>&1
        fi
    fi
done
unset i
unset pathmunge
export ORACLE_HOME=/usr/lib/oracle/11.2/client
export TNS_ADMIN=/usr/lib/oracle/11.2/client/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

[root@linuxtest ~]# export ORACLE_HOME=/usr/lib/oracle/11.2/client
[root@linuxtest ~]# export TNS_ADMIN=/usr/lib/oracle/11.2/client/network/admin
[root@linuxtest ~]# export LD_LIBRARY_PATH=$ORACLE_HOME/lib
[root@linuxtest ~]# mkdir -p /usr/lib/oracle/11.2/client/network/admin
[root@linuxtest ~]# chmod 755 -R /usr/lib/oracle/11.2/client/network
[root@linuxtest ~]#
[root@linuxtest ~]# rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@linuxtest ~]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@linuxtest ~]# rpm -qa | grep oracle-instantclient
oracle-instantclient11.2-basic-11.2.0.3.0-1
oracle-instantclient11.2-devel-11.2.0.3.0-1
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
จากนั้นก็ติดตั้ง DBI perl module. เพื่อนๆ สามารถ download ได้ที่ http://www.cpan.org
[root@linuxtest ~]# wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.622_924.tar.gz
--2012-12-20 01:50:56--  http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.622_924.tar.gz
Resolving search.cpan.org... 199.15.176.161
Connecting to search.cpan.org|199.15.176.161|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirror.yourconnect.com/CPAN/authors/id/T/TI/TIMB/DBI-1.622_924.tar.gz [following]
--2012-12-20 01:50:56--  http://mirror.yourconnect.com/CPAN/authors/id/T/TI/TIMB/DBI-1.622_924.tar.gz
Resolving mirror.yourconnect.com... 203.150.8.132
Connecting to mirror.yourconnect.com|203.150.8.132|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 589655 (576K) [application/x-gzip]
Saving to: `DBI-1.622_924.tar.gz'
100%[==============================================================================================================================>] 589,655     1.44M/s   in 0.4s
2012-12-20 01:50:57 (1.44 MB/s) - `DBI-1.622_924.tar.gz' saved [589655/589655]
[root@linuxtest ~]# tar zxvf DBI-1.622_924.tar.gz
DBI-1.622_924/
DBI-1.622_924/Changes
DBI-1.622_924/dbd_xsh.h
DBI-1.622_924/DBI.pm
DBI-1.622_924/DBI.xs
DBI-1.622_924/dbi_sql.h
DBI-1.622_924/dbilogstrip.PL
DBI-1.622_924/dbipport.h
DBI-1.622_924/dbiprof.PL
DBI-1.622_924/dbiproxy.PL
DBI-1.622_924/dbivport.h
DBI-1.622_924/DBIXS.h
DBI-1.622_924/dbixs_rev.h
DBI-1.622_924/dbixs_rev.pl
DBI-1.622_924/Driver.xst
DBI-1.622_924/Driver_xst.h
DBI-1.622_924/ex/
DBI-1.622_924/lib/
DBI-1.622_924/Makefile.PL
DBI-1.622_924/MANIFEST
DBI-1.622_924/META.json
DBI-1.622_924/META.yml
DBI-1.622_924/Perl.xs
DBI-1.622_924/README
DBI-1.622_924/t/
DBI-1.622_924/test.pl
DBI-1.622_924/TODO_2005.txt
DBI-1.622_924/TODO_gofer.txt
DBI-1.622_924/typemap
DBI-1.622_924/t/01basics.t
DBI-1.622_924/t/02dbidrv.t
DBI-1.622_924/t/03handle.t
DBI-1.622_924/t/04mods.t
DBI-1.622_924/t/05concathash.t
DBI-1.622_924/t/06attrs.t
DBI-1.622_924/t/07kids.t
DBI-1.622_924/t/08keeperr.t
DBI-1.622_924/t/09trace.t
DBI-1.622_924/t/10examp.t
DBI-1.622_924/t/11fetch.t
DBI-1.622_924/t/12quote.t
DBI-1.622_924/t/13taint.t
DBI-1.622_924/t/14utf8.t
DBI-1.622_924/t/15array.t
DBI-1.622_924/t/16destroy.t
DBI-1.622_924/t/19fhtrace.t
DBI-1.622_924/t/20meta.t
DBI-1.622_924/t/30subclass.t
DBI-1.622_924/t/31methcache.t
DBI-1.622_924/t/35thrclone.t
DBI-1.622_924/t/40profile.t
DBI-1.622_924/t/41prof_dump.t
DBI-1.622_924/t/42prof_data.t
DBI-1.622_924/t/43prof_env.t
DBI-1.622_924/t/48dbi_dbd_sqlengine.t
DBI-1.622_924/t/49dbd_file.t
DBI-1.622_924/t/50dbm_simple.t
DBI-1.622_924/t/51dbm_file.t
DBI-1.622_924/t/52dbm_complex.t
DBI-1.622_924/t/60preparse.t
DBI-1.622_924/t/65transact.t
DBI-1.622_924/t/70callbacks.t
DBI-1.622_924/t/72childhandles.t
DBI-1.622_924/t/80proxy.t
DBI-1.622_924/t/85gofer.t
DBI-1.622_924/t/86gofer_fail.t
DBI-1.622_924/t/87gofer_cache.t
DBI-1.622_924/t/90sql_type_cast.t
DBI-1.622_924/t/lib.pl
DBI-1.622_924/t/pod-coverage.t
DBI-1.622_924/t/pod.t
DBI-1.622_924/lib/Bundle/
DBI-1.622_924/lib/DBD/
DBI-1.622_924/lib/DBI/
DBI-1.622_924/lib/Win32/
DBI-1.622_924/lib/Win32/DBIODBC.pm
DBI-1.622_924/lib/DBI/Const/
DBI-1.622_924/lib/DBI/DBD/
DBI-1.622_924/lib/DBI/DBD.pm
DBI-1.622_924/lib/DBI/FAQ.pm
DBI-1.622_924/lib/DBI/Gofer/
DBI-1.622_924/lib/DBI/Profile.pm
DBI-1.622_924/lib/DBI/ProfileData.pm
DBI-1.622_924/lib/DBI/ProfileDumper/
DBI-1.622_924/lib/DBI/ProfileDumper.pm
DBI-1.622_924/lib/DBI/ProfileSubs.pm
DBI-1.622_924/lib/DBI/ProxyServer.pm
DBI-1.622_924/lib/DBI/PurePerl.pm
DBI-1.622_924/lib/DBI/SQL/
DBI-1.622_924/lib/DBI/Util/
DBI-1.622_924/lib/DBI/W32ODBC.pm
DBI-1.622_924/lib/DBI/Util/_accessor.pm
DBI-1.622_924/lib/DBI/Util/CacheMemory.pm
DBI-1.622_924/lib/DBI/SQL/Nano.pm
DBI-1.622_924/lib/DBI/ProfileDumper/Apache.pm
DBI-1.622_924/lib/DBI/Gofer/Execute.pm
DBI-1.622_924/lib/DBI/Gofer/Request.pm
DBI-1.622_924/lib/DBI/Gofer/Response.pm
DBI-1.622_924/lib/DBI/Gofer/Serializer/
DBI-1.622_924/lib/DBI/Gofer/Transport/
DBI-1.622_924/lib/DBI/Gofer/Transport/Base.pm
DBI-1.622_924/lib/DBI/Gofer/Transport/pipeone.pm
DBI-1.622_924/lib/DBI/Gofer/Transport/stream.pm
DBI-1.622_924/lib/DBI/Gofer/Serializer/Base.pm
DBI-1.622_924/lib/DBI/Gofer/Serializer/DataDumper.pm
DBI-1.622_924/lib/DBI/Gofer/Serializer/Storable.pm
DBI-1.622_924/lib/DBI/DBD/Metadata.pm
DBI-1.622_924/lib/DBI/DBD/SqlEngine/
DBI-1.622_924/lib/DBI/DBD/SqlEngine.pm
DBI-1.622_924/lib/DBI/DBD/SqlEngine/Developers.pod
DBI-1.622_924/lib/DBI/DBD/SqlEngine/HowTo.pod
DBI-1.622_924/lib/DBI/Const/GetInfo/
DBI-1.622_924/lib/DBI/Const/GetInfoReturn.pm
DBI-1.622_924/lib/DBI/Const/GetInfoType.pm
DBI-1.622_924/lib/DBI/Const/GetInfo/ANSI.pm
DBI-1.622_924/lib/DBI/Const/GetInfo/ODBC.pm
DBI-1.622_924/lib/DBD/DBM.pm
DBI-1.622_924/lib/DBD/ExampleP.pm
DBI-1.622_924/lib/DBD/File/
DBI-1.622_924/lib/DBD/File.pm
DBI-1.622_924/lib/DBD/Gofer/
DBI-1.622_924/lib/DBD/Gofer.pm
DBI-1.622_924/lib/DBD/NullP.pm
DBI-1.622_924/lib/DBD/Proxy.pm
DBI-1.622_924/lib/DBD/Sponge.pm
DBI-1.622_924/lib/DBD/Gofer/Policy/
DBI-1.622_924/lib/DBD/Gofer/Transport/
DBI-1.622_924/lib/DBD/Gofer/Transport/Base.pm
DBI-1.622_924/lib/DBD/Gofer/Transport/corostream.pm
DBI-1.622_924/lib/DBD/Gofer/Transport/null.pm
DBI-1.622_924/lib/DBD/Gofer/Transport/pipeone.pm
DBI-1.622_924/lib/DBD/Gofer/Transport/stream.pm
DBI-1.622_924/lib/DBD/Gofer/Policy/Base.pm
DBI-1.622_924/lib/DBD/Gofer/Policy/classic.pm
DBI-1.622_924/lib/DBD/Gofer/Policy/pedantic.pm
DBI-1.622_924/lib/DBD/Gofer/Policy/rush.pm
DBI-1.622_924/lib/DBD/File/Developers.pod
DBI-1.622_924/lib/DBD/File/HowTo.pod
DBI-1.622_924/lib/DBD/File/Roadmap.pod
DBI-1.622_924/lib/Bundle/DBI.pm
DBI-1.622_924/ex/corogofer.pl
DBI-1.622_924/ex/perl_dbi_nulls_test.pl
DBI-1.622_924/ex/profile.pl
[root@linuxtest ~]# cd DBI-1.622_924
[root@linuxtest DBI-1.622_924]# perl Makefile.PL
*** Your LANG environment variable is set to 'en_US.UTF-8'
*** This may cause problems for some perl installations.
*** If you get test failures, please try again with LANG unset.
*** If that then works, please email dbi-dev@perl.org with details
*** including the output of 'perl -V'

*** You are using a perl configured with threading enabled.
*** You should be aware that using multiple threads is
*** not recommended for production environments.
Your perl was compiled with gcc (version 4.1.2 20080704 (Red Hat 4.1.2-50)), okay.
Creating test wrappers for DBD::Gofer:
t/zvg_01basics.t
t/zvg_02dbidrv.t
t/zvg_03handle.t
t/zvg_04mods.t
t/zvg_05concathash.t
t/zvg_06attrs.t
t/zvg_07kids.t
t/zvg_08keeperr.t
t/zvg_09trace.t
t/zvg_10examp.t
t/zvg_11fetch.t
t/zvg_12quote.t
t/zvg_13taint.t
t/zvg_14utf8.t
t/zvg_15array.t
t/zvg_16destroy.t
t/zvg_19fhtrace.t
t/zvg_20meta.t
t/zvg_30subclass.t
t/zvg_31methcache.t
t/zvg_35thrclone.t (use threads)
t/zvg_40profile.t
t/zvg_41prof_dump.t
t/zvg_42prof_data.t
t/zvg_43prof_env.t
t/zvg_48dbi_dbd_sqlengine.t
t/zvg_49dbd_file.t
t/zvg_50dbm_simple.t
t/zvg_51dbm_file.t
t/zvg_52dbm_complex.t
t/zvg_60preparse.t
t/zvg_65transact.t
t/zvg_70callbacks.t
t/zvg_72childhandles.t
t/zvg_80proxy.t
t/zvg_85gofer.t
t/zvg_86gofer_fail.t
t/zvg_87gofer_cache.t
t/zvg_90sql_type_cast.t
Creating test wrappers for DBI::SQL::Nano:
t/zvn_48dbi_dbd_sqlengine.t
t/zvn_49dbd_file.t
t/zvn_50dbm_simple.t
t/zvn_51dbm_file.t
t/zvn_52dbm_complex.t
t/zvn_85gofer.t
Creating test wrappers for DBI::PurePerl:
t/zvp_01basics.t
t/zvp_02dbidrv.t
t/zvp_03handle.t
t/zvp_04mods.t
t/zvp_05concathash.t
t/zvp_06attrs.t
t/zvp_07kids.t
t/zvp_08keeperr.t
t/zvp_09trace.t
t/zvp_10examp.t
t/zvp_11fetch.t
t/zvp_12quote.t
t/zvp_13taint.t
t/zvp_14utf8.t
t/zvp_15array.t
t/zvp_16destroy.t
t/zvp_19fhtrace.t
t/zvp_20meta.t
t/zvp_30subclass.t
t/zvp_31methcache.t
t/zvp_35thrclone.t (use threads)
t/zvp_40profile.t
t/zvp_41prof_dump.t
t/zvp_42prof_data.t
t/zvp_43prof_env.t
t/zvp_48dbi_dbd_sqlengine.t
t/zvp_49dbd_file.t
t/zvp_50dbm_simple.t
t/zvp_51dbm_file.t
t/zvp_52dbm_complex.t
t/zvp_60preparse.t
t/zvp_65transact.t
t/zvp_70callbacks.t
t/zvp_72childhandles.t
t/zvp_80proxy.t
t/zvp_85gofer.t
t/zvp_86gofer_fail.t
t/zvp_87gofer_cache.t
t/zvp_90sql_type_cast.t
Creating test wrappers for DBD::Gofer + DBI::SQL::Nano:
t/zvxgn_48dbi_dbd_sqlengine.t
t/zvxgn_49dbd_file.t
t/zvxgn_50dbm_simple.t
t/zvxgn_51dbm_file.t
t/zvxgn_52dbm_complex.t
t/zvxgn_85gofer.t
Creating test wrappers for DBD::Gofer + DBI::PurePerl:
t/zvxgp_01basics.t
t/zvxgp_02dbidrv.t
t/zvxgp_03handle.t
t/zvxgp_04mods.t
t/zvxgp_05concathash.t
t/zvxgp_06attrs.t
t/zvxgp_07kids.t
t/zvxgp_08keeperr.t
t/zvxgp_09trace.t
t/zvxgp_10examp.t
t/zvxgp_11fetch.t
t/zvxgp_12quote.t
t/zvxgp_13taint.t
t/zvxgp_14utf8.t
t/zvxgp_15array.t
t/zvxgp_16destroy.t
t/zvxgp_19fhtrace.t
t/zvxgp_20meta.t
t/zvxgp_30subclass.t
t/zvxgp_31methcache.t
t/zvxgp_35thrclone.t (use threads)
t/zvxgp_40profile.t
t/zvxgp_41prof_dump.t
t/zvxgp_42prof_data.t
t/zvxgp_43prof_env.t
t/zvxgp_48dbi_dbd_sqlengine.t
t/zvxgp_49dbd_file.t
t/zvxgp_50dbm_simple.t
t/zvxgp_51dbm_file.t
t/zvxgp_52dbm_complex.t
t/zvxgp_60preparse.t
t/zvxgp_65transact.t
t/zvxgp_70callbacks.t
t/zvxgp_72childhandles.t
t/zvxgp_80proxy.t
t/zvxgp_85gofer.t
t/zvxgp_86gofer_fail.t
t/zvxgp_87gofer_cache.t
t/zvxgp_90sql_type_cast.t
Creating test wrappers for DBI::SQL::Nano + DBI::PurePerl:
t/zvxnp_48dbi_dbd_sqlengine.t
t/zvxnp_49dbd_file.t
t/zvxnp_50dbm_simple.t
t/zvxnp_51dbm_file.t
t/zvxnp_52dbm_complex.t
t/zvxnp_85gofer.t
Creating test wrappers for DBD::Gofer + DBI::SQL::Nano + DBI::PurePerl:
t/zvxgnp_48dbi_dbd_sqlengine.t
t/zvxgnp_49dbd_file.t
t/zvxgnp_50dbm_simple.t
t/zvxgnp_51dbm_file.t
t/zvxgnp_52dbm_complex.t
t/zvxgnp_85gofer.t
Checking if your kit is complete...
Looks good
    I see you're using perl 5.008008 on i386-linux-thread-multi, okay.
    Remember to actually *read* the README file!
    Use  'make' to build the software (dmake or nmake on Windows).
    Then 'make test' to execute self tests.
    Then 'make install' to install the DBI and then delete this working
    directory before unpacking and building any DBD::* drivers.
Writing Makefile for DBI
Writing MYMETA.yml and MYMETA.json
[root@linuxtest DBI-1.622_924]# make
/usr/bin/perl -MExtUtils::Command -e 'mkpath' -- blib/lib/DBI
rm -f blib/lib/DBI/Changes.pm
cp Changes blib/lib/DBI/Changes.pm
cp Driver_xst.h blib/arch/auto/DBI/Driver_xst.h
cp lib/DBI/Gofer/Response.pm blib/lib/DBI/Gofer/Response.pm
cp lib/DBD/Proxy.pm blib/lib/DBD/Proxy.pm
cp lib/DBI/Util/_accessor.pm blib/lib/DBI/Util/_accessor.pm
cp lib/DBI/Gofer/Transport/Base.pm blib/lib/DBI/Gofer/Transport/Base.pm
cp lib/DBD/DBM.pm blib/lib/DBD/DBM.pm
cp DBIXS.h blib/arch/auto/DBI/DBIXS.h
cp dbixs_rev.pl blib/lib/dbixs_rev.pl
cp lib/DBI/Gofer/Serializer/DataDumper.pm blib/lib/DBI/Gofer/Serializer/DataDumper.pm
cp lib/DBI/Const/GetInfoType.pm blib/lib/DBI/Const/GetInfoType.pm
cp lib/DBI/DBD/Metadata.pm blib/lib/DBI/DBD/Metadata.pm
cp lib/DBI/Const/GetInfo/ODBC.pm blib/lib/DBI/Const/GetInfo/ODBC.pm
cp lib/DBD/Gofer/Transport/pipeone.pm blib/lib/DBD/Gofer/Transport/pipeone.pm
cp lib/DBI/ProfileDumper/Apache.pm blib/lib/DBI/ProfileDumper/Apache.pm
cp lib/DBD/File.pm blib/lib/DBD/File.pm
cp Driver.xst blib/arch/auto/DBI/Driver.xst
cp lib/DBD/File/Roadmap.pod blib/lib/DBD/File/Roadmap.pod
cp lib/DBI/Util/CacheMemory.pm blib/lib/DBI/Util/CacheMemory.pm
cp lib/DBI/ProfileSubs.pm blib/lib/DBI/ProfileSubs.pm
cp lib/DBD/NullP.pm blib/lib/DBD/NullP.pm
cp dbi_sql.h blib/arch/auto/DBI/dbi_sql.h
cp lib/DBD/Gofer.pm blib/lib/DBD/Gofer.pm
cp lib/DBD/File/HowTo.pod blib/lib/DBD/File/HowTo.pod
cp dbd_xsh.h blib/arch/auto/DBI/dbd_xsh.h
cp dbivport.h blib/arch/auto/DBI/dbivport.h
cp lib/DBI/DBD/SqlEngine/HowTo.pod blib/lib/DBI/DBD/SqlEngine/HowTo.pod
cp dbixs_rev.h blib/arch/auto/DBI/dbixs_rev.h
cp lib/DBD/Gofer/Transport/Base.pm blib/lib/DBD/Gofer/Transport/Base.pm
cp lib/DBD/Gofer/Transport/corostream.pm blib/lib/DBD/Gofer/Transport/corostream.pm
cp lib/DBI/FAQ.pm blib/lib/DBI/FAQ.pm
cp lib/DBD/Gofer/Policy/rush.pm blib/lib/DBD/Gofer/Policy/rush.pm
cp lib/DBI/SQL/Nano.pm blib/lib/DBI/SQL/Nano.pm
cp lib/DBI/Const/GetInfo/ANSI.pm blib/lib/DBI/Const/GetInfo/ANSI.pm
cp lib/DBI/Gofer/Request.pm blib/lib/DBI/Gofer/Request.pm
cp lib/DBD/Gofer/Transport/stream.pm blib/lib/DBD/Gofer/Transport/stream.pm
cp lib/DBD/Gofer/Policy/classic.pm blib/lib/DBD/Gofer/Policy/classic.pm
cp lib/DBI/Const/GetInfoReturn.pm blib/lib/DBI/Const/GetInfoReturn.pm
cp lib/DBI/Gofer/Transport/stream.pm blib/lib/DBI/Gofer/Transport/stream.pm
cp lib/DBI/Gofer/Serializer/Storable.pm blib/lib/DBI/Gofer/Serializer/Storable.pm
cp DBI.pm blib/lib/DBI.pm
cp lib/DBD/Gofer/Policy/Base.pm blib/lib/DBD/Gofer/Policy/Base.pm
cp lib/DBD/Sponge.pm blib/lib/DBD/Sponge.pm
cp lib/DBD/Gofer/Policy/pedantic.pm blib/lib/DBD/Gofer/Policy/pedantic.pm
cp lib/DBI/Gofer/Transport/pipeone.pm blib/lib/DBI/Gofer/Transport/pipeone.pm
cp lib/DBI/W32ODBC.pm blib/lib/DBI/W32ODBC.pm
cp lib/DBI/DBD/SqlEngine/Developers.pod blib/lib/DBI/DBD/SqlEngine/Developers.pod
cp lib/DBD/Gofer/Transport/null.pm blib/lib/DBD/Gofer/Transport/null.pm
cp lib/Bundle/DBI.pm blib/lib/Bundle/DBI.pm
cp lib/DBD/File/Developers.pod blib/lib/DBD/File/Developers.pod
cp lib/DBI/Profile.pm blib/lib/DBI/Profile.pm
cp lib/DBI/ProfileDumper.pm blib/lib/DBI/ProfileDumper.pm
cp lib/DBI/Gofer/Serializer/Base.pm blib/lib/DBI/Gofer/Serializer/Base.pm
cp lib/DBI/ProxyServer.pm blib/lib/DBI/ProxyServer.pm
cp dbipport.h blib/arch/auto/DBI/dbipport.h
cp lib/DBI/Gofer/Execute.pm blib/lib/DBI/Gofer/Execute.pm
cp lib/DBI/DBD.pm blib/lib/DBI/DBD.pm
cp lib/DBI/DBD/SqlEngine.pm blib/lib/DBI/DBD/SqlEngine.pm
cp lib/Win32/DBIODBC.pm blib/lib/Win32/DBIODBC.pm
cp lib/DBI/PurePerl.pm blib/lib/DBI/PurePerl.pm
cp lib/DBD/ExampleP.pm blib/lib/DBD/ExampleP.pm
cp lib/DBI/ProfileData.pm blib/lib/DBI/ProfileData.pm
/usr/bin/perl -p -e "s/~DRIVER~/Perl/g" ./Driver.xst > Perl.xsi
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap  Perl.xs > Perl.xsc && mv Perl.xsc Perl.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"1.623\" -DXS_VERSION=\"1.623\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"  -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -Wmissing-noreturn -Wno-unused-parameter Perl.c
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap  DBI.xs > DBI.xsc && mv DBI.xsc DBI.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"1.623\" -DXS_VERSION=\"1.623\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"  -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -Wmissing-noreturn -Wno-unused-parameter DBI.c
Running Mkbootstrap for DBI ()
chmod 644 DBI.bs
rm -f blib/arch/auto/DBI/DBI.so
gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib DBI.o  -o blib/arch/auto/DBI/DBI.so      \
                \
chmod 755 blib/arch/auto/DBI/DBI.so
cp DBI.bs blib/arch/auto/DBI/DBI.bs
chmod 644 blib/arch/auto/DBI/DBI.bs
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" dbiprof.PL dbiprof
Extracted dbiprof from dbiprof.PL with variable substitutions.
cp dbiprof blib/script/dbiprof
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/dbiprof
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" dbiproxy.PL dbiproxy
Extracted dbiproxy from dbiproxy.PL with variable substitutions.
cp dbiproxy blib/script/dbiproxy
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/dbiproxy
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" dbilogstrip.PL dbilogstrip
Extracted dbilogstrip from dbilogstrip.PL with variable substitutions.
cp dbilogstrip blib/script/dbilogstrip
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/dbilogstrip
Manifying blib/man1/dbiprof.1
Manifying blib/man1/dbiproxy.1
Manifying blib/man1/dbilogstrip.1
Manifying blib/man3/DBD::Proxy.3pm
Manifying blib/man3/DBI::Gofer::Response.3pm
Manifying blib/man3/DBI::Gofer::Transport::Base.3pm
Manifying blib/man3/DBD::DBM.3pm
Manifying blib/man3/DBI::Const::GetInfoType.3pm
Manifying blib/man3/DBI::Gofer::Serializer::DataDumper.3pm
Manifying blib/man3/DBI::DBD::Metadata.3pm
Manifying blib/man3/DBD::Gofer::Transport::pipeone.3pm
Manifying blib/man3/DBI::Const::GetInfo::ODBC.3pm
Manifying blib/man3/DBI::ProfileDumper::Apache.3pm
Manifying blib/man3/DBD::File::Roadmap.3pm
Manifying blib/man3/DBD::File.3pm
Manifying blib/man3/DBI::Util::CacheMemory.3pm
Manifying blib/man3/DBI::ProfileSubs.3pm
Manifying blib/man3/DBD::File::HowTo.3pm
Manifying blib/man3/DBD::Gofer.3pm
lib/DBD/Gofer.pm:841: Unknown command paragraph "=encoding ISO8859-1"
Manifying blib/man3/DBI::DBD::SqlEngine::HowTo.3pm
Manifying blib/man3/DBD::Gofer::Transport::Base.3pm
Manifying blib/man3/DBD::Gofer::Transport::corostream.3pm
Manifying blib/man3/DBI::FAQ.3pm
Manifying blib/man3/DBD::Gofer::Policy::rush.3pm
Manifying blib/man3/DBI::SQL::Nano.3pm
Manifying blib/man3/DBI::Gofer::Request.3pm
Manifying blib/man3/DBI::Const::GetInfo::ANSI.3pm
Manifying blib/man3/DBD::Gofer::Transport::stream.3pm
Manifying blib/man3/DBD::Gofer::Policy::classic.3pm
Manifying blib/man3/DBD::Gofer::Policy::Base.3pm
Manifying blib/man3/DBI.3pm
Manifying blib/man3/DBI::Gofer::Serializer::Storable.3pm
Manifying blib/man3/DBI::Gofer::Transport::stream.3pm
Manifying blib/man3/DBI::Const::GetInfoReturn.3pm
Manifying blib/man3/DBD::Sponge.3pm
Manifying blib/man3/DBD::Gofer::Policy::pedantic.3pm
Manifying blib/man3/DBI::DBD::SqlEngine::Developers.3pm
Manifying blib/man3/DBI::W32ODBC.3pm
Manifying blib/man3/DBI::Gofer::Transport::pipeone.3pm
Manifying blib/man3/DBD::Gofer::Transport::null.3pm
Manifying blib/man3/Bundle::DBI.3pm
Manifying blib/man3/DBD::File::Developers.3pm
Manifying blib/man3/DBI::Profile.3pm
Manifying blib/man3/DBI::ProfileDumper.3pm
Manifying blib/man3/DBI::ProxyServer.3pm
Manifying blib/man3/DBI::Gofer::Serializer::Base.3pm
Manifying blib/man3/DBI::Gofer::Execute.3pm
Manifying blib/man3/DBI::DBD.3pm
Manifying blib/man3/Win32::DBIODBC.3pm
Manifying blib/man3/DBI::DBD::SqlEngine.3pm
Manifying blib/man3/DBI::PurePerl.3pm
Manifying blib/man3/DBI::ProfileData.3pm
[root@linuxtest DBI-1.622_924]# make  install
Manifying blib/man1/dbilogstrip.1
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/Driver.xst
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/Driver_xst.h
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DBI.so
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/DBIXS.h
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/dbixs_rev.h
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/ProfileDumper.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/Profile.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/Changes.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/DBD.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/FAQ.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/SQL/Nano.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBI/DBD/SqlEngine.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/DBM.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Proxy.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/File.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Gofer.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/NullP.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Gofer/Transport/stream.pm
Installing /usr/share/man/man1/dbilogstrip.1
Installing /usr/share/man/man1/dbiproxy.1
Installing /usr/share/man/man1/dbiprof.1
Installing /usr/share/man/man3/DBI::Profile.3pm
Installing /usr/share/man/man3/DBD::Gofer::Transport::stream.3pm
Installing /usr/share/man/man3/DBD::Gofer::Policy::pedantic.3pm
Installing /usr/share/man/man3/DBI::Gofer::Request.3pm
Installing /usr/share/man/man3/Win32::DBIODBC.3pm
Installing /usr/share/man/man3/DBI.3pm
Installing /usr/share/man/man3/DBD::File::Developers.3pm
Installing /usr/share/man/man3/DBI::DBD::Metadata.3pm
Installing /usr/share/man/man3/DBD::Gofer::Transport::pipeone.3pm
Installing /usr/share/man/man3/DBI::Const::GetInfoReturn.3pm
Installing /usr/share/man/man3/DBD::Gofer::Transport::Base.3pm
Installing /usr/share/man/man3/DBI::Gofer::Serializer::Storable.3pm
Installing /usr/share/man/man3/DBD::Gofer::Policy::Base.3pm
Installing /usr/share/man/man3/DBD::Sponge.3pm
Installing /usr/share/man/man3/DBI::Util::CacheMemory.3pm
Installing /usr/share/man/man3/DBI::Gofer::Transport::pipeone.3pm
Installing /usr/share/man/man3/DBI::DBD::SqlEngine.3pm
Installing /usr/share/man/man3/DBI::ProfileData.3pm
Installing /usr/share/man/man3/DBI::FAQ.3pm
Installing /usr/share/man/man3/Bundle::DBI.3pm
Installing /usr/share/man/man3/DBI::W32ODBC.3pm
Installing /usr/share/man/man3/DBI::SQL::Nano.3pm
Installing /usr/share/man/man3/DBD::File.3pm
Installing /usr/share/man/man3/DBD::Proxy.3pm
Installing /usr/share/man/man3/DBI::Const::GetInfoType.3pm
Installing /usr/share/man/man3/DBI::Gofer::Serializer::DataDumper.3pm
Installing /usr/share/man/man3/DBI::Gofer::Transport::Base.3pm
Installing /usr/share/man/man3/DBI::ProfileDumper.3pm
Installing /usr/share/man/man3/DBD::File::HowTo.3pm
Installing /usr/share/man/man3/DBI::ProfileDumper::Apache.3pm
Installing /usr/share/man/man3/DBI::Gofer::Transport::stream.3pm
Installing /usr/share/man/man3/DBD::Gofer.3pm
Installing /usr/share/man/man3/DBI::DBD.3pm
Installing /usr/share/man/man3/DBI::ProxyServer.3pm
Installing /usr/share/man/man3/DBD::Gofer::Transport::null.3pm
Installing /usr/share/man/man3/DBD::Gofer::Policy::rush.3pm
Installing /usr/share/man/man3/DBI::Gofer::Serializer::Base.3pm
Installing /usr/share/man/man3/DBD::DBM.3pm
Installing /usr/share/man/man3/DBI::ProfileSubs.3pm
Installing /usr/share/man/man3/DBI::Gofer::Execute.3pm
Installing /usr/share/man/man3/DBI::Gofer::Response.3pm
Installing /usr/share/man/man3/DBI::PurePerl.3pm
Installing /usr/share/man/man3/DBD::Gofer::Policy::classic.3pm
Installing /usr/share/man/man3/DBD::Gofer::Transport::corostream.3pm
Installing /usr/share/man/man3/DBI::DBD::SqlEngine::Developers.3pm
Installing /usr/share/man/man3/DBD::File::Roadmap.3pm
Installing /usr/share/man/man3/DBI::DBD::SqlEngine::HowTo.3pm
Installing /usr/share/man/man3/DBI::Const::GetInfo::ODBC.3pm
Installing /usr/share/man/man3/DBI::Const::GetInfo::ANSI.3pm 
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
จากนั้นก็ได้เวลา DBD:Oracle ก่อนติดตั้งเช็ค ORACLE_HOME, LD_LIBRARY_PATH ก่อนก็ดีนะครับ
[root@linuxtest ~]# wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.53_00.tar.gz
--2012-12-20 01:52:44--  http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.53_00.tar.gz
Resolving search.cpan.org... 199.15.176.161
Connecting to search.cpan.org|199.15.176.161|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirrors.issp.co.th/cpan/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.53_00.tar.gz [following]
--2012-12-20 01:52:45--  http://mirrors.issp.co.th/cpan/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.53_00.tar.gz
Resolving mirrors.issp.co.th... 202.43.32.2
Connecting to mirrors.issp.co.th|202.43.32.2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 443061 (433K) [application/x-gzip]
Saving to: `DBD-Oracle-1.53_00.tar.gz'
100%[==============================================================================================================================>] 443,061     1.32M/s   in 0.3s
2012-12-20 01:52:46 (1.32 MB/s) - `DBD-Oracle-1.53_00.tar.gz' saved [443061/443061]
[root@linuxtest ~]# tar zxvf DBD-Oracle-1.53_00.tar.gz
DBD-Oracle-1.53_00
DBD-Oracle-1.53_00/Todo
DBD-Oracle-1.53_00/README
DBD-Oracle-1.53_00/oci8.c
DBD-Oracle-1.53_00/LICENSE
DBD-Oracle-1.53_00/oci.def
DBD-Oracle-1.53_00/typemap
DBD-Oracle-1.53_00/Changes
DBD-Oracle-1.53_00/mkta.pl
DBD-Oracle-1.53_00/INSTALL
DBD-Oracle-1.53_00/META.yml
DBD-Oracle-1.53_00/MANIFEST
DBD-Oracle-1.53_00/dbdimp.h
DBD-Oracle-1.53_00/Oracle.h
DBD-Oracle-1.53_00/dbdimp.c
DBD-Oracle-1.53_00/META.json
DBD-Oracle-1.53_00/Oracle.xs
DBD-Oracle-1.53_00/t
DBD-Oracle-1.53_00/t/31lob.t
DBD-Oracle-1.53_00/t/38taf.t
DBD-Oracle-1.53_00/t/15nls.t
DBD-Oracle-1.53_00/ocitrace.h
DBD-Oracle-1.53_00/dbivport.h
DBD-Oracle-1.53_00/t/01base.t
DBD-Oracle-1.53_00/t/70meta.t
DBD-Oracle-1.53_00/t/30long.t
DBD-Oracle-1.53_00/t/39attr.t
DBD-Oracle-1.53_00/Makefile.PL
DBD-Oracle-1.53_00/t/21nchar.t
DBD-Oracle-1.53_00/t/25plsql.t
DBD-Oracle-1.53_00/t/rt13865.t
DBD-Oracle-1.53_00/README.mkdn
DBD-Oracle-1.53_00/t/55nested.t
DBD-Oracle-1.53_00/t/50cursor.t
DBD-Oracle-1.53_00/t/58object.t
DBD-Oracle-1.53_00/t/20select.t
DBD-Oracle-1.53_00/t/51scroll.t
DBD-Oracle-1.53_00/t/60reauth.t
DBD-Oracle-1.53_00/examples
DBD-Oracle-1.53_00/examples/sql
DBD-Oracle-1.53_00/t/10general.t
DBD-Oracle-1.53_00/t/32xmltype.t
DBD-Oracle-1.53_00/t/40ph_type.t
DBD-Oracle-1.53_00/t/14threads.t
DBD-Oracle-1.53_00/t/12impdata.t
DBD-Oracle-1.53_00/t/23wide_db.t
DBD-Oracle-1.53_00/hints
DBD-Oracle-1.53_00/hints/dgux.pl
DBD-Oracle-1.53_00/hints/svr4.pl
DBD-Oracle-1.53_00/examples/japh
DBD-Oracle-1.53_00/t/36lob_leak.t
DBD-Oracle-1.53_00/t/56embbeded.t
DBD-Oracle-1.53_00/t/00versions.t
DBD-Oracle-1.53_00/examples/ex.pl
DBD-Oracle-1.53_00/README.help.txt
DBD-Oracle-1.53_00/t/26exe_array.t
DBD-Oracle-1.53_00/t/34pres_lobs.t
DBD-Oracle-1.53_00/examples/README
DBD-Oracle-1.53_00/t/28array_bind.t
DBD-Oracle-1.53_00/t/22nchar_utf8.t
DBD-Oracle-1.53_00/examples/proc.pl
DBD-Oracle-1.53_00/examples/bind.pl
DBD-Oracle-1.53_00/lib/DBD
DBD-Oracle-1.53_00/lib/DBD/Oracle.pm
DBD-Oracle-1.53_00/t/80ora_charset.t
DBD-Oracle-1.53_00/t/31lob_extended.t
DBD-Oracle-1.53_00/t/23wide_db_8bit.t
DBD-Oracle-1.53_00/examples/commit.pl
DBD-Oracle-1.53_00/examples/curref.pl
DBD-Oracle-1.53_00/t/nchar_test_lib.pl
DBD-Oracle-1.53_00/t/24implicit_utf8.t
DBD-Oracle-1.53_00/hints/macos_syms.pl
DBD-Oracle-1.53_00/examples/mktable.pl
DBD-Oracle-1.53_00/examples/tabinfo.pl
DBD-Oracle-1.53_00/examples/oradump.pl
DBD-Oracle-1.53_00/t/22nchar_al32utf8.t
DBD-Oracle-1.53_00/hints/macos_lib.syms
DBD-Oracle-1.53_00/t/lib
DBD-Oracle-1.53_00/t/lib/ExecuteArray.pm
DBD-Oracle-1.53_00/t/23wide_db_al32utf8.t
DBD-Oracle-1.53_00/hints/macos_bundle.syms
DBD-Oracle-1.53_00/examples/ora_explain.pl
DBD-Oracle-1.53_00/lib/DBD/Oracle
DBD-Oracle-1.53_00/lib/DBD/Oracle/Object.pm
DBD-Oracle-1.53_00/t/rt74753-utf8-encoded.t
DBD-Oracle-1.53_00/lib/DBD/Oracle/GetInfo.pm
DBD-Oracle-1.53_00/examples/inserting_longs.pl
DBD-Oracle-1.53_00/t/000-report-versions-tiny.t
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting.pod
DBD-Oracle-1.53_00/examples/read_long_via_blob_read.pl
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Aix.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Sun.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Vms.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Hpux.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Linux.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Win32.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Macos.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Win64.pod
DBD-Oracle-1.53_00/lib/DBD/Oracle/Troubleshooting/Cygwin.pod
[root@linuxtest ~]# cd DBD-Oracle-1.53_00
[root@linuxtest DBD-Oracle-1.53_00]# perl Makefile.PL
Using DBI 1.623 (for perl 5.008008 on i386-linux-thread-multi) installed in /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/
Configuring DBD::Oracle for perl 5.008008 on linux (i386-linux-thread-multi)
Remember to actually *READ* the README file! Especially if you have any problems.
Installing on a linux, Ver#2.6
Using Oracle in /usr/lib/oracle/11.2/client
DEFINE _SQLPLUS_RELEASE = "1102000300" (CHAR)
Oracle version 11.2.0.3 (11.2)
Found /usr/share/oracle/11.2/client/demo.mk
Using /usr/share/oracle/11.2/client/demo.mk
Your LD_LIBRARY_PATH env var is set to '/usr/lib/oracle/11.2/client/lib'
Reading /usr/share/oracle/11.2/client/demo.mk
WARNING: Oracle /usr/share/oracle/11.2/client/demo.mk doesn't define a 'build' rule.
WARNING: I will now try to guess how to build and link DBD::Oracle for you.
         This kind of guess work is very error prone and Oracle-version sensitive.
         It is possible that it won't be supported in future versions of DBD::Oracle.
         *PLEASE* notify dbi-users about exactly _why_ you had to build it this way.
Found header files in /usr/include/oracle/11.2/client.
client_version=11.2

DEFINE= -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.3\" -DORA_OCI_102 -DORA_OCI_112

Checking for functioning wait.ph

System: perl5.008008 linux ca-build9.us.oracle.com 2.6.20-1.3002.fc6xen #1 smp thu apr 30 18:08:39 pdt 2009 i686 i686 i386 gnulinux
Compiler:   gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
Linker:     /usr/bin/ld
Sysliblist:
Oracle makefiles would have used these definitions but we override them:
  CC:       /usr/bin/gcc
  LDFLAGS:  -g $(MTYPE)
sh: shell: command not found
           [-g ]
Linking with  -L../../ -locci -lclntsh -lpthread [from $(CCLIB)]
Checking if your kit is complete...
Looks good
Warning: -L../../ changed to -L/root/DBD-Oracle-1.53_00/../../
LD_RUN_PATH=/usr/lib/oracle/11.2/client/lib
Using DBD::Oracle 1.53_00.
Using DBD::Oracle 1.53_00.
Using DBI 1.623 (for perl 5.008008 on i386-linux-thread-multi) installed in /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::Oracle
Writing MYMETA.yml and MYMETA.json
***  If you have problems...
     read all the log printed above, and the README and README.help.txt files.
     (Of course, you have read README by now anyway, haven't you?)
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]# make
cp lib/DBD/Oracle/Troubleshooting/Cygwin.pod blib/lib/DBD/Oracle/Troubleshooting/Cygwin.pod
cp lib/DBD/Oracle.pm blib/lib/DBD/Oracle.pm
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp lib/DBD/Oracle/Troubleshooting/Hpux.pod blib/lib/DBD/Oracle/Troubleshooting/Hpux.pod
cp lib/DBD/Oracle/Troubleshooting/Vms.pod blib/lib/DBD/Oracle/Troubleshooting/Vms.pod
cp lib/DBD/Oracle/Troubleshooting/Linux.pod blib/lib/DBD/Oracle/Troubleshooting/Linux.pod
cp lib/DBD/Oracle/GetInfo.pm blib/lib/DBD/Oracle/GetInfo.pm
cp lib/DBD/Oracle/Troubleshooting.pod blib/lib/DBD/Oracle/Troubleshooting.pod
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp lib/DBD/Oracle/Troubleshooting/Sun.pod blib/lib/DBD/Oracle/Troubleshooting/Sun.pod
cp lib/DBD/Oracle/Troubleshooting/Macos.pod blib/lib/DBD/Oracle/Troubleshooting/Macos.pod
cp lib/DBD/Oracle/Object.pm blib/lib/DBD/Oracle/Object.pm
cp lib/DBD/Oracle/Troubleshooting/Aix.pod blib/lib/DBD/Oracle/Troubleshooting/Aix.pod
cp lib/DBD/Oracle/Troubleshooting/Win64.pod blib/lib/DBD/Oracle/Troubleshooting/Win64.pod
cp lib/DBD/Oracle/Troubleshooting/Win32.pod blib/lib/DBD/Oracle/Troubleshooting/Win32.pod
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
/usr/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/Driver.xst > Oracle.xsi
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap  Oracle.xs > Oracle.xsc && mv Oracle.xsc Oracle.c
gcc -c  -I/usr/include/oracle/11.2/client  -I/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"1.53_00\" -DXS_VERSION=\"1.53_00\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.3\" -DORA_OCI_102 -DORA_OCI_112 Oracle.c
gcc -c  -I/usr/include/oracle/11.2/client  -I/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"1.53_00\" -DXS_VERSION=\"1.53_00\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.3\" -DORA_OCI_102 -DORA_OCI_112 dbdimp.c
gcc -c  -I/usr/include/oracle/11.2/client  -I/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   -DVERSION=\"1.53_00\" -DXS_VERSION=\"1.53_00\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.3\" -DORA_OCI_102 -DORA_OCI_112 oci8.c
oci8.c: In function âscribe_obj_by_tdoâoci8.c:3254: warning: comparison is always false due to limited range of data type
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
LD_RUN_PATH="/usr/lib/oracle/11.2/client/lib" gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib Oracle.o dbdimp.o oci8.o  -o blib/arch/auto/DBD/Oracle/Oracle.so   \
           -L/usr/lib/oracle/11.2/client/lib -L/root/DBD-Oracle-1.53_00/../.. -locci -lclntsh -lpthread         \
chmod 755 blib/arch/auto/DBD/Oracle/Oracle.so
cp Oracle.bs blib/arch/auto/DBD/Oracle/Oracle.bs
chmod 644 blib/arch/auto/DBD/Oracle/Oracle.bs
Manifying blib/man3/DBD::Oracle::Troubleshooting.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Cygwin.3pm
Manifying blib/man3/DBD::Oracle.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Sun.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Vms.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Macos.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Hpux.3pm
lib/DBD/Oracle/Troubleshooting/Hpux.pod:971: Unknown command paragraph "=itme 3 Add the following line: "
lib/DBD/Oracle/Troubleshooting/Hpux.pod:995: Unmatched =back
Manifying blib/man3/DBD::Oracle::Object.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Aix.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Linux.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Win64.3pm
Manifying blib/man3/DBD::Oracle::Troubleshooting::Win32.3pm
Manifying blib/man3/DBD::Oracle::GetInfo.3pm
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]#
[root@linuxtest DBD-Oracle-1.53_00]# make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/Oracle/dbdimp.h
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/Oracle/mk.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Object.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/GetInfo.pm
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Cygwin.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Hpux.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Aix.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Win32.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Linux.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Macos.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Vms.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Win64.pod
Installing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/DBD/Oracle/Troubleshooting/Sun.pod
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Linux.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Win64.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Aix.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Macos.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Hpux.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Vms.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Win32.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Sun.3pm
Installing /usr/share/man/man3/DBD::Oracle.3pm
Installing /usr/share/man/man3/DBD::Oracle::Object.3pm
Installing /usr/share/man/man3/DBD::Oracle::GetInfo.3pm
Installing /usr/share/man/man3/DBD::Oracle::Troubleshooting::Cygwin.3pm
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
[root@linuxtest DBD-Oracle-1.53_00]#
ไม่มี Error เป็นติดตั้งเรียบร้อยสวยงาม งั้นทดสอบ code ง่ายๆ
[root@linuxtest ~]# cat test.pl
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $db = DBI->connect( "dbi:Oracle:(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.111.151)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME = orcl)))", "demo", "demo",{AutoCommit=>0, RaiseError=>1} )
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $db->prepare("SELECT SYS_CONTEXT (\'USERENV\', \'SESSION_USER\') FROM DUAL ")
        or die "Couldn't prepare statement: " . $db->errstr;
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;
while ( my @data = $sth->fetchrow_array() )
{
     print "$data[0] \n";
}
$sth->finish;
$db->disconnect;
[root@linuxtest ~]# perl test.pl
DEMO
[root@linuxtest ~]#
Done. :)


วันอังคารที่ 7 สิงหาคม พ.ศ. 2555

เขียน Perl ติดต่อฐานข้อมูล Oracle #1

หลายท่านทำงานกับฐานข้อมูล Oracle บางท่านอาจจำเป็นต้องเขียนโปรแกรมเพื่อติดต่อกับ Oracle Database ผมเองก็สนใจอยู่หลายๆ โปรแกรม แต่ในบทความนี้ขอเริ่มด้วย PERL ละกัน
สิ่งที่ต้องมีก็คือ Perl program และ Perl Module ผมจะเน้นไปที่ Perl module (DBD::Oracle) การที่เราจะติดตั้ง DBD::Oracle module ได้นั้น เราต้องมี DBI module เสียก่อน แต่ที่ขาดไม่ได้เลยคือ Oracle client library
ในตัวอย่างต้องขออภัยที่ต้องใช้ oracle xe เพราะสะดวกผมในการติดตั้งและทดสอบ ในกรณีที่ท่านมี Oracle Database แยกคนละเครื่อง ท่านสามารถติดตั้ง instantclient ก็เพียงพอแล้ว

$  ldd /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so | grep oracle
        libclntsh.so.11.1 => /u01/app/oracle/product/11.2.0/xe/lib/libclntsh.so.11.1 (0x00007f1994c89000)
        libnnz11.so => /u01/app/oracle/product/11.2.0/xe/lib/libnnz11.so (0x00007f19942d9000)

นั่นคือตัวอย่าง แสดงให้เห็นว่า DBD::Oracle นั้นต้องการ Library อะไรจาก Oracle HOME

การติดตั้ง Oracle XE นั้นง่ายมาก แค่ download และใช้คำสั่่ง rpm 

[root@fedora ~]# unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Archive:  oracle-xe-11.2.0-1.0.x86_64.rpm.zip
   creating: Disk1/
   creating: Disk1/upgrade/
  inflating: Disk1/upgrade/gen_inst.sql
   creating: Disk1/response/
  inflating: Disk1/response/xe.rsp
  inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm
[root@fedora ~]# cd Disk1/
[root@fedora Disk1]# ls
oracle-xe-11.2.0-1.0.x86_64.rpm  response  upgrade
[root@fedora Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
error: Failed dependencies:
        libaio >= 0.3.104 is needed by oracle-xe-11.2.0-1.0.x86_64
[root@fedora Disk1]# yum install libaio
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-4.fc16 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================
 Package                         Arch                            Version                                  Repository                       Size
================================================================================================================================================
Installing:
 libaio                          x86_64                          0.3.109-4.fc16                           fedora                           21 k
Transaction Summary
================================================================================================================================================
Install       1 Package
Total download size: 21 k
Installed size: 21 k
Is this ok [y/N]: y
Downloading Packages:
libaio-0.3.109-4.fc16.x86_64.rpm                                                                                         |  21 kB     00:00
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libaio-0.3.109-4.fc16.x86_64                                                                                                 1/1
Installed:
  libaio.x86_64 0:0.3.109-4.fc16
Complete!
[root@fedora Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing...                ########################################### [100%]
   1:oracle-xe              ########################################### [100%]
Executing post-install steps...
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `echo ~(unknown)'
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
[root@fedora Disk1]# /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:
Specify a port that will be used for the database listener [1521]:
Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Password can't be null. Enter password:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:n
Starting Oracle Net Listener...Done
Configuring database...
Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
[root@fedora Disk1]# ps -aef | grep pmon
oracle    4166     1  0 00:39 ?        00:00:00 xe_pmon_XE

หลังจากติดตั้ง Oracle XE ก็ได้เวลาในการติดตั้ง Perl module - DBD::Oracle 
สิ่งแรกที่ต้องทำคือ download mudule จาก cpan.org หลังจากนั้น ลองมาติดตั้งกัน...
[root@fedora ~]# tar zxf DBD-Oracle-1.46.tar.gz
[root@fedora ~]# cd DBD-Oracle-1.46/
[root@fedora DBD-Oracle-1.46]# ls
Changes     examples  LICENSE      META.yml  ocitrace.h  Oraperl.pm        README.clients.txt  README.java.txt    README.win32.txt  Todo
dbdimp.c    hints     Makefile.PL  mkta.pl   Oracle.h    README            README-files        README.macosx.txt  README.win64.txt  typemap
dbdimp.h    INSTALL   MANIFEST     oci8.c    Oracle.xs   README.64bit.txt  README.help.txt     README.mkdn        t
dbivport.h  lib       META.json    oci.def   oraperl.ph  README.aix.txt    README.hpux.txt     README.sec.txt     test.pl
[root@fedora DBD-Oracle-1.46]# ls README.64bit.txt
README.64bit.txt
[root@fedora DBD-Oracle-1.46]# less  README.64bit.txt
[root@fedora DBD-Oracle-1.46]# export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
[root@fedora DBD-Oracle-1.46]# 
[root@fedora DBD-Oracle-1.46]# perl Makefile.PL
Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 21.
[root@fedora DBD-Oracle-1.46]# yum install perl-DBI.x86_64
[root@fedora DBD-Oracle-1.46]# perl Makefile.PL
Using DBI 1.616 (for perl 5.014002 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/auto/DBI/
Configuring DBD::Oracle for perl 5.014002 on linux (x86_64-linux-thread-multi)
Remember to actually *READ* the README file! Especially if you have any problems.
Installing on a linux, Ver#2.6
Using Oracle in /u01/app/oracle/product/11.2.0/xe
DEFINE _SQLPLUS_RELEASE = "1102000200" (CHAR)
Oracle version 11.2.0.2 (11.2)
Found /u01/app/oracle/product/11.2.0/xe/rdbms/demo/demo_xe.mk
Using /u01/app/oracle/product/11.2.0/xe/rdbms/demo/demo_xe.mk
Looks like Oracle XE (/u01/app/oracle/product/11.2.0/xe/rdbms/demo/demo_xe.mk)
Reading /u01/app/oracle/product/11.2.0/xe/rdbms/demo/demo_xe.mk
Your LD_LIBRARY_PATH env var is set to ''
WARNING: Your LD_LIBRARY_PATH env var doesn't include '/u01/app/oracle/product/11.2.0/xe/lib' but probably needs to.
client_version=11.2

DEFINE= -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.2\" -DORA_OCI_102 -DORA_OCI_112

Checking for functioning wait.ph

System: perl5.014002 linux x86-17.phx2.fedoraproject.org 2.6.32-220.4.1.el6.x86_64 #1 smp thu jan 19 14:50:54 est 2012 x86_64 x86_64 x86_64 gnulinux
Compiler:   gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
Linker:     not found
Sysliblist: -ldl -lm -lpthread -lnsl -lirc
Oracle makefiles would have used these definitions but we override them:
  CC:       /usr/bin/gcc
  LDFLAGS:  -g
           [-g]
Linking with -L/u01/app/oracle/product/11.2.0/xe/lib/ -lclntsh -lpthread
Checking if your kit is complete...
Looks good
LD_RUN_PATH=/u01/app/oracle/product/11.2.0/xe/lib
Using DBD::Oracle 1.46.
Using DBD::Oracle 1.46.
Using DBI 1.616 (for perl 5.014002 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/auto/DBI/
Writing Makefile for DBD::Oracle
Writing MYMETA.yml
***  If you have problems...
     read all the log printed above, and the README and README.help.txt files.
     (Of course, you have read README by now anyway, haven't you?)
[root@fedora DBD-Oracle-1.46]# make
gcc -c  -I/usr/lib64/perl5/vendor_perl/auto/DBI -I/u01/app/oracle/product/11.2.0/xe/rdbms/public/ -DLINUX -D_GNU_SOURCE -D_REENTRANT -g -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.46\" -DXS_VERSION=\"1.46\" -fPIC "-I/usr/lib64/perl5/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.2\" -DORA_OCI_102 -DORA_OCI_112 Oracle.c
gcc -c  -I/usr/lib64/perl5/vendor_perl/auto/DBI -I/u01/app/oracle/product/11.2.0/xe/rdbms/public/ -DLINUX -D_GNU_SOURCE -D_REENTRANT -g -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.46\" -DXS_VERSION=\"1.46\" -fPIC "-I/usr/lib64/perl5/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.2\" -DORA_OCI_102 -DORA_OCI_112 dbdimp.c
dbdimp.c: In function ‘ora_db_login6’:
dbdimp.c:776:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type ‘size_t’ [-Wformat]
dbdimp.c:776:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 14 has type ‘size_t’ [-Wformat]
gcc -c  -I/usr/lib64/perl5/vendor_perl/auto/DBI -I/u01/app/oracle/product/11.2.0/xe/rdbms/public/ -DLINUX -D_GNU_SOURCE -D_REENTRANT -g -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.46\" -DXS_VERSION=\"1.46\" -fPIC "-I/usr/lib64/perl5/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"11.2.0.2\" -DORA_OCI_102 -DORA_OCI_112 oci8.c
oci8.c: In function ‘ora_blob_read_mb_piece’:
oci8.c:1849:4: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘ub4’ [-Wformat]
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic Oracle.o dbdimp.o oci8.o  -o blib/arch/auto/DBD/Oracle/Oracle.so   \
   -L/u01/app/oracle/product/11.2.0/xe/lib/ -lclntsh -lpthread          \
chmod 755 blib/arch/auto/DBD/Oracle/Oracle.so
cp Oracle.bs blib/arch/auto/DBD/Oracle/Oracle.bs
chmod 644 blib/arch/auto/DBD/Oracle/Oracle.bs
Manifying blib/man3/DBD::Oracle::Troubleshooting.3pm
Manifying blib/man3/DBD::Oracle.3pm
Manifying blib/man3/DBD::Oracle::Object.3pm
Manifying blib/man3/DBD::Oraperl.3pm
Manifying blib/man3/DBD::Oracle::GetInfo.3pm
[root@fedora DBD-Oracle-1.46]# make test
[root@fedora DBD-Oracle-1.46]# make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/dbdimp.h
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/ocitrace.h
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.bs
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/mk.pm
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so
Installing /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.h
Installing /usr/local/lib64/perl5/oraperl.ph
Installing /usr/local/lib64/perl5/Oraperl.pm
Installing /usr/local/lib64/perl5/DBD/Oracle.pm
Installing /usr/local/lib64/perl5/DBD/Oracle/Object.pm
Installing /usr/local/lib64/perl5/DBD/Oracle/GetInfo.pm
Installing /usr/local/lib64/perl5/DBD/Oracle/Troubleshooting.pm
Installing /usr/local/share/man/man3/DBD::Oraperl.3pm
Installing /usr/local/share/man/man3/DBD::Oracle.3pm
Installing /usr/local/share/man/man3/DBD::Oracle::GetInfo.3pm
Installing /usr/local/share/man/man3/DBD::Oracle::Object.3pm
Installing /usr/local/share/man/man3/DBD::Oracle::Troubleshooting.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
จากการติดตั้งจะเห็นว่าต้องการ DBI module ก่อน
เมื่อเราติดตั้ง DBI::Oracle เรียบร้อยลองมาเขียน Perl โปรแกรมติดต่อฐานข้อมูล Oracle สักนิด
[opun@fedora PERL_PRACTICE]$ cat test-connect.pl
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $result;
my $db = DBI->connect( "dbi:Oracle:XE", "demo", "demo",{AutoCommit=>0, RaiseError=>1} )
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $db->prepare("SELECT SYS_CONTEXT (\'USERENV\', \'SESSION_USER\') FROM DUAL ")
        or die "Couldn't prepare statement: " . $db->errstr;
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;
while ( my @data = $sth->fetchrow_array() )
{
    $result = $data[0];
}
$sth->finish;
$db->disconnect;
print "Result: $result \n\n";
[opun@fedora PERL_PRACTICE]$ perl test-connect.pl
Result: DEMO
นั่นทำรู้ว่า DBI::Oracle ใช้งานได้ บทความนี้เป็นการเริ่มต้น สำหรับคนที่สนใจ Perl - DBI::Oracle module ติดต่อฐานข้อมูล Oracle

วันพฤหัสบดีที่ 19 กรกฎาคม พ.ศ. 2555

ทดสอบ thai language (oracle) กับ Browser


เมื่อกลับไปอ่านบทความเดิม ที่เคยทดสอบมานานแสนนาน ก็เจอว่าเคยใช้เวลาบางช่วงกับการทดสอบ thai language ด้วย browser กับ Oracle Database
SQL> select * from database_properties where PROPERTY_NAME like 'NLS_CHAR%';
PROPERTY_NAME                  PROPERTY_VALUE       DESCRIPTION
------------------------------ -------------------- ------------------------------
NLS_CHARACTERSET               TH8TISASCII          Character set
สิ่งหนึ่งที่น่าคิดทำไมใช้ TH8TISASCII ละครับ ง่ายมาก... เพราะผมเก็บภาษาไทยใน VARCHAR2 (1 ตัวอักษรเท่ากับ 1 byte)
ถ้าใช้ AL32UTF8 ละ ถ้าเก็บภาษาไทยใน VARCHAR2 (อาจเจอ 1 ตัวอักษร = 3 bytes) จริงไม่จริงก็ต้องลองทดสอบกันดู ในกรณีที่ใช้ AL32UTF8 แล้วอยากเก็บภาษาไทย แต่ไม่ให้ (1 ตัวอักษร = 3 byte) คงยาก ลองไปใช้ NVARVAR2 ดูสิอาจช่วยได้
อย่างไรก็ดี นั่นคือเรื่องเล่า แต่สิ่งที่น่าสนใจ ต้องถามว่า  nls_length_semantics มีค่าเป็น
SQL> show parameter nls_length_semantics
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
nls_length_semantics                 string      BYTE
นั่นแหละ คือสิ่งที่ต้องรู้ เอาแบบเร็วๆ (NLS_LENGTH_SEMANTICS enables you to create CHAR and VARCHAR2 columns using either byte or character length semantics.)
ก็ตามภาษาอังกฤษนั่นแหละ ดังนั้นลอง เปลี่ยน column VARCHAR2 เป็น character length semantic ดูแล้วทดสอบ ว่าเป็นอย่างไร

กลับมากับการทดสอบ Browser เล่นๆ กัน ด้วย PHP ต้องขอบอกก่อนที่ PHP นั้นผมได้เซต NLS_LANG=.TH8TISASCII  อยู่แล้วนะครับ

นี่คือข้อมูลที่มี หลังจาก INSERT ด้วย Browser บ้าง Client Program บ้าง
SQL> select * from tab_char;
A
--------------------------------------------------
à¸à¸”ี1
ดี2
ต่อจากนนั้นผมก็เขี่ยน PHP ง่าย Query มันออกมา จากนั้นเปลี่ยน Encoding บนBrowser ดู

<?php
$conn = oci_pconnect("test_char", "test_char", "DB");
$stmt = oci_parse($conn, "select * from tab_char");
    oci_execute($stmt, OCI_DEFAULT);
    while (oci_fetch($stmt)) {
        echo "    " . oci_result($stmt, "A") . "<br>\n";
    }

?>

(IE) Web result: 
- Thai (windows)
เธ”เธต1
ดี2

- Unicode (UTF8)
ดี1
ดี2

(Firefox) Web result: 
- windows (iso-8859-1)
ดี1
ดี2

-Unicode (UTF8)
ดี1
ดี2

- TIS 620
เธ”เธต1
ดี2

จากนั้นลอง INSERT จาก Browser ด้วย Encoding ที่ต่างๆ ออกไป
<?php
$x=$_POST['DATA'];
$conn = oci_pconnect("test_char", "test_char", "DB");
$stmt = oci_parse($conn, "insert into tab_char values ('$x')");
oci_execute($stmt, OCI_DEFAULT);
oci_commit($conn);

$stmt = oci_parse($conn, "select * from tab_char");
    oci_execute($stmt, OCI_DEFAULT);
    while (oci_fetch($stmt)) {
        echo "    " . oci_result($stmt, "A") . "<br>\n";
    }

?>

5 กรณี 
- ISO-8859-1  
DATA = ดี201

- UTF-8 
DATA = ดี202

- Windows-1252
DATA = ดี203

- TIS-620
DATA = ดี204

- Windows-874
DATA = ดี205

จากนั้นลองใช้ SQL*Plus ดึงข้อมูลออกมาดู
A
--------------------------------------------------
ดี201
ดี203 

à¸à¸”ี202
��204
��205
สรุปได้ว่า!
- Character-Encoding บน Browser มีผลกับขอ้มูลที่ insert ลง table
- ถ้าเรียกใช้ Character-Encoding ใดในการ Insert ข้อมูล... ควรต้องใช้ Character-Encoding นั้นในการโชว์ข้อมูล
- PL/SQL developer (NLS_LANG=AMERICAN_AMERICA.TH8TISASCII) สามารถโชว์ข้อมูล ที่เกิดจาก Character-Encoding (TIS-620,Windows-874) ได้ดี

*** นี่เป็นการทดสอบขำๆ แต่หวังว่าจะมีประโยชน์ กับคนอ่าน ***