====== Perl - DBD::Oracle ====== ===== 概要 ===== [[http://search.cpan.org/~timb/DBD-Oracle-1.26/Oracle.pm|CPAN - DBD::mysql]] :!:**DBIをあらかじめインストールしておくこと。** ===== 準備 ===== :!:**以下はMac OSX 10.6でのやり方。** ==== Instant Clientをインストールする ==== *[[http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html|Instant Client for Mac OSX(Intel x86)]] Basic All、JDBC、SQL*Plus、SDKの 4 つをダウンロードし、すべてのファイルを/Users/Shared/OracleInstantClientHome内にコピーする。\\ Macではlibclntsh.dylibというファイル名を使用するので下記コマンドを実行し、シンボリックリンクを作成する。 $ ln -s /Users/Shared/OracleInstantClientHome/libclntsh.dylib.10.1 \ /Users/Shared/OracleInstantClientHome/libclntsh.dylib tnsnames.oraファイルを用意し、/Users/Shared/OracleInstantClientHome内にコピーする。 ==== 環境変数を設定する ==== cd ~を実行してホームディレクトリに移動し、下記コマンドを実行する。 $ vi .bash_profile 以下の行を追加して保存し、ログインしなおす。 export ORACLE_HOME="/Users/Shared/OracleInstantClientHome" export DYLD_LIBRARY_PATH=$ORACLE_HOME export SQLPATH=$ORACLE_HOME export TNS_ADMIN=$ORACLE_HOME export NLS_LANG="Japanese_Japan.AL32UTF8" export PATH="$PATH:$DYLD_LIBRARY_PATH" これで環境設定はオッケー。 ==== DBD::Oracle をインストールする ==== *[[http://search.cpan.org/~timb/DBD-Oracle-1.26/|DBD::Oracle]] ターミナルからのCPAN操作ではうまくいかなかったので、手動でインストールする。\\ とりあえずMakefile.plを叩いてみると… $ perl Makefile.pl Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 37 Using DBI 1.615 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ Configuring DBD::Oracle for perl 5.010000 on darwin (darwin-thread-multi-2level) Remember to actually *READ* the README file! Especially if you have any problems. Installing on a darwin, Ver#10.0 Using Oracle in /Users/Shared/OracleInstantClientHome Can't find sqlplus. Pity, it would have helped. I'm having trouble finding your Oracle version number... trying harder WARNING: I could not determine Oracle client version so I'll just default to version 8.0.0.0. Some features of DBD::Oracle may not work. Oracle version based logic in Makefile.PL may produce erroneous results. You can use "perl Makefile.PL -V X.Y.Z" to specify a your client version. Oracle version 8.0.0.0 (8.0) DBD::Oracle no longer supports Oracle client versions before 9.2 Try a version before 1.25 for 9 and 1.18 for 8! at Makefile.PL line 168. なにやら嫌な感じのエラー。\\ よーく目を通してみると、Oracle Client Versionsが特定できないようなので、指示に従いバージョンを決め打ちしてやる。 $ perl Makefile.PL -V 10.2.0.4 Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 37 Using DBI 1.615 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ Configuring DBD::Oracle for perl 5.010000 on darwin (darwin-thread-multi-2level) Remember to actually *READ* the README file! Especially if you have any problems. Installing on a darwin, Ver#10.0 Using Oracle in /Users/Shared/OracleInstantClientHome Can't find sqlplus. Pity, it would have helped. Forcing Oracle version to be treated as 10.2.0.4 Oracle version 10.2.0.4 (10.2) Looks like an Instant Client installation, okay Your DYLD_LIBRARY_PATH env var is set to '/Users/Shared/OracleInstantClientHome' Oracle sysliblist: Found header files in /Users/Shared/OracleInstantClientHome/sdk/include. client_version=10.2 DEFINE= -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"10.2.0.4\" -DORA_OCI_102 Checking for functioning wait.ph System: perl5.010000 darwin b79.apple.com 10.0 darwin kernel version 10.0.0d8: tue may 5 19:29:59 pdt 2009; root:xnu-1437.2~2release_i386 i386 Compiler: gcc-4.2 -Os -arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include Linker: /usr/bin/ld Sysliblist: Linking with -lclntsh. LD_RUN_PATH=/Users/Shared/OracleInstantClientHome Using DBD::Oracle 1.26. Using DBD::Oracle 1.26. Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 1720 Using DBI 1.615 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ Writing Makefile for DBD::Oracle *** 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?) どうやら問題なさそうなので、このまま続行。 $ make $ sudo make install === Memo === ちなみに昔はPerlとDBD::Oracleの相性問題があり、パッチを当てて対処していた。 *[[http://hints.macworld.com/article.php?story=20061021211559813|参考サイト]]