Objective: To able write execute perl script to access to Oracle database
Problems:
Error messages when executing perl script to connect Oracle database:
- Can't locate object method "connect" via package "DBI" (even you have copied the oracle.pm into the DBD folder)
Solutions:
- Need to identify the RHEL / Linux OS you have executed has the /usr/local/lib64/perl5/DBD/Oracle.pm
- If the Oracle.pm is not there, then you need to follow the steps below:
i) Install Oracle client into your RHEL machine
- For RHEL 6.5, is advised to install Oracle client 12.0.2 which compatible with this distro version.
- Download link http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-1959253.html
- Choose the Oracle Database 12c Release 1 Client (12.1.0.1.0) for Linux x86-64 (my RHEL 6.5 is running on 64 bits)
- Extract and execute the client installer "./runInstaller"
- If there are dependencies missing, try use "yum search xxxx" for the exact packages. Then to install the packages "yum install YYYYY"
- Redo until all required packages are installed.
ii) Before you can compiled and create the right Oracle.pm, here are some dependencies that needed from Oracle website:
- http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
-- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-odbc-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm
- To install them type: "sudo rpm -ivh oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm"
-- If these packages are not installed, then you will see error messages during compilation as below:
iii) Finally can start to compile by create a script named test.sh, additional 2 lines on top is required to set the environment right before compilation to produce the Oracle.pm module
[kyfoo@hostname~]$ cat test.sh
export LD_LIBRARY_PATH=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
export ORACLE_HOME-=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
perl -MCPAN -e 'install DBD::Oracle'
Problems:
Error messages when executing perl script to connect Oracle database:
- Can't locate object method "connect" via package "DBI" (even you have copied the oracle.pm into the DBD folder)
Solutions:
- Need to identify the RHEL / Linux OS you have executed has the /usr/local/lib64/perl5/DBD/Oracle.pm
- If the Oracle.pm is not there, then you need to follow the steps below:
i) Install Oracle client into your RHEL machine
- For RHEL 6.5, is advised to install Oracle client 12.0.2 which compatible with this distro version.
- Download link http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-1959253.html
- Choose the Oracle Database 12c Release 1 Client (12.1.0.1.0) for Linux x86-64 (my RHEL 6.5 is running on 64 bits)
- Extract and execute the client installer "./runInstaller"
- If there are dependencies missing, try use "yum search xxxx" for the exact packages. Then to install the packages "yum install YYYYY"
- Redo until all required packages are installed.
ii) Before you can compiled and create the right Oracle.pm, here are some dependencies that needed from Oracle website:
- http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
-- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-odbc-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm
- To install them type: "sudo rpm -ivh oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm"
-- If these packages are not installed, then you will see error messages during compilation as below:
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm/usr/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/lib64/perl5/auto/DBI/Driver.xst >/usr/bin/perl /usr/share/perl5/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtigcc -c -I/usr/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-alias_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 SUPPORT -DORA_OCI_VERSION=\"12.1.0.2\" -DORA_OCI_102 -DORA_OCI_112 Oracle.cIn file included from Oracle.xs:1:Oracle.h:37:17: error: oci.h: No such file or directoryOracle.h:38:22: error: oratypes.h: No such file or directoryOracle.h:39:20: error: ocidfn.h: No such file or directoryOracle.h:40:18: error: orid.h: No such file or directoryOracle.h:41:17: error: ori.h: No such file or directoryIn file included from Oracle.h:52, from Oracle.xs:1:dbdimp.h:23: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:41: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:93: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:159: error: expected specifier-qualifier-list before ‘ub4’In file included from Oracle.h:52, from Oracle.xs:1:dbdimp.h:173: error: expected specifier-qualifier-list before ‘text’dbdimp.h:199: error: expected specifier-qualifier-list before ‘OCIParam’dbdimp.h:246: error: expected specifier-qualifier-list before ‘sword’dbdimp.h:294: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘chdbdimp.h:295: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ncdbdimp.h:296: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘usdbdimp.h:297: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘utdbdimp.h:298: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘aldbdimp.h:299: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘aldbdimp.h:321: error: expected declaration specifiers or ‘...’ before ‘OCILobLocadbdimp.h:323: error: expected ‘)’ before ‘bufl’dbdimp.h:324: error: expected ‘)’ before ‘piece_size’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘OCIError’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘sword’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘sb4’dbdimp.h:341: error: expected ‘)’ before ‘status’dbdimp.h:342: error: expected ‘)’ before ‘mode’dbdimp.h:343: error: expected ‘)’ before ‘options’dbdimp.h:344: error: expected ‘)’ before ‘options’dbdimp.h:345: error: expected ‘)’ before ‘hdtype’dbdimp.h:346: error: expected ‘)’ before ‘attr’dbdimp.h:347: error: expected ‘)’ before ‘mode’dbdimp.h:350: error: expected ‘)’ before ‘attr’dbdimp.h:358: error: expected declaration specifiers or ‘...’ before ‘ub4’dbdimp.h:367: error: expected declaration specifiers or ‘...’ before ‘ub4’dbdimp.h:368: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ordbdimp.h:377: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dbdbdimp.h:379: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dbdbdimp.h:382: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘prdbdimp.h:391: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ordbdimp.h:392: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘reIn file included from Oracle.xs:1:Oracle.h:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘oraOracle.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘oraOracle.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘OCOracle.xs: In function ‘XS_DBD__Oracle__st_ora_stmt_type’:Oracle.xs:129: error: ‘imp_sth_t’ has no member named ‘stmt_type’Oracle.xs: In function ‘XS_DBD__Oracle__st_ora_stmt_type_name’:Oracle.xs:138: error: ‘imp_sth_t’ has no member named ‘stmt_type’
iii) Finally can start to compile by create a script named test.sh, additional 2 lines on top is required to set the environment right before compilation to produce the Oracle.pm module
[kyfoo@hostname~]$ cat test.sh
export LD_LIBRARY_PATH=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
export ORACLE_HOME-=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
perl -MCPAN -e 'install DBD::Oracle'
iv) Verify Oracle.pm is ready, it will be existed at /usr/local/lib64/perl5/DBD/Oracle.pm
- Now you can write the perl script to test the connectivity or download any example to try it.
No comments:
Post a Comment