사용자 도구

사이트 도구


develop:perl:oracle

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
develop:perl:oracle [2009/08/12 10:37]
starlits
develop:perl:oracle [2017/05/29 17:27] (현재)
starlits [DBD::Oracle 설치]
줄 1: 줄 1:
 ====== Perl + Oracle 연동 ====== ====== Perl + Oracle 연동 ======
-<code perl>+ 
 +===== 사전작업 ===== 
 +  - apt-get 을 이용하여 패키지 설치 <code> 
 +# apt-get install libdbi-test-perl libdbix-abstract-perl make 
 +</code> <code> 
 +# apt-get install python3 python-dev python3-dev \ 
 +     build-essential libssl-dev libffi-dev \ 
 +     libxml2-dev libxslt1-dev zlib1g-dev \ 
 +     python-pip 
 +</code> 
 + 
 +===== DBD::Oracle 설치 ===== 
 +  - http://cpan.org 에서 DBD::Oracle 모듈을 설치한다.  
 +  - http://search.cpan.org/~pythian/DBD-Oracle-1.74/lib/DBD/Oracle.pm  
 +  - 컴파일해서 설치한다. <code> 
 +$ perl Makefile.PL 
 +$ make 
 +$ sudo make install  
 +</code> 
 + 
 +===== Oracle Database Instant Client Installation ===== 
 +  - [[dbms:oracle:admin:instantclient | Oracle Database Instant Client Installation ]] 을 참고한다.  
 +===== sample code test ===== 
 +  - <code perl>
 #!/usr/bin/perl #!/usr/bin/perl
 # #
줄 24: 줄 47:
 #my $dbh = DBI->connect ("DBI:Oracle:host=$hostip;sid=$sid", $username, $password, \%attr); #my $dbh = DBI->connect ("DBI:Oracle:host=$hostip;sid=$sid", $username, $password, \%attr);
  
-my $que = "select itemcode from tb_item where rownum < 5"; +my $que = "select table_name from tabs where rownum < 5"; 
-my $itemcode;+my $table_name;
 # #
 my $sth = $dbh->prepare($que); my $sth = $dbh->prepare($que);
 $sth->execute() || die $sth->errstr; $sth->execute() || die $sth->errstr;
-while( ($itemcode) = $sth->fetchrow() ) { +while( ($table_name) = $sth->fetchrow() ) { 
-    print "select * from tb_studyunit where itemcode=$itemcode ;\n";+    print "$table_name\n";
 } }
 +
 $sth->finish(); $sth->finish();
  
develop/perl/oracle.1250041075.txt.gz · 마지막으로 수정됨: 2009/08/12 10:37 저자 starlits