?? postgresql-howto-11.html
字號:
<H3>編譯錯誤或「測試失敗」</H3><P>如果發生訊息轉儲 (core dump),嘗試使用 Devel::CoreStack 模塊來產生訊息轉儲的堆疊追蹤 (stack trace)。Devel::CoreStack 可在 CPAN 找到∶<UL><LI> <A HREF="javascript:if(confirm('http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack'" tppabs="http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack">http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack</A></LI></UL><P>把堆疊追蹤、模塊版本、perl 版本、測試個案、操作系統版本及任何其他適用的資料電郵到 dbi-users 通信論壇。寄出的資料越齊全,開發人員越快解決問題。如果你不告訴我們,不要期望得到答案。<H3>視窗 95/NT 有沒有 DBI 支持?</H3><P>DBI 和 DBD::Oracle 的 Win32 版本已成為 DBI 的標準部分。因此,比 DBI 0.81 高的版本應該會正常運作。透過 ODBC,你可以存取微軟 Access 和 SQL-Server 資料庫。在 DBI-0.79(及以後)有一個實驗性質的 Win32::ODBC DBI 模擬層。它名為 DBI::W32ODBC。你需要使用 Win32::odbc 模塊。<UL><LI> Win32 DBI <A HREF="javascript:if(confirm('http://www.hermetica.com/technologia/perl/DBI/win32 \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.hermetica.com/technologia/perl/DBI/win32'" tppabs="http://www.hermetica.com/technologia/perl/DBI/win32">http://www.hermetica.com/technologia/perl/DBI/win32</A></LI><LI> Win32 ODBC <A HREF="javascript:if(confirm('http://www.roth.net/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.roth.net/'" tppabs="http://www.roth.net/">http://www.roth.net</A></LI></UL><H3>何謂 DBM?為何要用 DBI?</H3><P>UNIX 原本是使用簡單以檔案為基礎的「資料庫」,即 dbm 系統。dbm 容許你在檔案快速地存取資料。不過,它有數個嚴重的缺點。<P>檔案封鎖 (File Locking)<P>dbm 系統不容許特別全面的檔案封鎖能力,也沒有修正同時寫入資料庫引起的問題的能力。<P>隨意的資料結構<P>dbm 系統只容許單一固定的資料結構∶鏈-數值對 (key-value pair)。那數值可以是復雜的物件,如一個 C 的 struct,但鏈必須是獨一無二的。這對 dbm 系統的用途造成很大限制。<P>不過,dbm 系統仍為使用簡單資料及資源有限的用家提供了有用的功能,因為它快速、全面及經過極嚴謹的測試。存取 dbm 系統的模塊現已經 AnyDBM_File 模塊整合到 Perl 的核心散布中。<P>總括一句,對近乎是唯讀的資料庫或小型而簡單的資料來說,dbm 是一個非常令人滿意的解決方法。不過,對更強大和可增減 (scalable) 的資料集來說,用家最好使用 DBI。至于全面的交易封鎖 (transactional locking),就更不用說了?!?lt;P><H3>DBI 是否支持<這項功能>?</H3><P>根據所提出的功能是一個并不標準,而只為部分資料庫所獨有的假設,答案是否。<P>DBI 反映一個通用而可在大部分資料庫使用的 API,而沒有資料庫獨有的功能。<P>不過,如果驅動程序的作者有興趣,他們可以籍 DBI 界面所定義的 func method 來加上資料庫獨有的功能。命令稿的開發人員要注意籍 func methods 提供的功能一般不能在不同資料庫間移植。<H3>對 CGI 來說,dbi 有沒有用?</H3><P>一個字∶有!DBI 對 CGI 程序設計非常有用!事實上,CGI 是 DBI 最重要的用途之一。<P>DBI 讓 CGI 程序設計師設計功能強大的互聯網前端資料庫給他們的用家,從而提供大量按次序排列的資料。DBI 也容許在網站的資料庫服務器超過負荷時,管理人員在無須更改 CGI 命令稿的情況下將之升級。<H3>我如何加快 CGI 與 DBD Oracle 的連接速度?</H3><P>Apache httpd 管理一組子 httpd (httpd children) 來服務客戶。籍著 Doug MacEachern 的 Apache mod_perl 模塊,perl 翻譯器已嵌入到子 httpd 中。CGI、DBI 和你喜歡的模塊會在兒子誕生時載入。這些模塊直到在磁碟上的版本被更改時才會再被載入。要知道更多有關 Apache 的資料,請看 Apache 計劃的網站∶<UL><LI> Apache 計劃的網站 <A HREF="javascript:if(confirm('http://www.apache.org/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.apache.org/'" tppabs="http://www.apache.org/">http://www.apache.org</A></LI><LI> Mod_perl 模塊 <A HREF="javascript:if(confirm('http://www.perl.com/cgi-bin/cpan_mod?module=mod_perl \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.com/cgi-bin/cpan_mod?module=mod_perl'" tppabs="http://www.perl.com/cgi-bin/cpan_mod?module=mod_perl">http://www.perl.com/cgi-bin/cpan_mod?module=mod_perl</A></LI></UL><H3>如何使 DBI 和 CGI 持續連接?</H3><P>籍著 Edmund Mergl 的 Apache::DBI 模塊,每個子 httpd 會把資料庫登入儲存在雜湊 (hash) 中。如果你的應用程序只有一個資料庫用家,每一個兒子都可開始連連。目前,兒子之間并不會分享資料庫連接。Apache::DBI 可從 CPAN 下載∶<UL><LI> <A HREF="javascript:if(confirm('http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI'" tppabs="http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI">http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI</A></LI></UL><H3>“我在指令行執行一個 perl 命令稿時,并無問題。不過,當我在 http 執行它時,它會失敗!”何解?</H3><P>基本上,這很有可能是因為從指令行執行命令稿的使用者已把環境變數設定好,以 DBD::Oracle 來說,即 $ORACLE_HOME, $ORACLE_SID 或 TWO_TASK。httpd 行程通常是以 nobody 的身份執行,即沒有了設定好的環境。任何在這情況下嘗試執行的手稿都會正確地失敗。要解決這問題,在你的命令稿的開頭用一個 BEGIN() 區塊設定環境。這樣便會解決問題。同樣地,你要檢查你的 httpd 錯誤紀錄檔以尋找線索,以及閱讀“Idiot's Guide To Solving Perl / CGI Problems”和“Perl CGI Programming FAQ”以尋找更多資料。這問題大概不會和 DBI 有關。請兩份文件都小心閱讀!<UL><LI> Idiot's Guide to Solving Perl / CGI problems <A HREF="javascript:if(confirm('http://www.perl.com/perl/faq/index.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.com/perl/faq/index.html'" tppabs="http://www.perl.com/perl/faq/index.html">http://www.perl.com/perl/faq/index.html</A></LI></UL><H3>使用 DBI 時,我能否進行多流處理 (multi-threading)?</H3><P>目前不能。Perl 并不支持多流處理。不過,據估計,多流處理會成為 5.005 版的基本散布的一部分,即不久之後,DBI 可能會支持多流處理。要看一些使用多流 SELECT 句子的 Oracle OCI □例程序,請參閱∶<UL><LI> <A HREF="javascript:if(confirm('http://www.hermetica.com/technologia/oracle/oci/orathreads.tar.gz \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.hermetica.com/technologia/oracle/oci/orathreads.tar.gz'" tppabs="http://www.hermetica.com/technologia/oracle/oci/orathreads.tar.gz">http://www.hermetica.com/technologia/oracle/oci/orathreads.tar.gz</A></LI></UL><H3>我如何用 DBI 呼叫內儲程序 (stored procedure)?</H3><P>假設你在目標資料庫,例如一個 Oracle 資料庫中建立了內儲程序,你可使用 $dbh->do 來使程序立即執行。例如∶<P>$dbh->do( "BEGIN someProcedure END" );<H3>在 DBI 中,我如何取回內儲程序的返回值?</H3><P>記著還要檢查錯誤!<BLOCKQUOTE><CODE><PRE> $sth = $dbh->prepare( "BEGIN foo(:1, :2, :3); END;" ); $sth->bind_param(1, $a); $sth->bind_param_inout(2, \$path, 2000); $sth->bind_param_inout(3, \$success, 2000); $sth->execute;</PRE></CODE></BLOCKQUOTE><H3>我可否用 DBI 來丟棄一個資料庫?</H3><P>對 DBI 來說,要適當地支持資料庫的建立和丟棄太抽象了。例如,Oracle 根本不支持丟棄資料庫!此外,在 Oracle 中,資料庫服務器基本上就是資料庫,但在 mSQL,即使沒有資料庫,服務器也能順利地執行。這問題牽連太廣了。正因如此,部分驅動程序透過私家 func 方法來建立和刪除資料庫。你要檢查驅動程序的文件來了解它有沒有支持這機制。<H3>DBI 怎樣處理 NULL 值?</H3><P>DBI 被指定把 NULL 值當作 undef 值處理。NULL 可以 NULL 的數值來加入到資料庫中,例如∶<BLOCKQUOTE><CODE><PRE> $rv = $dbh->do( "INSERT INTO table VALUES( NULL )" );</PRE></CODE></BLOCKQUOTE>不過當查詢時,NULL 要和 undef 比較。這是所有驅動程序都適用的標準。<H3>這些 func 方法是做什么的?</H3><P>DBI 把 func 方法定義為資料庫獨有功能的進入點,例如建立和丟棄一個資料庫。使用這些驅動程序獨有方法十分簡單,例如,要使用一個 createDatabase 方法輸入一個引數 (argument) ,我們會寫∶<BLOCKQUOTE><CODE><PRE> $rv = $dbh->func( 'argument', 'createDatabase' );</PRE></CODE></BLOCKQUOTE>軟件開發人員要注意 func 方法不能在不同資料庫間移植。<H3>商業支持及訓練</H3><P>Perl5 資料庫界面是自由軟件。它并沒有任何擔保 (warranty)。不過,有些機構提供了 DBI 的技術支持或培訓計劃。<P><B>PERL CLINIC : </B>Perl Clinic 以合約形式為 Perl、DBI、DBD::Oracle 和 Oraperl 提供商業支持。這些支持是由 DBI 作者 Tim Bunce 工作的公司提供的。欲知詳情,請看∶<UL><LI> <A HREF="javascript:if(confirm('http://www.perl.co.uk/tpc \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.co.uk/tpc'" tppabs="http://www.perl.co.uk/tpc">http://www.perl.co.uk/tpc</A></LI></UL><HR><A HREF="PostgreSQL-HOWTO-12.html" tppabs="http://www.linux.org.tw/CLDP/gb/PostgreSQL-HOWTO-12.html"><IMG SRC="next.gif" tppabs="http://www.linux.org.tw/CLDP/gb/img/next.gif" ALT="Next"></A><A HREF="PostgreSQL-HOWTO-10.html" tppabs="http://www.linux.org.tw/CLDP/gb/PostgreSQL-HOWTO-10.html"><IMG SRC="prev.gif" tppabs="http://www.linux.org.tw/CLDP/gb/img/prev.gif" ALT="Previous"></A><A HREF="PostgreSQL-HOWTO.html#toc11" tppabs="http://www.linux.org.tw/CLDP/gb/PostgreSQL-HOWTO.html#toc11"><IMG SRC="toc.gif" tppabs="http://www.linux.org.tw/CLDP/gb/img/toc.gif" ALT="Contents"></A> </BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -