=encoding euc-jp =head1 NAME =begin original DBI::FAQ -- The Frequently Asked Questions for the Perl5 Database Interface =end original DBI::FAQ -- Perl 5 データベースインターフェースに対するよくある質問 =for html
DBI Frequently Asked Questions v.0.38
Last updated: February 8th, 2000

=head1 SYNOPSIS perldoc DBI::FAQ =head1 VERSION =begin original This document is currently at version I<0.38>, as of I. =end original このドキュメントは現在 I<2000 年 2 月 8 日> のバージョン I<0.38> です。 =begin original That's B old. A newer FAQ can be found at L =end original これは B<とても> 古いです。 より新しい FAQ は L にあります。 =head1 DESCRIPTION =begin original This document serves to answer the most frequently asked questions on both the DBI Mailing Lists and personally to members of the DBI development team. =end original このドキュメントは DBI メーリングリストや DBI 開発チームのメンバーに 個人的によせられたもののうち、特に頻繁に訊ねられた質問に対する回答を 提供します。 =head1 Basic Information & Information Sources (基本的な情報と情報源) =head2 1.1 What is DBI, DBperl, Oraperl and *perl? (1.1 DBI、DBperl、Oraperl、*perl って何ですか?) =begin original To quote Tim Bunce, the architect and author of DBI: =end original DBI の設計者にして作者である Tim Bunce の言葉を借りれば: ``DBI is a database access Application Programming Interface (API) for the Perl Language. The DBI API Specification defines a set of functions, variables and conventions that provide a consistent database interface independant of the actual database being used.'' DBI は、Perl 言語のためのアプリケーション・プログラミング・インターフェース (API)です。DBI は関数、変数、規約などを定義し、実際に使われている データベースに依存しない一貫性のあるデータベース・インターフェースを 提供します。 =begin original In simple language, the DBI interface allows users to access multiple database types transparently. So, if you connecting to an Oracle, Informix, mSQL, Sybase or whatever database, you don't need to know the underlying mechanics of the 3GL layer. The API defined by DBI will work on I these database types. =end original 簡単にいえば、DBI インターフェースは複数のデータベース種類へ透過的に アクセスすることを可能にします。 そのため Oracle、informix、mSQL、Sybase などデータベースであればなんで あっても接続していれば、3GL レイヤでの仕組みについて知る必要はありません。 DBI で定義されてる API はすべてのこれら I<すべての> データベースで機能します。 =begin original A similar benefit is gained by the ability to connect to two I databases of different vendor within the one perl script, I, I want to read data from an Oracle database and insert it back into an Informix database all within one program. The DBI layer allows you to do this simply and powerfully. =end original 同じ様な利点として、二つの異なるベンダーの I<異なる> データベースに 一つのPerlスクリプトで接続できる、I<つまり> Oracle データベースから データを読み込み、Informix データベースに入れるのをやりたいといったことを 一つのプログラムで可能です。 DBI レイヤは簡単にそして強力にこれをできるようにします。 =for html Here's a diagram that demonstrates the principle:

[ DBI Architecture ]

=begin original I is the old name for the interface specification. It's usually now used to denote perlI<4> modules on database interfacing, such as, I, I, I and so on. These interfaces didn't have a standard API and are generally I supported. =end original I はインターフェース仕様の古い名前です。 今では普通 I, I, I などのような、 perlI<4> モジュールを示すために使われます。 これらのインタフェースは標準となる API を持っておらず、通常 I<サポートされていません>。 =begin original Here's a list of DBperl modules, their corresponding DBI counterparts and support information. I, the author's listed here generally I maintain the DBI module for the same database. These email addresses are unverified and should only be used for queries concerning the perl4 modules listed below. DBI driver queries should be directed to the I mailing list. =end original DBPerl モジュール、対応する DBI、そしてサポート情報の一覧を以下に示します。 この一覧にある作者が、通常、同じデータベースの DBI モジュールを メンテナンスしているというわけではないことに I<ご注意下さい>。 これらの E メールアドレスは未確認ですし、以下の一覧にある Perl4 モジュールに ついての問い合わせにだけ使って下さい。 DBI ドライバの問い合わせは I メーリングリストへお願いします。 Module Name Database Required Author DBI ----------- ----------------- ------ --- Sybperl Sybase Michael Peppler DBD::Sybase Oraperl Oracle 6 & 7 Kevin Stock DBD::Oracle Ingperl Ingres Tim Bunce & DBD::Ingres Ted Lemon Interperl Interbase Buzz Moschetti DBD::Interbase Uniperl Unify 5.0 Rick Wargo None Pgperl Postgres Igor Metz DBD::Pg Btreeperl NDBM John Conover SDBM? Ctreeperl C-Tree John Conover None Cisamperl Informix C-ISAM Mathias Koerber None Duaperl X.500 Directory Eric Douglas None User Agent =begin original However, some DBI modules have DBperl emulation layers, so, I comes with an Oraperl emulation layer, which allows you to run legacy oraperl scripts without modification. The emulation layer translates the oraperl API calls into DBI calls and executes them through the DBI switch. =end original しかしながら、いくつかの DBI モジュールは DBPerl エミュレーションレイヤを 持っています。 そのため I は Oraperl エミュレーションレイヤを提供しています。 これで古い oraperl スクリプトを修正なしに動かすことが出来ます。 エミュレーションレイヤは oraperl API 呼び出しを DBI 呼び出しに変換し、 DBI スイッチを通して実行します。 =begin original Here's a table of emulation layer information: =end original エミュレーションレイヤの一覧を以下の表に示します: Module Emulation Layer Status ------ --------------- ------ DBD::Oracle Oraperl Complete DBD::Informix Isqlperl Under development DBD::Ingres Ingperl Complete? DBD::Sybase Sybperl Working? ( Needs verification ) DBD::mSQL Msqlperl Experimentally released with DBD::mSQL-0.61 =begin original The I emulation is a special case. I is a perl5 driver for I databases, but does not conform to the DBI Specification. It's use is being deprecated in favour of I. I may be downloaded from CPAN I: =end original I エミュレーションは特殊なケースです。 I は I データベースのための Perl5 ドライバですが、DBI 仕様に 従っていません。 これを使うことは I の利点に反しています。 I は CPAN の I<このアドレス> からダウンロードすることができます: http://www.perl.com/cgi-bin/cpan_mod?module=Msqlperl =head2 1.2. Where can I get it from? (1.2. どこで手に入りますか?) =begin original The Comprehensive Perl Archive Network resources should be used for retrieving up-to-date versions of the DBI and drivers. CPAN may be accessed I Tom Christiansen's splendid I program located at: =end original Comprehensive Perl Archive Network リソースが、DBI とドライバの 最新バージョンが取得されるために使えます。 CPAN には、以下のアドレスにある Tom Christiansen のすばらしい I プログラムを I<通じても> アクセスすることができます: http://www.perl.com/CPAN/ =begin original For more specific version information and exact URLs of drivers, please see the DBI drivers list and the DBI module pages which can be found on: =end original 特定のバージョン情報とドライバの正確な URL については、以下のアドレスにある DBI ドライバ一覧と DBI モジュールページをご覧下さい: http://dbi.perl.org/ http://www.symbolstone.org/technology/perl/DBI =begin original This list is automatically generated on a nightly basis from CPAN and should be up-to-date. =end original このリストは毎日、CPAN からの情報をベースに自動的に生成され、更新されます。 =head2 1.3. Where can I get more information? (1.3. さらに詳しい情報はどこで手に入りますか?) =begin original There are a few information sources on DBI. =end original DBI についてはいくつかの情報源があります。 =over 4 =item I<"Programming the Perl DBI"> (I<「入門 Perl DBI」>) =begin original "Programming the Perl DBI" is the I book on the DBI written by Alligator Descartes and Tim Bunce and published by O'Reilly & Associates. The book was released on February 9th, 2000. =end original "Programming the Perl DBI'' (和訳:「入門 Perl DBI」)は Alligator Descartes と Tim Bunce によって書かれ、O'Reilly & Associates から出版された DBI についての I<公式な> 本です。 この本は 2000年 2 月 9 日に出版されました。 =begin original The table of contents is: =end original 目次は以下のようになっています: Preface 1. Introduction From Mainframes to Workstations Perl DBI in the Real World A Historical Interlude and Standing Stones 2. Basic Non-DBI Databases Storage Managers and Layers Query Languages and Data Functions Standing Stones and the Sample Database Flat-File Databases Putting Complex Data into Flat Files Concurrent Database Access and Locking DBM Files and the Berkeley Database Manager The MLDBM Module Summary 3. SQL and Relational Databases The Relational Database Methodology Datatypes and NULL Values Querying Data Modifying Data Within Tables Creating and Destroying Tables 4. Programming with the DBI DBI Architecture Handles Data Source Names Connection and Disconnection Error Handling Utility Methods and Functions 5. Interacting with the Database Issuing Simple Queries Executing Non-SELECT Statements Binding Parameters to Statements Binding Output Columns do() Versus prepare() Atomic and Batch Fetching 6. Advanced DBI Handle Attributes and Metadata Handling LONG/LOB Data Transactions, Locking, and Isolation 7. ODBC and the DBI ODBC -- Embraced and Extended DBI -- Thrashed and Mutated The Nuts and Bolts of ODBC ODBC from Perl The Marriage of DBI and ODBC Questions and Choices Moving Between Win32::ODBC and the DBI And What About ADO? 8. DBI Shell and Database Proxying dbish -- The DBI Shell Database Proxying A. DBI Specification B. Driver and Database Characteristics C. ASLaN Sacred Site Charter Index =begin original The book should be available from all good bookshops and can be ordered online either via O'Reilly & Associates =end original この本はすべての大きな書店で手に入れることができます。 また I<以下の> サイトからオンラインで注文することができます。 http://www.oreilly.com/catalog/perldbi =begin original or Amazon =end original または Amazon から http://www.amazon.com/exec/obidos/ASIN/1565926994/dbi =item I (I) =begin original Is are chunks of documentation usually embedded within perl programs that document the code ``I'', providing a useful resource for programmers and users of modules. POD for DBI and drivers is beginning to become more commonplace, and documentation for these modules can be read with the C program included with Perl. =end original I は文書の固まりで、いつもは Perl プログラムのコードの 「I<その場>」に文書があり、埋め込まれています。 モジュールのプログラマやユーザに役に立つ資源を提供します。 DBI とドライバのための POD はごくありふれたものになってきています。 そしてこれらのモジュールの文書は Perl に入っている C プログラムで 読むことが出来ます。 =over 4 =item The DBI Specification (DBI の仕様) =begin original The POD for the DBI Specification can be read with the: =end original DBI 仕様の POD は以下のコマンドで読むことが出来ます: perldoc DBI =begin original command. The Specification also forms Appendix A of "Programming the Perl DBI". =end original 仕様は "Programming the Perl DBI" の付録 A にも載っています。 =item Oraperl =begin original Users of the Oraperl emulation layer bundled with I, may read up on how to program with the Oraperl interface by typing: =end original I に同梱されている Oraperl エミュレーションレイヤのユーザは、 以下のようにタイプすることで Oraperl インターフェースでどのように プログラムするかを読むことが出来ます: perldoc Oraperl =begin original This will produce an updated copy of the original oraperl man page written by Kevin Stock for perl4. The oraperl API is fully listed and described there. =end original これは Kevin Stock が書いた Perl4 のための元の oraperl man ページの 更新されたコピーを生成します。 oraperl API がすべて表示され、説明がされます。 =item Drivers =begin original Users of the DBD modules may read about some of the private functions and quirks of that driver by typing: =end original DBD モジュールのユーザはプライベートな関数やそのドライバの癖を以下のように タイプすることで読むことが出来ます: perldoc =begin original For example, the I driver is bundled with driver-specific documentation that can be accessed by typing =end original 例えば I ドライバは、以下のようにタイプすると アクセスすることができるドライバ独自のドキュメントと一緒に提供されています。 perldoc DBD::mSQL =item Frequently Asked Questions =begin original This document, the I is also available as POD documentation! You can read this on your own system by typing: =end original このドキュメント、I<よくある質問> は POD ドキュメントとしても使えます! あなたのシステムで以下のようにタイプすると読むことが出来ます: perldoc DBI::FAQ =begin original This may be more convenient to persons not permanently, or conveniently, connected to the Internet. The I module should be downloaded and installed for the more up-to-date version. =end original これは常に、または簡単にインターネットに接続できない人にとってはより 便利かもしれません。 I モジュールはより新しいバージョンのためにダウンロードされ インストールされなければなりません。 =begin original The version of I shipped with the C module may be slightly out of date. =end original C モジュールと一緒に入る I はちょっとだけ古いかもしれません。 =item POD in general (一般的な POD) =begin original Information on writing POD, and on the philosophy of POD in general, can be read by typing: =end original POD の書き方、POD 一般の原則は以下のようにタイプすることにより 読むことが出来ます: perldoc perlpod =begin original Users with the Tk module installed may be interested to learn there is a Tk-based POD reader available called C, which formats POD in a convenient and readable way. This is available I CPAN as the module called I and is highly recommended. =end original Tk モジュールをインストールしているユーザは、C という Tk を ベースとした POD リーダが使えることを聞いて興味をもつかもしれません。 これは簡単に読める形に POD を整形します。 I と呼ばれるモジュールとしてCPANを I<通じて> 使うことが出来ます; これを強くお勧めします。 =back =item I (I<ドライバとデータベースの特徴>) =begin original The driver summaries that were produced for Appendix B of "Programming the Perl DBI" are available online at: =end original "Programming the Perl DBI" の Appendix B のために作成されたドライバの要約が 以下のサイトからオンラインで利用できます: http://dbi.perl.org/ http://www.symbolstone.org/technology/perl/DBI =begin original in the driver information table. These summaries contain standardised information on each driver and database which should aid you in selecting a database to use. It will also inform you quickly of any issues within drivers or whether a driver is not fully compliant with the DBI Specification. =end original のドライバ情報テーブルにあります。 これらの要約には利用するデータベースを選ぶときに助けになるであろう、 各ドライバとデータベースについての標準化された情報が入っています。 ドライバでの論点やドライバが DBI 仕様と十分に互換性がないといったことを 簡単に知らせもします。 =item I (I<雑談、ちょっとしたニュース、評論>) http://dbi.perl.org/tidbits http://www.symbolstone.org/technology/perl/DBI/tidbits =begin original There are a series of occasional rambles from various people on the DBI mailing lists who, in an attempt to clear up a simple point, end up drafting fairly comprehensive documents. These are quite often varying in quality, but do provide some insights into the workings of the interfaces. =end original 簡単な点をはっきりさせようとしたり、最新のドキュメントの草案を完璧に 仕上げようとする DBI メーリングリストでのたくさんの人たちからの、その時々の 一連の雑談があります。 かなりのばらつきがありますが、インターフェースの作業に洞察力を与えています。 =item I (I<記事>) =begin original A list of articles discussing the DBI can be found on the DBI WWW page at: =end original DBI について書かれた記事のリストが DBI WWW ページから見ることができます: http://dbi.perl.org/ http://www.symbolstone.org/technology/perl/DBI =begin original These articles are of varying quality and age, from the original Perl Journal article written by Alligator and Tim, to more recent debacles published online from about.com. =end original これらの記事は Alligator と Tim によって書かれた Perl Journal 記事から、 より最近の about.com からオンラインで流れた大失敗まで、年代も品質も バラつきがあります。 =item I (I) =begin original The I files included with each driver occasionally contains some useful information ( no, really! ) that may be pertinent to the user. Please read them. It makes our worthless existences more bearable. These can all be read from the main DBI WWW page at: =end original 各ドライバに入っている README ファイルには、時々(じゃなかった、本当に!) 役に立つ情報が入っています。 これはユーザにはぴったりかもしれません。 それをお読みください。 これのおかげで、役に立たない我々の存在が少しはましにしてくれます。 これらはメインの DBI WWW ページからすべて読むことができます: http://dbi.perl.org/ http://www.symbolstone.org/technology/perl/DBI =item I (I<メーリングリスト>) =begin original There are three mailing lists for DBI: =end original DBI のためのメーリングリストが三つあります。 dbi-announce@perl.org -- for announcements, very low traffic dbi-users@perl.org -- general user support dbi-dev@perl.org -- for driver developers (no user support) =begin original For information on how to subscribe, set digest mode etc, and unsubscribe, send an email message (the content will be ignored) to: =end original 購読、ダイジェストモードなどの設定、購読解除のための情報は、 次に E メールを送って下さい (本文は無視されます): dbi-announce-help@perl.org dbi-users-help@perl.org dbi-dev-help@perl.org =item I =over 4 =item I http://outside.organic.com/mail-archives/dbi-users/ =begin original Searchable hypermail archives of the three mailing lists, and some of the much older traffic have been set up for users to browse. =end original 三つのメーリングリストの検索可能な hypermail アーカイブと かなり古いトラフィックでも閲覧できるようになっているものもあります。 =item I http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest =begin original As per the US archive above. =end original 上記の US archive と同じ。 =back =back =head1 Compilation Problems (コンパイルでの問題) =head2 2.1. Compilation problems or "It fails the test!" (2.1. コンパイルでの問題または「テストが失敗する!」) =begin original First off, consult the README for that driver in case there is useful information about the problem. It may be a known problem for your given architecture and operating system or database. You can check the README files for each driver in advance online at: =end original まず最初に、そのドライバの README をみて、その問題に役に立つ情報がないか 調べてください。 あなたのアーキテクチャとオペレーティング・システムまたはデータベースでは 既知のバグかもしれません。 あらかじめオンラインにある README ファイルをチェックすることもできます: http://dbi.perl.org/ http://www.symbolstone.org/technology/perl/DBI =begin original If it's a known problem, you'll probably have to wait till it gets fixed. If you're I needing it fixed, try the following: =end original 既知のバグであれば、たぶん修正されるまで待つべきでしょう。 もし本当にそれを修正する必要があるのであれば、以下のことに 挑戦してみてください。 =over 4 =item I (I<自分で修正してみる>) =begin original This technique is generally I recommended to the faint-hearted. If you do think you have managed to fix it, then, send a patch file ( context diff ) to the author with an explanation of: =end original この方法は気の弱い方には普通、お勧めしません。 本当に修正がうまくいったと思ったならば、パッチファイル(context diff)を 以下の説明と一緒に作者へ送ってください: =over 4 =item * =begin original What the problem was, and test cases, if possible. =end original 何が問題だったか、そしてできればテストケース。 =item * =begin original What you needed to do to fix it. Please make sure you mention everything. =end original それを修正するために何が必要だったもの。 すべてを書いたか確認してください。 =item * =begin original Platform information, database version, perl version, module version and DBI version. =end original プラットホーム情報、データベースのバージョン、Perl のバージョン、 モジュールのバージョン、DBI のバージョン。 =back =item I Do I whinge! 作者にEメールする 泣き言はやめて! =begin original Please email the address listed in the WWW pages for whichever driver you are having problems with. Do I directly email the author at a known address unless it corresponds with the one listed. =end original 障害があるドライバの WWW ページに記載されているアドレスに E メールしてください。 記載されているものに対応していなければ知っている作者のアドレス直接 E メールするのは I<やめてください>。 =begin original We tend to have real jobs to do, and we do read the mailing lists for problems. Besides, we may not have access to > and couldn't be of any assistance anyway! Apologies for sounding harsh, but that's the way of it! =end original 我々はやらなければならない本来の仕事を持っていることが多く、障害のための メーリングリストをきちんと読んでいます。 それに > にはアクセスしたこともないかもしれませんし、なんの助けにも ならないかもしれません。 厳しく聞こえることは謝りますが、しかしそういうものなのです! =begin original However, you might catch one of these creative genii at 3am when we're doing this sort of stuff anyway, and get a patch within 5 minutes. The atmosphere in the DBI circle is that we I appreciate the users' problems, since we work in similar environments. =end original しかし我々がボケっとしている夜中の 3 時に、あなたが創造の妖精を 捕まえることができるかもしれません。 そして 5 分以内にパッチをとることができるかもしれません。 我々は同じような環境で働いているので、DBI サークルではユーザの障害を正しく 認識しようとする雰囲気が I<あります>。 =begin original If you are planning to email the author, please furnish as much information as possible, I: =end original 作者に E メールしようとするならば、なるべく多くの情報を伝えてください。 I<つまり>: =over 4 =item * =begin original I the information asked for in the README file in the problematic module. And we mean I of it. We don't put lines like that in documentation for the good of our health, or to meet obscure README file standards of length. =end original 問題になっているモジュールのREADMEファイルで尋ねられている情報のすべて。 我々はその I<全て> を意図しています。 我々の健康のためとか、よくわからない README ファイルを標準の長さに 合わせるために、われわれはそのドキュメントにそれらの行を 入れてはいないのです。 =item * =begin original If you have a core dump, try the I module for generating a stack trace from the core dump. Send us that too. I can be found on CPAN at: =end original コアダンプがあれば、コアダンプからスタックトレースを生成するために I モジュールを試してみてください。 これも送ってください。 I は CPAN の以下のところにあります: http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack =item * =begin original Module versions, perl version, test cases, operating system versions and I. =end original モジュールのバージョン、Perl のバージョン、テストケース、 オペレーティングシステムのバージョン、そして I<関連するほかのすべての情報>。 =back =begin original Remember, the more information you send us, the quicker we can track problems down. If you send us no useful information, expect nothing back. =end original 送る情報が多いほど、より早く問題を追いかけることができることを 忘れないでください。 役に立つ情報を送らなければ、何も返ってこないと思ってください。 =begin original Finally, please be aware that some authors, including Tim Bunce, specifically request that you do I mail them directly. Please respect their wishes and use the email addresses listed in the appropriate module C file. =end original 最後に、Tim Bunce も含めて、作者によっては直接メール I<しない> ように特に 要望している人もいることに注意してください。 彼らの要望を尊重し、対応するモジュールの C ファイルに載っている E メールアドレスを使ってください。 =item I (I) =begin original It's usually a fairly intelligent idea to I the mailing list anyway with problems. The authors all read the lists, so you lose nothing by mailing there. =end original 何か問題があったらメーリングリストに I することは通常、とても賢明な 考えです。 作者は全員このリストを読みます。 そのためそこへメールすることによって何も失うことはありません。 =back =head1 Platform and Driver Issues (プラットフォームとドライバについて) =head2 3.1 What's the difference between ODBC and DBI? (3.1 ODBCとDBIは何が違うのですか?) =begin original In terms of architecture - not much: Both define programming interfaces. Both allow multiple drivers to be loaded to do the actual work. =end original アーキテクチャの面からいえばあまり大きな違いはありません。 両方ともプログラミングインターフェースを定義していますし、実際に機能のために 複数のドライバをロードすることを可能にしています。 =begin original In terms of ease of use - much: The DBI is a 'high level' interface that, like Perl itself, strives to make the simple things easy while still making the hard things possible. The ODBC is a 'low level' interface. All nuts-bolts-knobs-and-dials. =end original 使いやすさの面からいえば大きく違います: DBI は Perl 自身のような「上位レベル」インターフェースです。 難しいことを可能としながら、単純なことを簡単にしようとしています。 ODBC は「下位レベル」インターフェースです。 全て(ナットにボルトにノブに文字盤といった=All nuts-bolts-knobs-and-dials) 基本的な部品です。 =begin original Now there's an ODBC driver for the DBI (DBD::ODBC) the "What's the difference" question is more usefully rephrased as: =end original いまや DBI のための ODBC ドライバ (DBD::ODBC) もあります。 「何が違うの?」という質問は次の質問としてより多く繰り返されています: =begin original Chapter 7 of "Programming the Perl DBI" covers this topic in far more detail and should be consulted. =end original "Programming the Perl DBI'' の Chapter 7 は、この話題についてさらに詳細に カバーしていますのでご覧になってください。 =head2 3.2 What's the difference between Win32::ODBC and DBD::ODBC? (3.2 Win32::ODBC と DBD::ODBC は何が違うのですか?) =begin original The DBI, and thus DBD::ODBC, has a different philosophy from the Win32::ODBC module: =end original DBI つまり DBD::ODBC は、Win32::ODBC とは違う原理を持っています。 =begin original The Win32::ODBC module is a 'thin' layer over the low-level ODBC API. The DBI defines a simpler 'higher level' interface. =end original Win32::ODBC モジュールは下位レベルの ODBC API をカバーする「薄い」層です。 DBI はより簡単で「より上位のレベル」のインタフェースを定義します。 =begin original The Win32::ODBC module gives you access to more of the ODBC API. The DBI and DBD::ODBC give you access to only the essentials. (But, unlike Win32::ODBC, the DBI and DBD::ODBC do support parameter binding and multiple prepared statements which reduces the load on the database server and can dramatically increase performance.) =end original Win32::ODBC モジュールはより多くの ODBC API へアクセスできるようにします。 DBI と DBD::ODBC は基本的なものだけにアクセスできるようにします。 (しかし Win32::ODBC とは違って DBI と DBD::ODBC は、データベースサーバの 負荷を減らし、劇的にパフォーマンスを向上させるパラメータの結びつけや 複数の準備(prepare)されたステートメントをサポートしています。) =begin original The Win32::ODBC module only works on Win32 systems. The DBI and DBD::ODBC are very portable and work on Win32 and Unix. =end original Win32::ODBC モジュールは Win32 システムでしか動きません。 DBI と DBD::ODBC は非常に移植性が高く、Win32 でも Unix でも動きます。 =begin original The DBI and DBD::ODBC modules are supplied as a standard part of the Perl 5.004 binary distribution for Win32 (they don't work with the older, non-standard, ActiveState port). =end original DBI と DBD::ODBC モジュールは Win32 のための Perl5.004 バイナリ ディストリビューションの標準部分として提供されます。 (古くて、標準ではない ActiveState 版では動きません) (訳者注: ActiveState でも DBI と一部の DBD が提供されています。 ただし古いバージョンのこともあります。) =begin original Scripts written with the DBI and DBD::ODBC are faster than Win32::ODBC on Win32 and are trivially portable to other supported database types. =end original DBI と DBD::ODBC を使って書かれたスクリプトは Win32 上で Win32::ODBC よりも 速く動き、サポートされている他のデータベースタイプへ簡単に移行できます。 =begin original The DBI offers optional automatic printing or die()ing on errors which makes applications simpler and more robust. =end original DBI はオプションでエラー時の自動的出力や die() することを提供することで、 アプリケーションをより単純に、より堅牢にします。 =begin original The current DBD::ODBC driver version 0.16 is new and not yet fully stable. A new release is due soon [relative to the date of the next TPJ issue :-] and will be much improved and offer more ODBC functionality. =end original 現在 DBD::ODBC ドライバはバージョン 0.16 は新しく、完全に安定は していません。 新しいリリースでは [次の TPJ が出版されるの日と比べて :-] すぐに 対応つもりです、そしてより進化し、より多くの ODBC 機能を提供します。 =begin original To summarise: The Win32::ODBC module is your best choice if you need access to more of the ODBC API than the DBI gives you. Otherwise, the DBI and DBD::ODBC combination may be your best bet. =end original まとめると: DBI が提供しているよりも多くの ODBC API にアクセスする必要が あれば、Win32::ODBC モジュールがベストな選択です。 そうでなければ DBI と DBD::ODBC の組み合わせが一番でしょう。 =begin original Chapter 7 of "Programming the Perl DBI" covers this topic in far more detail and should be consulted. =end original "Programming the Perl DBI" の Chapter 7 は、この話題についてさらに 詳細にカバーしていますのでご覧になってください。 =head2 3.3 Is DBI supported under Windows 95 / NT platforms? (3.3 DBI は Windows95/NT プラットホームでもサポートされていますか?) =begin original Finally, yes! Jeff Urlwin has been working diligently on building I and I under these platforms, and, with the advent of a stabler perl and a port of I, the project has come on by great leaps and bounds. =end original ついにそうなりました! Jeff Urlwin がこれらのフォーマットでの I と I の 構築のためにこつこつと働いてきました。 そしてより安定した Perl と I がついに出来ました。 プロジェクトは飛躍的に進行しています。 =begin original The I and I Win32 ports are now a standard part of DBI, so, downloading I of version higher than I<0.81> should work fine as should using the most recent I version. =end original Win32 版の I と I は標準の DBI の一部となりました。 そのためバージョン I<0.81> 以降の I をダウンロードするとより新しい I バージョンを使うことになります。 =head2 3.4 Can I access Microsoft Access or SQL-Server databases with DBI? (3.4 DBI で Microsoft Access やSQL-Server にアクセスできますか?) =begin original Yes, use the I driver. =end original はい、I ドライバを使って下さい。 =head2 3.5 Is there a DBD for >? (3.5 > というデータベースのためのDBDはありますか?) =begin original First check if a driver is available on CPAN by searching for the name of the database (including common abbreviations and aliases). =end original データベースの名前 (およびよくある略称と別名) で検索することで、 ドライバが CPAN で利用可能かをまずチェックしてください。 =begin original Here's a general query that'll match all distributions: =end original 以下は全ての配布にマッチングする一般的なクエリです: http://search.cpan.org/search?query=DBD&mode=dist =begin original If you can't find a driver that way, you could check if the database supports ODBC drivers. If so then you could probably use the DBD::ODBC driver: =end original この方法でドライバを見つけられなかった場合、データベースが ODBC ドライバに 対応しているかをチェックしてください。 もしそうなら、おそらく DBD:: ODBC ドライバを使えます: http://search.cpan.org/dist/DBD-ODBC/ =begin original If not, then try asking on the dbi-users mailing list. =end original そうでなければ、dbi-users メーリングリストで質問してみてください。 =head2 3.6 What's DBM? And why should I use DBI instead? (3.6 DBMって何ですか?なぜその代わりにDBIを使わなければならないのですか?) =begin original Extracted from ``I'': =end original "DBI - The Database Interface for Perl 5''からの抜粋: =begin original ``UNIX was originally blessed with simple file-based ``databases'', namely the dbm system. dbm lets you store data in files, and retrieve that data quickly. However, it also has serious drawbacks. File Locking The dbm systems did not allow particularly robust file locking capabilities, nor any capability for correcting problems arising through simultaneous writes [ to the database ]. Arbitrary Data Structures The dbm systems only allows a single fixed data structure: key-value pairs. That value could be a complex object, such as a [ C ] struct, but the key had to be unique. This was a large limitation on the usefulness of dbm systems. However, dbm systems still provide a useful function for users with simple datasets and limited resources, since they are fast, robust and extremely well-tested. Perl modules to access dbm systems have now been integrated into the core Perl distribution via the AnyDBM_File module.'' =end original 「UNIXには簡単なファイルベースの「データベース」があります。 名前を dbm システムといいます。 dbmにより、データをファイルに格納したり、データを早く取り出したり することができます。 しかし、それには重要な欠点も持っています。 ファイルロック dbm システムは特に強力なファイルロックを許していませんし、 [データベースへの] 同時書き込みにより発生する問題を修正する能力もありません。 任意のデータ構造 dbm システムは一つのキーと値の組という決まったのデータ構造だけを 許します。 値は [C] の構造体のように、複雑なオブジェクトにもすることが できますが、キーはユニークでなければなりません。 これは dbm システムの使い勝手には大きな制限です。 しかし、dbm システムは、早く強力で非常によくテストされているので、 簡単なデータセットと限られたリソースでユーザに便利な機能を 提供しています。 dbm システムにアクセスするための Perl モジュールは AnyDBM_File モジュールを通じて、 コアPerl配布セットに統合されています。」 =begin original To sum up, DBM is a perfectly satisfactory solution for essentially read-only databases, or small and simple datasets. However, for more scaleable dataset handling, not to mention robust transactional locking, users are recommended to use a more powerful database engine I I. =end original 要するに、DBM は基本的にリードオンリーのデータベース、または簡単な データセットを完全に満足させる解決法です。 しかし強力なトランザクション的なロックはいうまでもなく、より スケーラブルなデータセット操作のためには、ユーザに I を I<通じて> より 強力なデータベースエンジンを使うことをお勧めします。 =begin original Chapter 2 of "Programming the Perl DBI" discusses DBM files in detail. =end original "Programming the Perl DBI" の Chapter 2 は、DBM ファイルについて詳しく 述べています。 =head2 3.7 What database do you recommend me using? (3.7 どのデータベースがお勧めですか?) =begin original This is a particularly thorny area in which an objective answer is difficult to come by, since each dataset, proposed usage and system configuration differs from person to person. =end original 各データセット、計画される使用法そしてシステム構成が人によって違うので、 目指している答えが出しにくく特に難しい領域です。 =begin original From the current author's point of view, if the dataset is relatively small, being tables of less than 1 million rows, and less than 1000 tables in a given database, then I is a perfectly acceptable solution to your problem. This database is extremely cheap, is wonderfully robust and has excellent support. More information is available on the Hughes Technology WWW site at: =end original 現在の著者の視点からは、データセットが比較的小さく、テーブルが 100 万行よりも小さく、データベースのテーブル数が 1000 よりも少なければ、 I は完璧に受け入れられるあなたの問題の解決法でしょう。 このデータベースは非常に安く、とても強力で、すぐれたサポートを持っています。 さらに詳しい情報が、以下の Hughes Technology WWW サイトにあります: http://www.hughes.com.au =begin original You may also wish to look at MySQL which is a more powerful database engine that has a similar feel to mSQL. =end original より強力なデータベースエンジンで mSQL と同じような感じの MySQL を 見ることを望むかもしれません: http://www.tcx.se =begin original If the dataset is larger than 1 million row tables or 1000 tables, or if you have either more money, or larger machines, I would recommend I. Oracle's WWW site is an excellent source of more information. =end original データセットが 100 万行よりも大きいかテーブル数が 1000 より多ければ、 あるいはよりお金を持っているか、より大きなマシンを持っていれば、 I をお勧めします。 Oracle の WWW サイトはさらなる情報のすぐれた情報源です。 http://www.oracle.com =begin original I is another high-end RDBMS that is worth considering. There are several differences between Oracle and Informix which are too complex for this document to detail. Information on Informix can be found on their WWW site at: =end original I は、考えるの価値があるもう一つのハイエンドな RDBMS です。 Oracle と Informix とはさまざまな違いがあり、あまりにも複雑なのでこの文書で 詳しく述べることはできません。 Informix の情報は以下の WWW サイトで見つかります: http://www.informix.com =begin original In the case of WWW fronted applications, I may be a better option due to slow connection times between a CGI script and the Oracle RDBMS and also the amount of resource each Oracle connection will consume. I is lighter resource-wise and faster. =end original WWW フロントエンドアプリケーションの場合、CGI スクリプトと Oracle RDBMS との接続時間の遅さや、各 Oracle の接続が消費するリソースの 量から I がよい選択かもしれません。 I はより軽く、少ないリソースでより速く動きます。 =begin original These views are not necessarily representative of anyone else's opinions, and do not reflect any corporate sponsorship or views. They are provided I. =end original この意見は、他の人の意見を何も代表しませんし、いかなる企業の スポンサーシップや意見も反映していません。 まさに I<そのまま> です。 =head2 3.8 Is > supported in DBI? (3.8 > という機能は DBI でサポートされていますか?) =begin original Given that we're making the assumption that the feature you have requested is a non-standard database-specific feature, then the answer will be I. =end original あなたが要求している機能が標準でない、データベース特有の機能であれば、 答えは I<ノー> でしょう。 =begin original DBI reflects a I API that will work for most databases, and has no database-specific functionality. =end original DBI は、ほとんどのデータベースで動く I<汎用的な> API を反映しており、 データベース特有の機能は持っていません。 =begin original However, driver authors may, if they so desire, include hooks to database-specific functionality through the C method defined in the DBI API. Script developers should note that use of functionality provided I the C methods is very unlikely to be portable across databases. =end original しかし、ドライバの作者は、もし彼らがそう望むのであれば、DBI API の中で 定義されている C メソッドを通じて、データベース特有の機能を 呼び出すための仕組みを入れることができます。 スクリプト開発者は C メソッドを通じて提供される機能を使うことは、 データベースをまたがった移植ができないだろうということに注意して下さい。 =head1 Programming Questions (プログラムについての質問) =head2 4.1 Is DBI any use for CGI programming? (4.1 DBIはCGIプログラムに使えますか?) =begin original In a word, yes! DBI is hugely useful for CGI programming! In fact, I would tentatively say that CGI programming is one of two top uses for DBI. =end original 一言で言えば、「イエス」です! DBI は CGI プログラムではとても便利です! 事実、CGI プログラムは DBI の主要な使い道の二つのうちの一つだともいえます。 =begin original DBI confers the ability to CGI programmers to power WWW-fronted databases to their users, which provides users with vast quantities of ordered data to play with. DBI also provides the possibility that, if a site is receiving far too much traffic than their database server can cope with, they can upgrade the database server behind the scenes with no alterations to the CGI scripts. =end original DBI は CGI プログラマにユーザへの WWW をフロントとしたデータベースのための 能力を与えます。 それはユーザがそれを使うことが出来るように手入れの行き届いた膨大な量の データを提供します。 もしサイトがデータベースサーバが対処可能な量よりも遙かに多くの トラフィックを受け取るならば、CGI スクリプトを何も変更することなく、 データベースサーバをアップグレードすることも、DBI は可能にします。 =head2 4.2 How do I get faster connection times with DBD::Oracle and CGI? 4.2 DBD::Oracle と CGI との接続はどのようにすれば速くなりますか? Contributed by John D. Groenveld =begin original The Apache C maintains a pool of C children to service client requests. =end original Apache C はクライアント要求のサービスのために C の子供の プールを保持します。 =begin original Using the Apache I module by I, the perl interpreter is embedded with the C children. The CGI, DBI, and your other favorite modules can be loaded at the startup of each child. These modules will not be reloaded unless changed on disk. =end original I の Apache I モジュールを使うと、 perl インタープリタは C の子供に埋め込まれます。 CGI、DBI、その他の好きなモジュールを各子供が起動する時点で ロードすることができます。 これらのモジュールはディスク上で変更されない限り再ロードされません。 =begin original For more information on Apache, see the Apache Project's WWW site: =end original Apache についてのさらなる情報は、Apache Project の WWW サイトをご覧下さい: http://www.apache.org =begin original The I module can be downloaded from CPAN I: =end original I モジュールは、CPAN の以下のアドレス I<から> ダウンロードできます: http://www.perl.com/cgi-bin/cpan_mod?module=Apache =head2 4.3 How do I get persistent connections with DBI and CGI? (4.3 DBIとCGIを接続したままにするにはどうすればよいですか?) Contributed by John D. Groenveld =begin original Using Edmund Mergl's I module, database logins are stored in a hash with each of these C child. If your application is based on a single database user, this connection can be started with each child. Currently, database connections cannot be shared between C children. =end original Edmund Mergl の I モジュールを使うと、データベースへの ログインは C の子供それぞれのハッシュに格納されます。 もしあなたのアプリケーションが一つのデータベースユーザをベースにしていたら、 この接続は各子供によって開始されます。 現在、データベース接続は C の子供の間で共有することはできません。 =begin original I can be downloaded from CPAN I: =end original I はCPANの以下のアドレス I<から> ダウンロードできます。 http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI =head2 4.4 ``When I run a perl script from the command line, it works, but, when I run it under the C, it fails!'' Why? (4.4 「コマンドラインでは動くのに、C からでは失敗します!」なぜ?) =begin original Basically, a good chance this is occurring is due to the fact that the user that you ran it from the command line as has a correctly configured set of environment variables, in the case of I, variables like C, C or C. =end original 基本的に、これはそれをコマンドラインから実行したときユーザは、 I の場合であれば C, C, C といった環境変数が正しく設定されていたために 発生するということがよくあります。 =begin original The C process usually runs under the user id of C, which implies there is no configured environment. Any scripts attempting to execute in this situation will correctly fail. =end original Cプロセスは通常、何も環境変数が設定されていない C ユーザ ID の下で起動されます。 この状況のもとでスクリプトを実行しようとしても失敗するでしょう。 =begin original One way to solve this problem is to set the environment for your database in a C block at the top of your script. Another technique is to configure your WWW server to pass-through certain environment variables to your CGI scripts. =end original この問題を解決する方法の一つとして、あなたのスクリプトの最初で、 C ブロックのなかでデータベースのための環境を 設定することがあります。 もう一つの方法としては、WWW サーバをあなたのCGIスクロプトにある 環境変数を渡すように設定することです。 =begin original Similarly, you should check your C error logfile for any clues, as well as the ``Idiot's Guide To Solving Perl / CGI Problems'' and ``Perl CGI Programming FAQ'' for further information. It is unlikely the problem is DBI-related. =end original 同時に、手がかりを求めて C エラーログファイルや、より詳細な 情報のために「Idiot's Guide To Solving Perl / CGI Problems'」と 「Perl CGI Programming FAQ」もチェックするべきです。 これは DBI 関連の問題ではないようです。 =begin original The ``Idiot's Guide To Solving Perl / CGI Problems'' can be located at: =end original 「Idiot's Guide To Solving Perl / CGI Problems'」は以下のアドレスにあります: http://www.perl.com/perl/faq/index.html =begin original as can the ``Perl CGI Programming FAQ''. Read I these documents carefully! =end original 「Perl CGI Programming FAQ」もここにあります。 これらの文書を I<両方とも> 注意深く読んで下さい! =head2 4.5 How do I get the number of rows returned from a C ステートメントから返される行の数はどのように取得できますか?) =begin original Count them. Read the DBI docs for the C method. =end original 数えて下さい。 DBIのドキュメントで C メソッドを読んで下さい。 =head1 Miscellaneous Questions (その他の質問) =head2 5.1 Can I do multi-threading with DBI? (5.1 DBIでマルチスレッドはできますか?) =begin original Perl version 5.005 and later can be built to support multi-threading. The DBI, as of version 1.02, does not yet support multi-threading so it would be unsafe to let more than one thread enter the DBI at the same time. =end original Perl version 5.005 以降では、マルチスレッドをサポートするように作られます。 DBI(version 1.02)はまだマルチスレッドをサポートしていません; このため、 同時に DBI に一つより多くのスレッドを DBI に入らせるのは安全ではありません。 =begin original It is expected that some future version of the DBI will at least be thread-safe (but not thread-hot) by automatically blocking threads intering the DBI while it's already in use. =end original 将来のバージョンでは、既に使われている間は DBI を抑留するスレッドを 自動的にブロックすることにより、DBI はスレッドセーフ(しかし スレッドホットではない)になる予定です。 =begin original For some OCI example code for Oracle that has multi-threaded C