=encoding euc-jp =head1 NAME =begin original DBI - Database independent interface for Perl =end original DBI - Perl Íѥǡ¼¥¿¥Ù¡¼¥¹ÆÈΩ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹ (ÌõÃí: (TBR)¤¬¤Ä¤¤¤Æ¤¤¤ëÃÊÍî¤Ï¡Ö¤ß¤ó¤Ê¤Î¼«Æ°ËÝÌõ¡÷TexTra¡×¤Ë¤è¤ë µ¡³£ËÝÌõ¤Ç¤¹¡£) =head1 SYNOPSIS use DBI; @driver_names = DBI->available_drivers; %drivers = DBI->installed_drivers; @data_sources = DBI->data_sources($driver_name, \%attr); $dbh = DBI->connect($data_source, $username, $auth, \%attr); $rv = $dbh->do($statement); $rv = $dbh->do($statement, \%attr); $rv = $dbh->do($statement, \%attr, @bind_values); $ary_ref = $dbh->selectall_arrayref($statement); $hash_ref = $dbh->selectall_hashref($statement, $key_field); $ary_ref = $dbh->selectcol_arrayref($statement); $ary_ref = $dbh->selectcol_arrayref($statement, \%attr); @row_ary = $dbh->selectrow_array($statement); $ary_ref = $dbh->selectrow_arrayref($statement); $hash_ref = $dbh->selectrow_hashref($statement); $sth = $dbh->prepare($statement); $sth = $dbh->prepare_cached($statement); $rc = $sth->bind_param($p_num, $bind_value); $rc = $sth->bind_param($p_num, $bind_value, $bind_type); $rc = $sth->bind_param($p_num, $bind_value, \%attr); $rv = $sth->execute; $rv = $sth->execute(@bind_values); $rv = $sth->execute_array(\%attr, ...); $rc = $sth->bind_col($col_num, \$col_variable); $rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind); @row_ary = $sth->fetchrow_array; $ary_ref = $sth->fetchrow_arrayref; $hash_ref = $sth->fetchrow_hashref; $ary_ref = $sth->fetchall_arrayref; $ary_ref = $sth->fetchall_arrayref( $slice, $max_rows ); $hash_ref = $sth->fetchall_hashref( $key_field ); $rv = $sth->rows; $rc = $dbh->begin_work; $rc = $dbh->commit; $rc = $dbh->rollback; $quoted_string = $dbh->quote($string); $rc = $h->err; $str = $h->errstr; $rv = $h->state; $rc = $dbh->disconnect; =begin original I =end original I<¾åµ­¤Î³µÎ¬¤Ï¼ç¤Ê¥á¥½¥Ã¥É¤È¥Ñ¥é¥á¡¼¥¿¤À¤±¤ò¥ê¥¹¥È¤Ë¤·¤Æ¤¤¤Þ¤¹¡£> =head2 GETTING HELP (½õ¤±¤òÆÀ¤ë) =begin original If you have questions about DBI, or DBD driver modules, you can get help from the I mailing list. You don't have to subscribe to the list in order to post, though I'd recommend it. You can get help on subscribing and using the list by emailing I. =end original DBI ¤ä DBD ¥É¥é¥¤¥Ð¥â¥¸¥å¡¼¥ë¤Ë´Ø¤¹¤ë¼ÁÌ䤬¤¢¤ë¤Ê¤é¡¢ I ¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Ç½õ¤±¤òÆÀ¤é¤ì¤Þ¤¹¡£ Åê¹Æ¤¹¤ë¤Î¤Ë¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Î¹ØÆɤÏɬÍפǤϤ¢¤ê¤Þ¤»¤ó¤¬¡¢¹ØÆɤ¹¤ë¤³¤È¤ò ´«¤á¤Þ¤¹¡£ I ¤Ë¥á¡¼¥ë¤¹¤ë¤³¤È¤Ç¡¢¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Î¹ØÆɤª¤è¤Ó »ÈÍѤ˴ؤ¹¤ë½õ¤±¤¬ÆÀ¤é¤ì¤Þ¤¹¡£ =begin original I don't recommend the DBI cpanforum (at http://www.cpanforum.com/dist/DBI) because relatively few people read it compared with dbi-users@perl.org. =end original »ä¤Ï DBI cpanforum (at http://www.cpanforum.com/dist/DBI) ¤Ï´«¤á¤Þ¤»¤ó; dbi-users@perl.org ¤ËÈæ¤Ù¤ÆÆɤó¤Ç¤¤¤ë¿Í¿ô¤¬¾¯¤Ê¤¤¤«¤é¤Ç¤¹¡£ =begin original To help you make the best use of the dbi-users mailing list, and any other lists or forums you may use, I I recommend that you read "How To Ask Questions The Smart Way" by Eric Raymond: L. =end original dbi-users ¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤ä¡¢¤½¤Î¾¤Î¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤ä¥Õ¥©¡¼¥é¥à¤ò ¤¦¤Þ¤¯ÍøÍѤ¹¤ë¤¿¤á¤Ë¡¢»ä¤Ï Eric Raymond ¤Ë¤è¤ë "How To Ask Questions The Smart Way" L (ÏÂÌõ:¡Ö¸­¤¤¼ÁÌä¤Î¤·¤«¤¿¡× L) ¤ò Æɤळ¤È¤ò I<¶¯¤¯> ´«¤á¤Þ¤¹¡£ =begin original If you think you've found a bug then please also read "How to Report Bugs Effectively" by Simon Tatham: L. =end original ¥Ð¥°¤òȯ¸«¤·¤¿¤È»×¤Ã¤¿¤é¡¢Simon Tatham ¤Ë¤è¤ë "How to Report Bugs Effectively" L (ÏÂÌõ: ¡Ö¸ú²ÌŪ¤Ë¥Ð¥°¤òÊó¹ð¤¹¤ë¤Ë¤Ï¡× L) ¤â Æɤó¤Ç¤¯¤À¤µ¤¤¡£ =begin original The DBI home page at L and the DBI FAQ at L are always worth a visit. They include links to other resources. =end original L ¤Î DBI ¥Û¡¼¥à¥Ú¡¼¥¸¤È L ¤Î DBI FAQ ¤Ï¾ï¤Ëˬ¤ì¤ë²ÁÃͤΤ¢¤ë¾ì½ê¤Ç¤¹¡£ ¤³¤ì¤é¤Ë¤Ï¾¤Î¥ê¥½¡¼¥¹¤Ø¤Î¥ê¥ó¥¯¤â¤¢¤ê¤Þ¤¹¡£ =begin original Before asking any questions, reread this document, consult the archives and read the DBI FAQ. The archives are listed at the end of this document and on the DBI home page. =end original ¼ÁÌä¤ò¤¹¤ëÁ°¤Ë¡¢¤³¤Î¥É¥­¥å¥á¥ó¥È¤òÆɤßÊÖ¤·¡¢¥¢¡¼¥«¥¤¥Ö¤ò¤¢¤¿¤ê¡¢DBI FAQ ¤ò Æɤó¤Ç¤¯¤À¤µ¤¤¡£ ¥¢¡¼¥«¥¤¥Ö¤Ï¤³¤Î¥ê¥¹¥È¤ÎºÇ¸å¤È DBI ¥Û¡¼¥à¥Ú¡¼¥¸¤Ë°ìÍ÷¤¬¤¢¤ê¤Þ¤¹¡£ =begin original This document often uses terms like I, I, I. If you're not familiar with those terms then it would be a good idea to read at least the following perl manuals first: L, L, L, and L. =end original ¤³¤Îʸ½ñ¤Ë¤Ï¤·¤Ð¤·¤Ð I<¥ê¥Õ¥¡¥ì¥ó¥¹>, I<¥ª¥Ö¥¸¥§¥¯¥È>, I<¥á¥½¥Ã¥É> ¤È¤¤¤Ã¤¿ ÍѸì¤ò»È¤¤¤Þ¤¹¡£ ¤³¤ì¤é¤ÎÍѸì¤Ë¿Æ¤·¤ß¤¬¤Ê¤¤¤Ê¤é¡¢¾¯¤Ê¤¯¤È¤â°Ê²¼¤Î¥Þ¥Ë¥å¥¢¥ë¤òÀè¤ËÆɤà¤Î¤¬ ¤¤¤¤¹Í¤¨¤Ç¤¹: L, L, L, L =begin original Please note that Tim Bunce does not maintain the mailing lists or the web page (generous volunteers do that). So please don't send mail directly to him; he just doesn't have the time to answer questions personally. The I mailing list has lots of experienced people who should be able to help you if you need it. If you do email Tim he is very likely to just forward it to the mailing list. =end original Tim Bunce ¤¬¤½¤Î¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤ä Web ¥Ú¡¼¥¸¤ò´ÉÍý¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï ¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤(Ä̾ï¤Ï¥Ü¥é¥ó¥Æ¥£¥¢¤¬¤ä¤Ã¤Æ¤¤¤Þ¤¹)¡£ ¤½¤Î¤¿¤áÈà¤ËľÀܥ᡼¥ë¤òÁ÷¤é¤Ê¤¤¤Ç²¼¤µ¤¤; Èà¤Ë¤Ï¸Ä¿ÍŪ¤Ë¼ÁÌä¤ËÅú¤¨¤ë»þ´Ö¤¬ ¤Ê¤¤¤À¤±¤Ç¤¹¡£ I ¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Ï·Ð¸³Ë­É٤ʿͤ¿¤Á¤¬¤¿¤¯¤µ¤ó¤¤¤Æ¡¢É¬ÍפǤ¢¤ì¤Ð ¤¢¤Ê¤¿¤ò½õ¤±¤Æ¤¯¤ì¤ë¤Ç¤·¤ç¤¦¡£ Tim ¤Ë¥á¡¼¥ë¤·¤Æ¤â¡¢¤ª¤½¤é¤¯Ã±¤Ë¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤ËžÁ÷¤µ¤ì¤ë¤Ç¤·¤ç¤¦¡£ =head2 NOTES (Ãí°Õ) =begin original This is the DBI specification that corresponds to the DBI version 1.612 ($Revision: 14216 $). =end original ¤³¤ì¤Ï DBI ¥Ð¡¼¥¸¥ç¥ó1.612 ($Revision: 14216 $) ¤ËÂбþ¤·¤¿ DBI ¤Î»ÅÍͤǤ¹¡£ =begin original The DBI is evolving at a steady pace, so it's good to check that you have the latest copy. =end original DBI ¤Î»ÅÍͤϡ¢¸½ºß¡¢³Î¼Â¤Ê¥Ú¡¼¥¹¤Ç¹¹¿·¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ºÇ¿·¤Î¤â¤Î¤ò»ý¤Ã¤Æ¤¤¤ë¤«¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The significant user-visible changes in each release are documented in the L module so you can read them by executing C. =end original ¥ê¥ê¡¼¥¹Ëè¤Î¥æ¡¼¥¶¡¼¤Ë¸«¤¨¤ë½ÅÍפÊÊѹ¹¤Ï L ¥â¥¸¥å¡¼¥ë¤Ë ʸ½ñ²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢C ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç ¤³¤ì¤òÆɤळ¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original Some DBI changes require changes in the drivers, but the drivers can take some time to catch up. Newer versions of the DBI have added features that may not yet be supported by the drivers you use. Talk to the authors of your drivers if you need a new feature that is not yet supported. =end original DBI ¤ÎÊѹ¹¤Ë¤è¤Ã¤Æ¥É¥é¥¤¥Ð¤ÎÊѹ¹¤¬É¬Íפˤʤë¾ì¹ç¤â¤¢¤ê¤Þ¤¹¤¬¡¢ ¥É¥é¥¤¥Ð¤ÏÄɤ¤¤Ä¤¯¤Î¤Ë¾¯¤·»þ´Ö¤¬¤«¤«¤ê¤Þ¤¹¡£ ¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Î DBI ¤Ï¡¢º£»È¤Ã¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤Ç¤Ï¤Þ¤ÀÂбþ¤·¤Æ¤¤¤Ê¤¤ µ¡Ç½¤òÄɲ䷤Ƥ¤¤ë¤³¤È¤â¤¢¤ê¤Þ¤¹¡£ ¤â¤·¤Þ¤ÀÂбþ¤·¤Æ¤¤¤Ê¤¤¿·¤·¤¤µ¡Ç½¤¬É¬Íפʤ顢¥É¥é¥¤¥Ð¤Îºî¼Ô¤Ë Ï䷤ƤߤƤ¯¤À¤µ¤¤¡£ =begin original Features added after DBI 1.21 (February 2002) are marked in the text with the version number of the DBI release they first appeared in. =end original DBI 1.21 (2002 ǯ 2 ·î) °Ê¹ß¤ËÄɲ䵤줿µ¡Ç½¤Ë¤Ä¤¤¤Æ¤Ï¡¢ºÇ½é¤Ë Äɲ䵤줿 DBI ¥ê¥ê¡¼¥¹¤Î¥Ð¡¼¥¸¥ç¥óÈÖ¹æ¤òʸ¾ÏÃæ¤Ëµ­¤·¤Æ¤¤¤Þ¤¹¡£ =begin original Extensions to the DBI API often use the C namespace. See L. DBI extension modules can be found at L. And all modules related to the DBI can be found at L. =end original DBI API ¤Î¥¨¥¯¥¹¥Æ¥ó¥·¥ç¥ó¤Ï¤·¤Ð¤·¤Ð C ̾Á°¶õ´Ö¤¬»È¤ï¤ì¤Þ¤¹¡£ L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ DBI ¥¨¥¯¥¹¥Æ¥ó¥·¥ç¥ó¥â¥¸¥å¡¼¥ë¤Ï L ¤Ë¤¢¤ê¤Þ¤¹¡£ DBI ´ØÏ¢¤ÎÁ´¤Æ¤Î¥â¥¸¥å¡¼¥ë¤Ï L ¤Ë¤¢¤ê¤Þ¤¹¡£ =cut =head1 DESCRIPTION =begin original The DBI is a database access module for the Perl programming language. It defines a set of methods, variables, and conventions that provide a consistent database interface, independent of the actual database being used. =end original DBI ¤Ï Perl ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î¤¿¤á¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥¢¥¯¥»¥¹¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£ ¤½¤ì¤Ï¥»¥Ã¥È¤Ë¤Ê¤Ã¤¿¥á¥½¥Ã¥É¡¢ÊÑ¿ô¤½¤·¤Æµ¬Ìó¤òÄêµÁ¤·¡¢¼ÂºÝ¤Î»È¤ï¤ì¤Æ¤¤¤ë ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë°Í¸¤·¤Ê¤¤°ì´ÓÀ­¤Î¤¢¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò Ä󶡤·¤Þ¤¹¡£ =begin original It is important to remember that the DBI is just an interface. The DBI is a layer of "glue" between an application and one or more database I modules. It is the driver modules which do most of the real work. The DBI provides a standard interface and framework for the drivers to operate within. =end original DBI ¤¬Ã±¤Ê¤ë¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¤¢¤ë¤³¤È¤ò˺¤ì¤Ê¤¤¤³¤È¤Ï½ÅÍפǤ¹¡£ DBI ¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤È°ì¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹ I<¥É¥é¥¤¥Ð> ¥â¥¸¥å¡¼¥ë¤È¤ò·ë¤ÓÉÕ¤±¤ëÇö¤¤¡Ö¸Ò¡×¤ÎÁؤʤΤǤ¹¡£ ¼ÂºÝ¤ËƯ¤¯¤Î¤Ï¥É¥é¥¤¥Ð¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£ DBI ¤Ï¥É¥é¥¤¥Ð¤òÁàºî¤¹¤ë¤¿¤á¤Îɸ½à¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ÈÏÈÁȤߤòÄ󶡤·¤Þ¤¹¡£ =head2 Architecture of a DBI Application (DBI ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã) |<- Scope of DBI ->| .-. .--------------. .-------------. .-------. | |---| XYZ Driver |---| XYZ Engine | | Perl | | | `--------------' `-------------' | script| |A| |D| .--------------. .-------------. | using |--|P|--|B|---|Oracle Driver |---|Oracle Engine| | DBI | |I| |I| `--------------' `-------------' | API | | |... |methods| | |... Other drivers `-------' | |... `-' =begin original The API, or Application Programming Interface, defines the call interface and variables for Perl scripts to use. The API is implemented by the Perl DBI extension. =end original API¡¢¤Ä¤Þ¤ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¡¦¥×¥í¥°¥é¥ß¥ó¥°¡¦¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï Perl ¥¹¥¯¥ê¥×¥È¤¬»È¤¦¤¿¤á¤Î¸Æ¤Ó½Ð¤·¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ÈÊÑ¿ô¤òÄêµÁ¤·¤Þ¤¹¡£ API ¤Ï Perl DBI ¥¨¥¯¥¹¥Æ¥ó¥·¥ç¥ó¤Ë¤è¤Ã¤Æ¼ÂÁõ¤µ¤ì¤Þ¤¹¡£ =begin original The DBI "dispatches" the method calls to the appropriate driver for actual execution. The DBI is also responsible for the dynamic loading of drivers, error checking and handling, providing default implementations for methods, and many other non-database specific duties. =end original DBI ¤ÏŬÀڤʥɥ饤¥Ð¤Ø¼ÂºÝ¤Î¼Â¹Ô¤Î¤¿¤á¤Ë¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò ¡Öȯ¹Ô¡×(dispatch)¤·¤Þ¤¹¡£ DBI ¤Ï¥É¥é¥¤¥Ð¤ÎưŪ¤Ê¥í¡¼¥É¡¢¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯/Áàºî¡¢¥á¥½¥Ã¥É¤Î¤¿¤á¤Î ¥Ç¥Õ¥©¥ë¥È¤Î¼ÂÁõ¤ÎÄ󶡡¢¤½¤Î¾¤¿¤¯¤µ¤ó¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹ÆÃÍ­¤Ê¤³¤È°Ê³°¤Ë¤â ÀÕǤ¤ò»ý¤Á¤Þ¤¹¡£ =begin original Each driver contains implementations of the DBI methods using the private interface functions of the corresponding database engine. Only authors of sophisticated/multi-database applications or generic library functions need be concerned with drivers. =end original ³Æ¥É¥é¥¤¥Ð¤ÏÂбþ¤¹¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Î¥×¥é¥¤¥Ù¡¼¥È¤Ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹ ´Ø¿ô¤ò»È¤¤¡¢DBI ¥á¥½¥Ã¥É¤Î¼ÂÁõ¤ò»ý¤Á¤Þ¤¹¡£ ¹âÅÙ¤Ê/Ê£¿ô¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂбþ¤¹¤ë¥¢¥×¥ê¡¼¥±¡¼¥·¥ç¥ó¤ä ÈÆÍѥ饤¥Ö¥é¥ê´Ø¿ô¤ÎºîÀ®¼Ô¤À¤±¤¬¡¢¤³¤Î¥É¥é¥¤¥Ð¤Ë´Ø¿´¤ò¤â¤ÄɬÍפ¬¤¢¤ê¤Þ¤¹¡£ =head2 Notation and Conventions (µ­Ë¡¤Èµ¬Ìó) =begin original The following conventions are used in this document: =end original ¤³¤Î¥É¥­¥å¥á¥ó¥È¤Ç¤Ï°Ê²¼¤Îɽµ­Ë¡¤ò»ÈÍѤ·¤Þ¤¹: =begin original $dbh Database handle object $sth Statement handle object $drh Driver handle object (rarely seen or used in applications) $h Any of the handle types above ($dbh, $sth, or $drh) $rc General Return Code (boolean: true=ok, false=error) $rv General Return Value (typically an integer) @ary List of values returned from the database, typically a row of data $rows Number of rows processed (if available, else -1) $fh A filehandle undef NULL values are represented by undefined values in Perl \%attr Reference to a hash of attribute values passed to methods =end original $dbh ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È $sth ʸ¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È $drh ¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È(¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇÌܤˤ·¤¿¤ê¡¢»È¤Ã¤¿¤ê¤¹¤ë¤³¤È¤Ï¤Þ¤º¤¢¤ê¤Þ¤»¤ó) $h ¾åµ­¤Î¥Ï¥ó¥É¥ë¤Î¤É¤ì¤« $rc °ìÈÌŪ¤ÊÌá¤êÃÍ(¥³¡¼¥É)(¿¿µ¶ÃÍ: ¿¿=OK, µ¶=¥¨¥é¡¼) $rv °ìÈÌŪ¤ÊÌá¤êÃÍ(ÃÍ) (Ä̾ï¤Ïinteger) @ary ¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤éÊÖ¤µ¤ì¤ëÃͤΥꥹ¥È¡£Ä̾ï¤Ï¥Ç¡¼¥¿¤Î¹Ô $rows ½èÍý¤µ¤ì¤¿¹Ô¤Î¿ô (¤â¤·¤¢¤ì¤Ð¡£¤Ê¤±¤ì¤Ð -1) $fh ¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë undef Perl ¤Ç¤Ï NULLÃͤÏ̤ÄêµÁÃͤÇɽ¸½¤µ¤ì¤ë \%attr ¥á¥½¥Ã¥É¤ËÅϤµ¤ì¤ë°À­ÃͤΥϥå·¥å¤Î¥ê¥Õ¥¡¥ì¥ó¥¹ =begin original Note that Perl will automatically destroy database and statement handle objects if all references to them are deleted. =end original Ãí°Õ:¤½¤³¤Ø¤Î»²¾È¤¬¤¹¤Ù¤Æºï½ü¤µ¤ì¤ë¤È¡¢Perl ¤Ï¡¢¼«Æ°Åª¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤È ¥¹¥Æ¡¼¥È¥á¥ó¥È¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤·¤Þ¤¹¡£ =head2 Outline Usage (»ÈÍÑË¡¤Î³µÍ×) =begin original To use DBI, first you need to load the DBI module: =end original DBI ¤ò»È¤¦¤¿¤á¤Ë¤Ï¡¢¤Þ¤º DBI ¥â¥¸¥å¡¼¥ë¤ò¥í¡¼¥É¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹: use DBI; use strict; =begin original (The C isn't required but is strongly recommended.) =end original (C ¤Ïɬ¿Ü¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¢¶¯¤¯¿ä¾©¤·¤Þ¤¹¡£) =begin original Then you need to L to your data source and get a I for that connection: =end original ¤½¤·¤Æ¥Ç¡¼¥¿¥½¡¼¥¹¤ËÀܳ(L)¤·¡¢¤½¤ÎÀܳ¤Î¤¿¤á¤Î I<¥Ï¥ó¥É¥ë> ¤ò¼èÆÀ¤·¤Þ¤¹: $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 }); =begin original Since connecting can be expensive, you generally just connect at the start of your program and disconnect at the end. =end original Àܳ¤Ë¤Ï¥³¥¹¥È¤¬¤«¤«¤ë¤Î¤Ç¡¢°ìÈÌŪ¤Ë¤Ï¥×¥í¥°¥é¥à¤Î³«»Ï¤·¤¿»þÅÀ¤ÇÀܳ¤·¡¢ ½ª¤ï¤ê¤ÇÀÚÃǤ·¤Þ¤¹: =begin original Explicitly defining the required C behaviour is strongly recommended and may become mandatory in a later version. This determines whether changes are automatically committed to the database when executed, or need to be explicitly committed later. =end original Í׵ᤵ¤ì¤ë C ¤ÎÆ°¤­¤òÌÀ¼¨Åª¤ËÄêµÁ¤¹¤ë¤³¤È¤Ï¶¯¤¯¿ä¾©¤µ¤ì¤Þ¤¹¡£ ¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ïɬ¿Ü¤Ë¤Ê¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ ¤³¤ì¤Ï¼Â¹Ô¤·¤¿¤È¤­¤ËÊѹ¹¤ò¼«Æ°Åª¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¥³¥ß¥Ã¥È¤¹¤ë¤«¡¢¸å¤«¤é ÌÀ¼¨Åª¤Ë¥³¥ß¥Ã¥È¤µ¤ì¤ëɬÍפ¬¤¢¤ë¤«¤ò·èÄꤷ¤Þ¤¹¡£ =begin original The DBI allows an application to "prepare" statements for later execution. A prepared statement is identified by a statement handle held in a Perl variable. We'll call the Perl variable C<$sth> in our examples. =end original DBI ¤Ç¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÏSQLʸ¤ò¸å¤Ç¼Â¹Ô¤¹¤ë¤¿¤á¤Î "prepare"(=½àÈ÷)¤ò¤·¤Æ¤ª¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ prepare ¤µ¤ì¤¿Ê¸¤Ï Perl ÊÑ¿ô¤ËÆþ¤Ã¤¿Ê¸¥Ï¥ó¥É¥ë¤Ë¤è¤ê ¼±Ê̤µ¤ì¤Þ¤¹¡£ ¤³¤ÎÎã¤Ç¤Ï¤½¤Î Perl ÊÑ¿ô¤ò $sth ¤È¤·¤Þ¤¹¡£ =begin original The typical method call sequence for a C ʸ¤Î¤¿¤á¤Îŵ·¿Åª¤Ê¥á¥½¥Ã¥É¤Î½çÈ֤ϰʲ¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: prepare, execute, fetch, fetch, ... execute, fetch, fetch, ... execute, fetch, fetch, ... =begin original for example: =end original Îã: $sth = $dbh->prepare("SELECT foo, bar FROM table WHERE baz=?"); $sth->execute( $baz ); while ( @row = $sth->fetchrow_array ) { print "@row\n"; } =begin original The typical method call sequence for a I-C ʸ I<°Ê³°> ¤Î¤¿¤á¤Îŵ·¿Åª¤Ê¥á¥½¥Ã¥É¤Î½çÈÖ¤Ï °Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: prepare, execute, execute, execute. =begin original for example: =end original Îã: $sth = $dbh->prepare("INSERT INTO table(foo,bar,baz) VALUES (?,?,?)"); while() { chomp; my ($foo,$bar,$baz) = split /,/; $sth->execute( $foo, $bar, $baz ); } =begin original The C method can be used for non repeated I-C I<°Ê³°> ¤Îʸ¤Î¤¿¤á¤Ë (¤Þ¤¿¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤¤¥É¥é¥¤¥Ð¤Ç)»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹: $rows_affected = $dbh->do("UPDATE your_table SET foo = foo + 1"); =begin original To commit your changes to the database (when L is off): =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤ÎÊѹ¹¤ò¥³¥ß¥Ã¥È¤¹¤ë¤¿¤á¤Ë¤Ï(L ¤¬¥ª¥Õ¤Î»þ): $dbh->commit; # or call $dbh->rollback; to undo changes =begin original Finally, when you have finished working with the data source, you should L from it: =end original ºÇ¸å¤Ë¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤Ç¤Îºî¶È¤ò½ªÎ»¤¹¤ë¤È¤­¤Ë¤Ï¤½¤³¤«¤é ÀÚÃÇ(L )¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó: $dbh->disconnect; =head2 General Interface Rules & Caveats (°ìÈÌŪ¤Ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹µ¬Â§¤Èα°Õ»ö¹à) =begin original The DBI does not have a concept of a "current session". Every session has a handle object (i.e., a C<$dbh>) returned from the C method. That handle object is used to invoke database related methods. =end original DBI ¤Ë¤Ï¡Ö¸½ºß¤Î¥»¥Ã¥·¥ç¥ó¡×¤È¤¤¤¦¹Í¤¨¤Ï¤¢¤ê¤Þ¤»¤ó¡£ ³Æ¥»¥Ã¥·¥ç¥ó¤Ï C¥á¥½¥Ã¥É¤«¤éÊÖ¤µ¤ì¤ë¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È (¤Ä¤Þ¤ê C<$dbh>)¤ò»ý¤Á¤Þ¤¹¡£ ¤½¤Î¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹´ØÏ¢¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤¿¤á¤Ë »È¤ï¤ì¤Þ¤¹¡£ =begin original Most data is returned to the Perl script as strings. (Null values are returned as C.) This allows arbitrary precision numeric data to be handled without loss of accuracy. Beware that Perl may not preserve the same accuracy when the string is used as a number. =end original ¤Û¤È¤ó¤É¤Î¥Ç¡¼¥¿¤Ïʸ»úÎó¤È¤·¤Æ Perl ¥¹¥¯¥ê¥×¥È¤ËÊÖ¤µ¤ì¤Þ¤¹(Null ÃÍ¤Ï C ¤È¤·¤ÆÊÖ¤µ¤ì¤Þ¤¹)¡£ ¤³¤ì¤Ë¤è¤êǤ°Õ¤Î·å¿ô¤Î¿ôÃͥǡ¼¥¿¤òÀºÅÙ¤òÍî¤È¤¹¤³¤È¤Ê¤¯°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ʸ»úÎó¤ò¿ôÃͤȤ·¤Æ°·¤¦ºÝ¤Ë¡¢Perl ¤¬Æ±¤¸ÀºÅÙ¤òÊݤ¿¤Ê¤¤¤«¤â ¤·¤ì¤Ê¤¤¤È¤¤¤¦¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Dates and times are returned as character strings in the current default format of the corresponding database engine. Time zone effects are database/driver dependent. =end original ÆüÉÕ(Date)¡¢»þ¹ï(Time)¤Ï¡¢Âбþ¤¹¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Î¸½ºß¤Î ¥Ç¥Õ¥©¥ë¥È¥Õ¥©¡¼¥Þ¥Ã¥È¤Îʸ»úÎó¤È¤·¤ÆÊÖ¤µ¤ì¤Þ¤¹¡£ »þ´ÖÂӤαƶÁ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¿¥É¥é¥¤¥Ð¤Ë¸¤·¤Þ¤¹¡£ =begin original Perl supports binary data in Perl strings, and the DBI will pass binary data to and from the driver without change. It is up to the driver implementors to decide how they wish to handle such binary data. =end original Perl ¥¹¥¯¥ê¥×¥È¤Ïʸ»úÎó¤Î¤Ê¤«¤Ë¤¢¤ë¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£ DBI ¤Ï¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤òÊѹ¹¤¹¤ë¤³¤È¤Ê¤¯¡¢¥É¥é¥¤¥Ð¤È¤ä¤ê¤È¤ê¤·¤Þ¤¹¡£ ¤½¤Î¤è¤¦¤Ê¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ò¤É¤Î¤è¤¦¤Ë°·¤¤¤¿¤¤¤Î¤«¤ò·è¤á¤ë¤³¤È¤Ï¥É¥é¥¤¥Ð¤Î ¼ÂÁõ¼Ô¼¡Âè¤Ç¤¹¡£ =begin original Perl supports two kinds of strings: Unicode (utf8 internally) and non-Unicode (defaults to iso-8859-1 if forced to assume an encoding). Drivers should accept both kinds of strings and, if required, convert them to the character set of the database being used. Similarly, when fetching from the database character data that isn't iso-8859-1 the driver should convert it into utf8. =end original Perl ¤Ï 2 ¼ïÎà¤Îʸ»úÎó¤ËÂбþ¤·¤Æ¤¤¤Þ¤¹: Unicode (ÆâÉô¤Ç¤Ï utf8) ¤È Èó-Unicode (¤â¤·¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ò²¾Äꤹ¤ë¤³¤È¤ò¶¯À©¤µ¤ì¤ë¤Ê¤é ¥Ç¥Õ¥©¥ë¥È¤Ï iso-8859-1)¡£ ¥É¥é¥¤¥Ð¤Ï¤É¤Á¤é¤Î¼ïÎà¤Îʸ»úÎó¤â¼õ¤±ÉÕ¤±¤Æ¡¢¤â¤·É¬Íפʤé¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ »È¤Ã¤Æ¤¤¤ëʸ»ú½¸¹ç¤ËÊÑ´¹¤Ç¤­¤ë¤Ù¤­¤Ç¤¹¡£ ƱÍͤˡ¢iso-8859-1 ¤Ç¤Ê¤¤ ¥Ç¡¼¥¿¥Ù¡¼¥¹Ê¸»ú¥Ç¡¼¥¿¤ò¥Õ¥§¥Ã¥Á¤·¤¿¤È¤­¤Ë¤Ï¡¢ ¥É¥é¥¤¥Ð¤Ï utf8 ¤ËÊÑ´¹¤¹¤ë¤Ù¤­¤Ç¤¹¡£ =begin original Multiple SQL statements may not be combined in a single statement handle (C<$sth>), although some databases and drivers do support this (notably Sybase and SQL Server). =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¡¢¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï¤½¤ì¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤È¤·¤Æ¤â (ÆÃ¤Ë Sybase¤È SQL Server)¡¢Ê£¿ô¤Î SQL ʸ¤Ï£±¤Ä¤Î ʸ¥Ï¥ó¥É¥ë($sth)¤Ë·ë¤ÓÉÕ¤±¤é¤ì¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original Non-sequential record reads are not supported in this version of the DBI. In other words, records can only be fetched in the order that the database returned them, and once fetched they are forgotten. =end original ¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Î DBI ¤Ç¤Ï½ç½øÄ̤ê¤Ç¤Ê¤¤¥ì¥³¡¼¥É¤ÎÆɤ߹þ¤ß¤Ï¤Ç¤­¤Þ¤»¤ó¡£ ¤¤¤¤¤«¤¨¤ì¤Ð¥ì¥³¡¼¥É¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ÊÖ¤·¤Æ¤­¤¿½ç½ø¤Ë¤·¤« ¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¤·¡¢°ìÅÙ¼è¤ê½Ð¤µ¤ì¤ë¤È˺¤ìµî¤é¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¡£ =begin original Positioned updates and deletes are not directly supported by the DBI. See the description of the C attribute for an alternative. =end original °ÌÃ֤Ť±¤Æ¤Î¹¹¿·¡¢ºï½ü¤ò DBI ¤ÏľÀÜ¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£ ¤½¤ÎÂå¤ï¤ê¤È¤·¤Æ C °À­¤ÎÀâÌÀ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original Individual driver implementors are free to provide any private functions and/or handle attributes that they feel are useful. Private driver functions can be invoked using the DBI C method. Private driver attributes are accessed just like standard attributes. =end original ³Æ¥É¥é¥¤¥Ð¤ò¼ÂÁõ¤¹¤ë³«È¯¼Ô¤Ï¡¢»È¤¤¤ä¤¹¤¤¤È»×¤¨¤Ð¡¢¥×¥é¥¤¥Ù¡¼¥È¤Ê´Ø¿ô¤ä °À­¤ò¼«Í³¤ËÄ󶡤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¥×¥é¥¤¥Ù¡¼¥È¤Ê¥É¥é¥¤¥Ð´Ø¿ô¤Ï DBI ¤Î C ¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ ¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¥×¥é¥¤¥Ù¡¼¥È¤Ê¥É¥é¥¤¥Ð°À­¤Ïɸ½à¤Î°À­¤È¤Þ¤Ã¤¿¤¯Æ±¤¸¤è¤¦¤Ë ¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original Many methods have an optional C<\%attr> parameter which can be used to pass information to the driver implementing the method. Except where specifically documented, the C<\%attr> parameter can only be used to pass driver specific hints. In general, you can ignore C<\%attr> parameters or pass it as C. =end original ¿¤¯¤Î¥á¥½¥Ã¥É¤Ï¥ª¥×¥·¥ç¥ó¤È¤·¤Æ C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤ò¼õ¤±¼è¤ê¤Þ¤¹¡£ ¤³¤ì¤ò»È¤Ã¤Æ¥É¥é¥¤¥Ð¤¬¼ÂÁõ¤·¤Æ¤¤¤ë¥á¥½¥Ã¥É¤Ë¾ðÊó¤òÅϤ¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ Æä˵­½Ò¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤ÏÆÃÄê¤Î¥Ò¥ó¥È¤òÅϤ¹¾ì¹ç¤Ë¤Î¤ß »ÈÍѤµ¤ì¤Þ¤¹¡£ ÉáÄÌ¤Ï C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤ò̵»ë¤¹¤ë¤« C ¤òÅϤ¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =head2 Naming Conventions and Name Space (̿̾µ¬Â§¤È̾Á°¶õ´Ö) =begin original The DBI package and all packages below it (C) are reserved for use by the DBI. Extensions and related modules use the C namespace (see L). Package names beginning with C are reserved for use by DBI database drivers. All environment variables used by the DBI or by individual DBDs begin with "C" or "C". =end original DBI ¥Ñ¥Ã¥±¡¼¥¸¤È¤½¤Î²¼¤Î¥Ñ¥Ã¥±¡¼¥¸(C)¡¡¤Ï¡¢DBI ¤Ë¤è¤Ã¤Æ ͽÌ󤵤ì¤Æ¤Þ¤¹¡£ ¥¨¥¯¥¹¥Æ¥ó¥·¥ç¥ó¤È´ØÏ¢¤¹¤ë¥â¥¸¥å¡¼¥ë¤Ï C ̾Á°¶õ´Ö (http://www.perl.com/CPAN/modules/by-module/DBIx/¤ò¤´Í÷²¼¤µ¤¤)¤ò»È¤¤¤Þ¤¹¡£ C ¤Ç»Ï¤Þ¤ë¥Ñ¥Ã¥±¡¼¥¸Ì¾¤Ï DBI ¥Ç¡¼¥¿¥Ù¡¼¥¹¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ »È¤¦¤è¤¦¤ËͽÌ󤵤ì¤Æ¤¤¤Þ¤¹¡£ DBI ¤Þ¤¿¤Ï³Æ DBD ¤Ë¤è¤Ã¤Æ»È¤ï¤ì¤ë¤¹¤Ù¤Æ¤Î´Ä¶­ÊÑ¿ô¤Ï "C" ¤Þ¤¿¤Ï "C" ¤Ç»Ï¤Þ¤ê¤Þ¤¹¡£ =begin original The letter case used for attribute names is significant and plays an important part in the portability of DBI scripts. The case of the attribute name is used to signify who defined the meaning of that name and its values. =end original °À­¤Î̾Á°¤Ë»È¤ï¤ì¤ëʸ»ú¤ÎÂçʸ»ú/¾®Ê¸»ú¤Î¶èÊ̤ϡ¢DBI ¥¹¥¯¥ê¥×¥È¤Î °Ü¿¢À­¤Ë¤ª¤¤¤Æ½ÅÍפÇÂ礭¤ÊÌò³ä¤ò²Ì¤¿¤·¤Æ¤¤¤Þ¤¹¡£ °À­¤Î̾Á°¤¬Âçʸ»ú¤«¾®Ê¸»ú¤«¤Ë¤è¤Ã¤Æ¡¢Ì¾Á°¤ÈÃͤò郎·è¤á¤¿¤Î¤«¤ò¼¨¤¹¤Î¤Ë »È¤ï¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original Case of name Has a meaning defined by ------------ ------------------------ UPPER_CASE Standards, e.g., X/Open, ISO SQL92 etc (portable) MixedCase DBI API (portable), underscores are not used. lower_case Driver or database engine specific (non-portable) =end original ̾Á°¤ÎÂçʸ»ú¡¿¾®Ê¸»ú ÀâÌÀ ---------------------- ------------------------------------------- Âçʸ»ú¤Î¤ß(UPPER_CASE) ɸ½à¡¢¤Ä¤Þ¤ê X/Open, SQL92 ¤Ê¤É(°Ü¿¢À­¤¢¤ê) º®¹ç(MixedCase) DBI API(°Ü¿¢À­À­¤¢¤ê)¥¢¥ó¥À¡¼¥¹¥³¥¢(_)¤Ï»È¤ï¤Ê¤¤ ¾®Ê¸»ú¤Î¤ß(lower_case) ¥É¥é¥¤¥Ð¤â¤·¤¯¤Ï¥¨¥ó¥¸¥ó¤ËÆÃÍ­(°Ü¿¢À­¤Ê¤·) =begin original It is of the utmost importance that Driver developers only use lowercase attribute names when defining private attributes. Private attribute names must be prefixed with the driver name or suitable abbreviation (e.g., "C" for Oracle, "C" for Ingres, etc). =end original ºÇ¤â½ÅÍפʤΤϥɥ饤¥Ð³«È¯¼Ô¤Ï¥×¥é¥¤¥Ù¡¼¥È¤Ê°À­¤òÄêµÁ¤¹¤ë¤È¤­¡¢¾®Ê¸»ú¤Î °À­¤·¤«»È¤Ã¤Æ¤Ï¤¤¤±¤Ê¤¤¤È¤¤¤³¤È¤Ç¤¹¡£ ¥×¥é¥¤¥Ù¡¼¥È¤Ê°À­¤Î̾Á°¤Ï¡¢¥É¥é¥¤¥Ð̾¤â¤·¤¯¤ÏŬÀÚ¤Êά¸ì¤«¤é»Ï¤Þ¤é¤Ê¤±¤ì¤Ð ¤Ê¤ê¤Þ¤»¤ó¡£ (Î㤨¤Ð C ¤ÏOracle, C ¤Ï Ingres ¤Ê¤É). =head2 SQL - A Query Language (SQL - Ì䤤¹ç¤ï¤»¸À¸ì) =begin original Most DBI drivers require applications to use a dialect of SQL (Structured Query Language) to interact with the database engine. The L section provides links to useful information about SQL. =end original ÂçȾ¤Î DBI ¥É¥é¥¤¥Ð¤Ç¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤È¤Î¤ä¤ê¤È¤ê¤Ë¡¢¤½¤ì¤¾¤ì¤Î SQL(Structured Query Language) ¤ò»È¤¦¤³¤È¤¬Í×µá¤È¤·¤Þ¤¹¡£ L ¾Ï¤Ï SQL ¤Ë´Ø¤¹¤ëÍ­ÍѤʾðÊó¤Ø¤Î ¥ê¥ó¥¯¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£ =begin original The DBI itself does not mandate or require any particular language to be used; it is language independent. In ODBC terms, the DBI is in "pass-thru" mode, although individual drivers might not be. The only requirement is that queries and other statements must be expressed as a single string of characters passed as the first argument to the L or L methods. =end original DBI ¼«¿È¤ÏÆÃÄê¤Î¸À¸ì¤ò»È¤¦¤³¤È¤òɬ¿Ü¤È¤âɬÍפȤ⤷¤Æ¤¤¤Þ¤»¤ó;¸À¸ì¤«¤é ÆÈΩ¤·¤Æ¤¤¤Þ¤¹¡£ ODBC ¤ÎÍѸì¤Ç¤¤¤¦¤ÈDBI ¤Ï¡Ö¥Ñ¥¹¥¹¥ë¡¼¡×¥â¡¼¥É(='pass-thru' mode)¤Ë ¤¢¤¿¤ê¤Þ¤¹¡£ ³Æ¥É¥é¥¤¥Ð¤Ï¤½¤¦¤Ç¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£ Í£°ìɬÍפʤ³¤È¤Ï¡¢L ¤Þ¤¿¤Ï L ¥á¥½¥Ã¥É¤Ø¤ÎºÇ½é¤Î°ú¿ô¤È¤·¤Æ ÅϤµ¤ì¤ëÌ䤤¹ç¤»¤Þ¤¿¤Ï¤½¤Î¾¤Îʸ¤Ï¡¢Ê¸»ú¤Ë¤è¤ë°ì¤Ä¤Îʸ»úÎó¤È¤·¤Æ ɽ¸½¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤Ç¤¹¡£ =begin original For an interesting diversion on the I history of RDBMS and SQL, from the people who made it happen, see: =end original RDBMS ¤È SQL ¤Î I<ËÜÅö¤Î> Îò»Ë¤Ë¤Ä¤¤¤Æ¤Î¶½Ì£¿¼¤¤¤³¤Ü¤ìÏ䬡¢¼ÂºÝ¤Ë¤½¤ì¤ò ¤ä¤Ã¤¿¿Í㤫¤é½Ð¤µ¤ì¤Æ¤¤¤Þ¤¹: http://ftp.digital.com/pub/DEC/SRC/technical-notes/SRC-1997-018-html/sqlr95.html =begin original Follow the "Full Contents" then "Intergalactic dataspeak" links for the SQL history. =end original SQL¤ÎÎò»Ë¤Ë¤Ä¤¤¤Æ¤Ï "Full Contents" ¤«¤é "Intergalactic dataspeak" ¥ê¥ó¥¯¤òÄɤäƤߤƤ¯¤À¤µ¤¤¡£ =head2 Placeholders and Bind Values (¥×¥ì¡¼¥¹¥Û¥ë¥À¤È¥Ð¥¤¥ó¥ÉÃÍ) =begin original Some drivers support placeholders and bind values. I, also called parameter markers, are used to indicate values in a database statement that will be supplied later, before the prepared statement is executed. For example, an application might use the following to insert a row of data into the SALES table: =end original ¤¢¤ë¼ï¤Î¥É¥é¥¤¥Ð¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤È¥Ð¥¤¥ó¥ÉÃͤò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï¥Ñ¥é¥á¡¼¥¿¡¦¥Þ¡¼¥«¡¼¤È¤â¸Æ¤Ð¤ì¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹Ê¸¤Î Ãæ¤ÎÃͤ¬¸å¤Ç¡¢½àÈ÷(prepare)¤µ¤ì¤¿Ê¸¤¬¼Â¹Ô¤µ¤ì¤ëÁ°¤Ë Í¿¤¨¤é¤ì¤ë¤³¤È¤ò¼¨¤¹¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ Î㤨¤Ð¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¡¢SALES ¥Æ¡¼¥Ö¥ë¤Ë¹Ô¤òÁÞÆþ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹: INSERT INTO sales (product_code, qty, price) VALUES (?, ?, ?) =begin original or the following, to select the description for a product: =end original ¤¢¤ë¤¤¤Ï PRODUCTS ¥Æ¡¼¥Ö¥ë¤«¤éÀ½ÉʤÎÀâÌÀ (description) ¤ò¼èÆÀ¤Ç¤­¤Þ¤¹ SELECT description FROM products WHERE product_code = ? =begin original The C characters are the placeholders. The association of actual values with placeholders is known as I, and the values are referred to as I. Note that the C is not enclosed in quotation marks, even when the placeholder represents a string. =end original C ¤È¤¤¤¦Ê¸»ú¤¬¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ç¤¹¡£ ¼ÂºÝ¤ÎÃͤȥץ졼¥¹¥Û¥ë¥À¤È¤Î·ë¤Ó¤Ä¤±¤¬ I<¥Ð¥¤¥ó¥É>(binding)¤Ç¡¢ÃÍ¤Ï I<¥Ð¥¤¥ó¥ÉÃÍ>(bind values) ¤È¤·¤Æ¸Æ¤Ð¤ì¤Þ¤¹¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤¬Ê¸»úÎó¤òɽ¤ï¤·¤Æ¤¤¤ë¤È¤·¤Æ¤â¡¢C ¤¬ ¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¥Þ¡¼¥¯¤Ç°Ï¤Þ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Some drivers also allow placeholders like C<:>I and C<:>I (e.g., C<:1>, C<:2>, and so on) in addition to C, but their use is not portable. =end original ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢C ¤À¤±¤Ç¤Ê¤¯¡¢C<:>I<̾Á°> ¤ä C<:>I<ÈÖ¹æ> (Î㤨¤Ð C<:1>, C<:2> ¤Ê¤É)¤È¤¤¤Ã¤¿·Á¼°¤Î¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò µö¤·¤Æ¤¤¤ë¤â¤Î¤â¤¢¤ê¤Þ¤¹¤¬¡¢¤½¤ì¤Ï°Ü¿¢²Äǽ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original If the C<:>I form of placeholder is supported by the driver you're using, then you should be able to use either L or L to bind values. Check your driver documentation. =end original »È¤Ã¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤¬ C<:>I ·Á¼°¤Î¥×¥ì¡¼¥¹¥Õ¥©¥ë¥À¤ËÂбþ¤·¤Æ¤¤¤ë¤Ê¤é¡¢ Ãͤò¥Ð¥¤¥ó¥É¤¹¤ë¤Î¤Ë L ¤¢¤ë¤¤¤Ï L ¤ò»È¤¨¤ë¤Ù¤­¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤Îʸ½ñ¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£ =begin original With most drivers, placeholders can't be used for any element of a statement that would prevent the database server from validating the statement and creating a query execution plan for it. For example: =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤Ç¤Îʸ¤Îɾ²Á¤¬¤Ç¤­¤º¡¢¤½¤Î¤¿¤áÌ䤤¹ç¤ï¤» ·×²è¤òºîÀ®¤Ç¤­¤Ê¤¯¤Ê¤ë¤¿¤á¤Ë¡¢Â¿¤¯¤Î¥É¥é¥¤¥Ð¤Ç¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò¤¹¤Ù¤Æ¤Î ʸ¤ÎÍ×ÁǤȤ·¤Æ»È¤¨¤ë¤È¤¤¤¦¤³¤È¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ Î㤨¤Ð: "SELECT name, age FROM ?" # wrong (will probably fail) "SELECT name, ? FROM people" # wrong (but may not 'fail') =begin original Also, placeholders can only represent single scalar values. For example, the following statement won't work as expected for more than one value: =end original ¤Þ¤¿¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï°ì¤Ä¤Î¥¹¥«¥éÃͤÀ¤±¤òɽ¤ï¤·¤Þ¤¹¡£ Î㤨¤Ð°Ê²¼¤Îʸ¤ÏÊ£¿ô¤ÎÃͤò´üÂÔ¤·¤Æ¤â¤¦¤Þ¤¯¤¤¤«¤¤¤Ê¤¤¤Ç¤·¤ç¤¦: "SELECT name, age FROM people WHERE name IN (?)" # wrong "SELECT name, age FROM people WHERE name IN (?,?)" # two names =begin original When using placeholders with the SQL C qualifier, you must remember that the placeholder substitutes for the whole string. So you should use "C<... LIKE ? ...>" and include any wildcard characters in the value that you bind to the placeholder. =end original ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò SQL ¤Î C ½¤¾þ»Ò¤È»È¤¦¾ì¹ç¤Ë¤Ï¡¢¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï ʸ»úÎóÁ´ÂΤòÃÖ¤­´¹¤¨¤ë¤³¤È¤ò˺¤ì¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£ ¤½¤Î¤¿¤á "C<... LIKE ? ...>" ¤ò»È¤¤¡¢¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ë¥Ð¥¤¥ó¥É¤¹¤ëÃÍ¤Ë ¥ï¥¤¥ë¥É¥«¡¼¥É¤È¤Ê¤ëʸ»ú¤ò¤¹¤Ù¤ÆÆþ¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original B =end original B =begin original Undefined values, or C, are used to indicate NULL values. You can insert and update columns with a NULL value as you would a non-NULL value. These examples insert and update the column C with a NULL value: =end original ̤ÄêµÁÃÍ (C) ¤Ï NULL Ãͤò¼¨¤¹¤Î¤Ë»È¤ï¤ì¤Þ¤¹¡£ Èó NULL ÃͤÈƱÍÍ¡¢NULL ÃͤÇÎó¤òÁÞÆþ¤ª¤è¤Ó¹¹¿·¤Ç¤­¤Þ¤¹¡£ °Ê²¼¤Ï C Îó¤ò NULL ÃͤÇÁÞÆþ¤ª¤è¤Ó¹¹¿·¤¹¤ëÎã¤Ç¤¹: $sth = $dbh->prepare(qq{ INSERT INTO people (fullname, age) VALUES (?, ?) }); $sth->execute("Joe Bloggs", undef); $sth = $dbh->prepare(qq{ UPDATE people SET age = ? WHERE fullname = ? }); $sth->execute(undef, "Joe Bloggs"); =begin original However, care must be taken when trying to use NULL values in a C clause. Consider: =end original ¤·¤«¤· C ¶ç¤Ç NULL Ãͤò»È¤¦¾ì¹ç¤Ë¤ÏÆäËÃí°Õ¤¬É¬ÍפǤ¹¡£ °Ê²¼¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ä¤¤¤Æ¹Í¤¨¤Æ¤ß¤Þ¤·¤ç¤¦: SELECT fullname FROM people WHERE age = ? =begin original Binding an C (NULL) to the placeholder will I select rows which have a NULL C! At least for database engines that conform to the SQL standard. Refer to the SQL manual for your database engine or any SQL book for the reasons for this. To explicitly select NULLs you have to say "C". =end original C (NULL) ¤ò¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ë¥Ð¥¤¥ó¥É¤·¤Æ¤â¡¢NULL¤Î C ¤ò»ý¤Ä¹Ô¤Ï ²¿¤â I<ÁªÂò¤µ¤ì¤Þ¤»¤ó>¡ª ¾¯¤Ê¤¯¤È¤â SQL ɸ½à¤Ë½àµò¤¤¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ç¤Ï¤½¤¦¤Ç¤¹¡£ ¤³¤ÎÍýͳ¤Ë¤Ä¤¤¤Æ¤Ï¡¢»ÈÍѤ·¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Î SQL ¤Î¥Þ¥Ë¥å¥¢¥ë ¤Þ¤¿¤Ï SQL ¤Î²òÀâ½ñ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ ÌÀ¼¨Åª¤Ë NULL ¤ò SELECT ¤¹¤ë¤¿¤á¤Ë¤Ï "C"¤È¤¹¤ëɬÍפ¬ ¤¢¤ê¤Þ¤¹¡£ =begin original A common issue is to have a code fragment handle a value that could be either C or C (non-NULL or NULL) at runtime. A simple technique is to prepare the appropriate statement as needed, and substitute the placeholder for non-NULL cases: =end original ¤è¤¯¤¢¤ëÌäÂê¤Î°ì¤Ä¤Ï¡¢¼Â¹Ô»þ¤Ë C ¤« C ¤« (Èó NULL ¤« NULL ¤«)·èÄꤵ¤ì¤ëÃͤò°·¤¦¤¿¤á¤Î¥³¡¼¥É¤¬¤¢¤ë¤È¤­¤Ç¤¹¡£ ´Êñ¤Ê¥Æ¥¯¥Ë¥Ã¥¯¤Ï¡¢É¬Íפ˱þ¤¸¤ÆŬÀÚ¤Êʬ¤ò½àÈ÷¤·¤Æ¡¢Èó NULL ¤Î¾ì¹ç¤Î ¥×¥ì¡¼¥¹¥Õ¥©¥ë¥À¤òÃÖ¤­´¹¤¨¤ë¤³¤È¤Ç¤¹: $sql_clause = defined $age? "age = ?" : "age IS NULL"; $sth = $dbh->prepare(qq{ SELECT fullname FROM people WHERE $sql_clause }); $sth->execute(defined $age ? $age : ()); =begin original The following technique illustrates qualifying a C clause with several columns, whose associated values (C or C) are in a hash %h: =end original °Ê²¼¤Î¥Æ¥¯¥Ë¥Ã¥¯¤Ï¡¢·ë¤Ó¤Ä¤±¤ëÃÍ (C or C) ¤¬¥Ï¥Ã¥·¥å %h ¤Ë Æþ¤Ã¤Æ¤¤¤ëÊ£¿ô¤ÎÎó¤Î C ¶ç¤ÎºîÀ®ÊýË¡¤ò¼¨¤·¤Æ¤¤¤Þ¤¹: for my $col ("age", "phone", "email") { if (defined $h{$col}) { push @sql_qual, "$col = ?"; push @sql_bind, $h{$col}; } else { push @sql_qual, "$col IS NULL"; } } $sql_clause = join(" AND ", @sql_qual); $sth = $dbh->prepare(qq{ SELECT fullname FROM people WHERE $sql_clause }); $sth->execute(@sql_bind); =begin original The techniques above call prepare for the SQL statement with each call to execute. Because calls to prepare() can be expensive, performance can suffer when an application iterates many times over statements like the above. =end original ¾å½Ò¤Î¥Æ¥¯¥Ë¥Ã¥¯¤Ï¼Â¹Ô¤¹¤ë¤½¤ì¤¾¤ì¤Î¸Æ¤Ó½Ð¤·¤Î SQL ʸ¤Î¤¿¤á¤Ë prepare ¤ò ¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ prepare() ¤Î¸Æ¤Ó½Ð¤·¤Ï¥³¥¹¥È¤¬¹â¤¤¤Î¤Ç¡¢¾å½Ò¤Î¤è¤¦¤Ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬ ʸ¤ò²¿²ó¤â·«¤êÊÖ¤¹¤ÈÀ­Ç½¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original A better solution is a single C clause that supports both NULL and non-NULL comparisons. Its SQL statement would need to be prepared only once for all cases, thus improving performance. Several examples of C clauses that support this are presented below. But each example lacks portability, robustness, or simplicity. Whether an example is supported on your database engine depends on what SQL extensions it provides, and where it supports the C placeholder in a statement. =end original ¤è¤ê¤è¤¤²ò·èË¡¤Ï¡¢NULL ¤ÈÈó NULL Èæ³Ó¤ÎξÊý¤ËÂбþ¤·¤¿Ã±°ì¤Î C ¶ç¤Ç¤¹¡£ ¤³¤Î SQL ʸ¤ÏÁ´¤Æ¤Î¾ì¹ç¤ËÃÖ¤¤¤Æ 1 ²ó¤À¤± prepare ¤¹¤ëɬÍפ¬¤¢¤ë¤Î¤Ç¡¢ À­Ç½¤¬¸þ¾å¤·¤Þ¤¹¡£ ¤³¤ì¤ËÂбþ¤¹¤ë¤¿¤á¤Î¤¤¤¯¤Ä¤«¤Î C ¶ç¤ÎÎã¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£ ¤·¤«¤·¤½¤ì¤¾¤ì¤ÎÎã¤Ë¤Ï¸ß´¹À­¡¢·øÏ´À­¡¢Ã±½ãÀ­¤Ë·ç¤±¤Æ¤¤¤Þ¤¹¡£ ¤¢¤Ê¤¿¤¬»È¤¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ç¤É¤ÎÎ㤬Âбþ¤·¤Æ¤¤¤ë¤«¤Ï¡¢ ¤É¤Î SQL ³ÈÄ¥¤òÄ󶡤·¤Æ¤¤¤ë¤«¤È¡¢Ê¸Ãæ¤Î¤É¤³¤Ë C ¥×¥ì¡¼¥¹¥Û¥ë¥À¤¬ Âбþ¤·¤Æ¤¤¤ë¤«¤Ë°Í¸¤·¤Þ¤¹¡£ 0) age = ? 1) NVL(age, xx) = NVL(?, xx) 2) ISNULL(age, xx) = ISNULL(?, xx) 3) DECODE(age, ?, 1, 0) = 1 4) age = ? OR (age IS NULL AND ? IS NULL) 5) age = ? OR (age IS NULL AND SP_ISNULL(?) = 1) 6) age = ? OR (age IS NULL AND ? = 1) =begin original Statements formed with the above C clauses require execute statements as follows. The arguments are required, whether their values are C or C. =end original ¾å½Ò¤Î C ¶ç¤Î·Á¼°¤Îʸ¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ëʸ¤ò¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ Ãͤ¬ C ¤« C ¤«¤ò¼¨¤¹°ú¿ô¤¬É¬ÍפǤ¹¡£ 0,1,2,3) $sth->execute($age); 4,5) $sth->execute($age, $age); 6) $sth->execute($age, defined($age) ? 0 : 1); =begin original Example 0 should not work (as mentioned earlier), but may work on a few database engines anyway (e.g. Sybase). Example 0 is part of examples 4, 5, and 6, so if example 0 works, these other examples may work, even if the engine does not properly support the right hand side of the C expression. =end original Îã 0 ¤Ï(Á°½Ò¤·¤¿¤è¤¦¤Ë)Æ°ºî¤·¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¡¢¤½¤ì¤Ç¤â(Sybase ¤Î¤è¤¦¤Ê) ¤¤¤¯¤Ä¤«¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ç¤ÏÆ°ºî¤·¤Þ¤¹¡£ Îã 0 ¤ÏÎã 4, 5, 6 ¤Î°ìÉô¤Ê¤Î¤Ç¡¢Îã 0 ¤¬Æ°ºî¤¹¤ì¤Ð¡¢Î㤨¥¨¥ó¥¸¥ó¤¬ C ¼°¤Î ±¦Â¦¤òÀµ¤·¤¯Âбþ¤·¤Æ¤¤¤Ê¤¤¤È¤·¤Æ¤â¡¢Â¾¤ÎÎã¤âÆ°ºî¤·¤Þ¤¹¡£ =begin original Examples 1 and 2 are not robust: they require that you provide a valid column value xx (e.g. '~') which is not present in any row. That means you must have some notion of what data won't be stored in the column, and expect clients to adhere to that. =end original Îã 1 ¤È 2 ¤Ï´è¶¯¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó: ¤³¤ì¤é¤Ï¡¢¤É¤Î¹Ô¤Ë¤â¸ºß¤·¤Ê¤¤¡¢ Í­¸ú¤ÊÎó¤ÎÃÍ xx (Î㤨¤Ð '~') ¤òÄ󶡤¹¤ë¤³¤È¤òµá¤á¤é¤ì¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢¤É¤Î¥Ç¡¼¥¿¤¬¤½¤ÎÎó¤ËÊݴɤǤ­¤Ê¤¤¤Î¤«¤Ë¤Ä¤¤¤ÆÃí°Õ¤ò ʧ¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢¥¯¥é¥¤¥¢¥ó¥È¤¬¤½¤ì¤Ë½¾¤¦¤³¤È¤ò ÁÛÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original Example 5 requires that you provide a stored procedure (SP_ISNULL in this example) that acts as a function: it checks whether a value is null, and returns 1 if it is, or 0 if not. =end original Îã 5 ¤Ï¡¢´Ø¿ô¤Î¤è¤¦¤ËÆ°ºî¤¹¤ë¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã (Î㤨¤Ð SP_ISNULL) ¤ò Ä󶡤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹: ¤³¤ì¤ÏÃͤ¬ null ¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤·¤Æ¡¢¤½¤¦¤Ê¤é 1 ¤ò¡¢¤µ¤â¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤·¤Þ¤¹¡£ =begin original Example 6, the least simple, is probably the most portable, i.e., it should work with with most, if not all, database engines. =end original Îã 6 ¤Ï°ìÈÖÊ£»¨¤Ç¤¹¤¬¡¢¤ª¤½¤é¤¯°ìÈÖ°Ü¿¢À­¤¬¤¢¤ê¤Þ¤¹; ¤Ä¤Þ¤ê¡¢ (Á´¤Æ¤Ç¤Ê¤¤¤È¤·¤Æ¤â)¤Û¤È¤ó¤É¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤ÇÆ°ºî¤¹¤ë¤Ï¤º¤Ç¤¹¡£ =begin original Here is a table that indicates which examples above are known to work on various database engines: =end original °Ê²¼¤ÏÍÍ¡¹¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤ËÂФ·¤Æ¤É¤ÎÎ㤬ưºî¤¹¤ë¤Èʬ¤«¤Ã¤Æ¤¤¤ë¤«¤Î ɽ¤Ç¤¹: -----Examples------ 0 1 2 3 4 5 6 - - - - - - - Oracle 9 N Y N Y Y ? Y Informix IDS 9 N N N Y N Y Y MS SQL N N Y N Y ? Y Sybase Y N N N N N Y AnyData,DBM,CSV Y N N N Y Y* Y SQLite 3.3 N N N N Y N N =begin original * Works only because Example 0 works. =end original * Îã 0 ¤¬Æ°ºî¤¹¤ë¾ì¹ç¤Ë¤Î¤ßÆ°ºî¤·¤Þ¤¹¡£ =begin original DBI provides a sample perl script that will test the examples above on your database engine and tell you which ones work. It is located in the F subdirectory of the DBI source distribution, or here: L Please use the script to help us fill-in and maintain this table. =end original DBI ¤Ï¡¢¾å½Ò¤ÎÎã¤ò¤¢¤Ê¤¿¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¥Æ¥¹¥È¤·¤ÆÆ°ºî¤¹¤ë¤«¤É¤¦¤«¤ò ÃΤ餻¤Æ¤¯¤ì¤ë¥µ¥ó¥×¥ë perl ¥¹¥¯¥ê¥×¥È¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï DBI ¥½¡¼¥¹ÇÛÉۤΠF ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤«¡¢°Ê²¼¤Î¾ì½ê¤Ë¤¢¤ê¤Þ¤¹: L ¥¹¥¯¥ê¥×¥È¤ò¡¢¤³¤Îɽ¤òËä¤á¤ÆÊݼ餹¤ë½õ¤±¤Ë»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =begin original B =end original B<À­Ç½> =begin original Without using placeholders, the insert statement shown previously would have to contain the literal values to be inserted and would have to be re-prepared and re-executed for each row. With placeholders, the insert statement only needs to be prepared once. The bind values for each row can be given to the C method each time it's called. By avoiding the need to re-prepare the statement for each row, the application typically runs many times faster. Here's an example: =end original ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò»È¤ï¤Ê¤±¤ì¤Ð¡¢¾åµ­¤Î INSERT ʸ¤ÏÁÞÆþ¤¹¤ëÃͤò¥ê¥Æ¥é¥ë¤Ç Æþ¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¤·¡¢³Æ¹ÔËè¤ËºÆ½àÈ÷(re-prepare)¤·¡¢ ºÆ¼Â¹Ô(re-execute)¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò»È¤¦¤È¡¢INSERT ʸ¤ò½àÈ÷(prepare)¤¹¤ëɬÍפ¬¤¢¤ë¤Î¤Ï 1 ²ó¤À¤±¤Ç¤¹¡£ ³Æ¹Ô¤Î¥Ð¥¤¥ó¥ÉÃÍ¤Ï C ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤È¤­¤ËÍ¿¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ³Æ¹ÔËè¤ËºÆ½àÈ÷(re-prepare)¤¹¤ëɬÍפ¬¤Ê¤¯¤Ê¤ë¤Î¤Ç¡¢¥¢¥×¥ê¡¼¥±¡¼¥·¥ç¥ó¤Ï Ä̾²¿Çܤ⮤¯¤Ê¤ê¤Þ¤¹¡£ °Ê²¼¤ËÎã¤ò¼¨¤·¤Þ¤¹: my $sth = $dbh->prepare(q{ INSERT INTO sales (product_code, qty, price) VALUES (?, ?, ?) }) or die $dbh->errstr; while (<>) { chomp; my ($product_code, $qty, $price) = split /,/; $sth->execute($product_code, $qty, $price) or die $dbh->errstr; } $dbh->commit or die $dbh->errstr; =begin original See L and L for more details. =end original ¾ÜºÙ¤Ï L ¤ª¤è¤Ó L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original The C style quoting used in this example avoids clashing with quotes that may be used in the SQL statement. Use the double-quote like C operator if you want to interpolate variables into the string. See L for more details. =end original ¤³¤ÎÎã¤Ç¤Ï¡¢SQL ʸ¤Î¤Ê¤«¤Ç»È¤ï¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¥¯¥©¡¼¥È¤ÎÂбþ¤¬Êø¤ì¤Ê¤¤¤è¤¦¡¢ C ¥¹¥¿¥¤¥ë¤Î¥¯¥©¡¼¥È¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ ʸ»úÎó¤Ë²ò¼á¤·¤ÆÍߤ·¤¤ÊÑ¿ô¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢C ¤Î¤è¤¦¤Ê ¥À¥Ö¥ë¥¯¥©¡¼¥È¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original See also the L method, which is used to associate Perl variables with the output columns of a C ʸ¤Î½ÐÎÏ¥«¥é¥à¤Ë·ë¤Ó¤Ä¤±¤ë¤¿¤á¤Ë»È¤ï¤ì¤ë L ¥á¥½¥Ã¥É¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =head1 THE DBI PACKAGE AND CLASS (DBI ¥Ñ¥Ã¥±¡¼¥¸¤È¥¯¥é¥¹) =begin original In this section, we cover the DBI class methods, utility functions, and the dynamic attributes associated with generic DBI handles. =end original ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ç¤Ï¡¢DBI ¥¯¥é¥¹¥á¥½¥Ã¥É¡¢¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô¤½¤·¤Æ °ìÈÌŪ¤Ê DBI ¥Ï¥ó¥É¥ë¤Ë´ØÏ¢¤¹¤ëưŪ°À­¤Ë¤Ä¤¤¤Æ¥«¥Ð¡¼¤·¤Þ¤¹¡£ =head2 DBI Constants (DBI Äê¿ô) =begin original Constants representing the values of the SQL standard types can be imported individually by name, or all together by importing the special C<:sql_types> tag. =end original °Ê²¼¤Î SQL ɸ½à·¿Äê¿ô¤Ï¸ÄÊ̤˥¤¥ó¥Ý¡¼¥È¤·¤¿¤ê¡¢Æüì¤Ê C<:sql_types> ¥¿¥°¤Ç ¤¹¤Ù¤Æ¤ò¥¤¥ó¥Ý¡¼¥È¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹: =begin original The names and values of all the defined SQL standard types can be produced like this: =end original ÄêµÁ¤µ¤ì¤Æ¤¤¤ëÁ´¤Æ¤Î SQL ɸ½à·¿¤Î̾Á°¤ÈÃͤϰʲ¼¤Î¤è¤¦¤Ë¤·¤Æ¼èÆÀ¤Ç¤­¤Þ¤¹: foreach (@{ $DBI::EXPORT_TAGS{sql_types} }) { printf "%s=%d\n", $_, &{"DBI::$_"}; } =begin original These constants are defined by SQL/CLI, ODBC or both. C is (currently) omitted, because SQL/CLI and ODBC provide conflicting codes. =end original ¤³¤ì¤é¤ÎÄê¿ô¤Ï SQL/CLI, ODBC ¤¢¤ë¤¤¤ÏξÊý¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ SQL/CLI ¤È ODBC ¤Ç¥³¡¼¥É¤¬¾×Æͤ·¤Æ¤¤¤ë¤Î¤Ç¡¢C is (¸½¾õ¤Ç¤Ï) ¾Êά¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original See the L, L, and L methods for possible uses. =end original ²Äǽ¤ÊÍøÍÑË¡¤Ë´Ø¤·¤Æ¤Ï L, L, L ¥á¥½¥Ã¥É¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Note that just because the DBI defines a named constant for a given data type doesn't mean that drivers will support that data type. =end original ¤¢¤ë¥Ç¡¼¥¿·¿¤Ë¤Ä¤¤¤Æ DBI ¤¬Ì¾Á°ÉÕ¤­Äê¿ô¤òÄêµÁ¤·¤Æ¤¤¤Ê¤¤¤«¤é¤È¸À¤Ã¤Æ¡¢ ¥É¥é¥¤¥Ð¤¬¤½¤Î¥Ç¡¼¥¿·¿¤ËÂбþ¤·¤Æ¤¤¤Ê¤¤¤È¤¤¤¦¤ï¤±¤Ç¤Ï¤Ê¤¤¤³¤È¤Ë Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 DBI Class Methods (DBI ¥¯¥é¥¹¥á¥½¥Ã¥É) =begin original The following methods are provided by the DBI class: =end original DBI ¥¯¥é¥¹¤Ë¤è¤Ã¤Æ°Ê²¼¤Î¥á¥½¥Ã¥É¤¬Ä󶡤µ¤ì¤Æ¤¤¤Þ¤¹: =head3 C ($scheme, $driver, $attr_string, $attr_hash, $driver_dsn) = DBI->parse_dsn($dsn) or die "Can't parse DBI DSN '$dsn'"; =begin original Breaks apart a DBI Data Source Name (DSN) and returns the individual parts. If $dsn doesn't contain a valid DSN then parse_dsn() returns an empty list. =end original DBI ¥Ç¡¼¥¿¥½¡¼¥¹Ì¾(Data Source Name) (DSN) ¤òʬ²ò¤·¤Æ¡¢¤½¤ì¤¾¤ì¤ÎÉôʬ¤ò ÊÖ¤·¤Þ¤¹¡£ $dsn ¤ËÍ­¸ú¤Ê DSN ¤¬´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢parse_dsn() ¤Ï¶õ¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£ =begin original $scheme is the first part of the DSN and is currently always 'dbi'. $driver is the driver name, possibly defaulted to $ENV{DBI_DRIVER}, and may be undefined. $attr_string is the contents of the optional attribute string, which may be undefined. If $attr_string is not empty then $attr_hash is a reference to a hash containing the parsed attribute names and values. $driver_dsn is the last part of the DBI DSN string. For example: =end original $scheme ¤Ï DSN ¤ÎºÇ½é¤ÎÉôʬ¤Ç¡¢¸½ºß¤Î¤È¤³¤í¾ï¤Ë 'dbi' ¤Ç¤¹¡£ $driver ¤Ï¥É¥é¥¤¥Ð̾¤Ç¡¢¤ª¤½¤é¤¯¥Ç¥Õ¥©¥ë¥È¤Ï $ENV{DBI_DRIVER} ¤Ç¡¢ ̤ÄêµÁÃͤ«¤â¤·¤ì¤Þ¤»¤ó¡£ $attr_string ¤Ï¥ª¥×¥·¥ç¥ó¤Î°À­Ê¸»úÎó¤ÎÆâÍƤǡ¢Ì¤ÄêµÁÃͤ«¤â¤·¤ì¤Þ¤»¤ó¡£ $attr_string ¤¬¶õ¤Ç¤Ê¤¤¤Ê¤é¡¢$attr_hash ¤Ï¥Ñ¡¼¥¹¤µ¤ì¤¿Â°À­Ì¾¤ÈÃͤò´Þ¤à ¥Ï¥Ã¥·¥å¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¹¡£ $driver_dsn ¤Ï DBI DSN ʸ»úÎó¤ÎºÇ¸å¤ÎÉôʬ¤Ç¤¹¡£ Î㤨¤Ð: ($scheme, $driver, $attr_string, $attr_hash, $driver_dsn) = DBI->parse_dsn("DBI:MyDriver(RaiseError=>1):db=test;port=42"); $scheme = 'dbi'; $driver = 'MyDriver'; $attr_string = 'RaiseError=>1'; $attr_hash = { 'RaiseError' => '1' }; $driver_dsn = 'db=test;port=42'; =begin original The parse_dsn() method was added in DBI 1.43. =end original parse_dsn() ¥á¥½¥Ã¥É¤Ï DBI 1.43 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $dbh = DBI->connect($data_source, $username, $password) or die $DBI::errstr; $dbh = DBI->connect($data_source, $username, $password, \%attr) or die $DBI::errstr; =begin original Establishes a database connection, or session, to the requested C<$data_source>. Returns a database handle object if the connection succeeds. Use C<$dbh-Edisconnect> to terminate the connection. =end original Í׵ᤵ¤ì¤¿ C<$data_source> ¤Ø¤ÎÀܳ¤Þ¤¿¤Ï¥»¥Ã¥·¥ç¥ó¤ò³ÎΩ¤·¤Þ¤¹¡£ Àܳ¤¬À®¸ù¤¹¤ë¤È¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Ï¥ó¥É¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£ Àܳ¤ò½ª¤ï¤é¤»¤ë¤¿¤á¤Ë¤Ï C<$dbh-Edisconnect> ¤ò»È¤¤¤Þ¤¹¡£ =begin original If the connect fails (see below), it returns C and sets both C<$DBI::err> and C<$DBI::errstr>. (It does I explicitly set C<$!>.) You should generally test the return status of C and C if it has failed. =end original connect ¤¬¼ºÇÔ¤·¤¿¤é(²¼µ­¤ò¤´Í÷²¼¤µ¤¤)C¤òÊÖ¤·¡¢ C<$DBI::err>, C<$DBI::errstr> ¤òÀßÄꤷ¤Þ¤¹ (C<$!> ¤ÏÌÀ¼¨Åª¤Ë¤Ï I<ÀßÄꤷ¤Þ¤»¤ó>)¡£ °ìÈÌŪ¤Ë¤Ï C ¤ÎÌá¤ê¥¹¥Æ¡¼¥¿¥¹¤ò³Îǧ¤·¡¢¼ºÇÔ¤·¤Æ¤¤¤¿¤é C<$DBI::errstr> ¤òɽ¼¨¤·¤Þ¤¹¡£ =begin original Multiple simultaneous connections to multiple databases through multiple drivers can be made via the DBI. Simply make one C call for each database and keep a copy of each returned database handle. =end original DBI ·Ðͳ¤Ç¡¢Ê£¿ô¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂФ·¤Æ¤ÎÊ£¿ô¤Î¥É¥é¥¤¥Ð¤ò»È¤Ã¤Æ¡¢Æ±»þ¤Ë Ê£¿ôÀܳ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ñ½ã¤Ë³Æ¥Ç¡¼¥¿¥Ù¡¼¥¹Ëè¤Ë C ¤ò¸Æ¤Ó½Ð¤·¡¢ÊÖ¤µ¤ì¤¿ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î¥³¥Ô¡¼¤ò¤È¤Ã¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C<$data_source> value must begin with "CIC<:>". The I specifies the driver that will be used to make the connection. (Letter case is significant.) =end original C<$data_source> ¤ÎÃÍ¤Ï "CI<¥É¥é¥¤¥Ð̾>C<:>" ¤Ç »Ï¤Þ¤é¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ I<¥É¥é¥¤¥Ð̾> ¤¬Àܳ¤¿¤á¤Ë»È¤ï¤ì¤ë¥É¥é¥¤¥Ð¤ò¼¨¤·¤Þ¤¹¡£ (Âçʸ»ú¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Þ¤¹). =begin original As a convenience, if the C<$data_source> parameter is undefined or empty, the DBI will substitute the value of the environment variable C. If just the I part is empty (i.e., the C<$data_source> prefix is "C"), the environment variable C is used. If neither variable is set, then C dies. =end original Êص¹¾å¡¢C<$data_source> ¥Õ¥£¡¼¥ë¥É¤¬Ì¤ÄêµÁ¤¢¤ë¤¤¤Ï¶õ¤À¤Ã¤¿¾ì¹ç¡¢DBI ¤Ï ¤³¤ÎÃͤò´Ä¶­ÊÑ¿ô C ¤ÎÃͤÇÃÖ´¹¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð̾¤ÎÉôʬ¤À¤±¤¬¶õ¤À¤Ã¤¿¾ì¹ç(¤Ä¤Þ¤ê C<$data_source> ¤Î»Ï¤Þ¤ê¤¬ "C") ¡¢´Ä¶­ÊÑ¿ô C ¤¬»È¤ï¤ì¤Þ¤¹¡£ ¤â¤·ÊÑ¿ô¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð C ¤Ï die ¤·¤Þ¤¹¡£ =begin original Examples of C<$data_source> values are: =end original C<$data_source> ¤ÎÃͤÎÎã¤Ï: dbi:DriverName:database_name dbi:DriverName:database_name@hostname:port dbi:DriverName:database=database_name;host=hostname;port=port =begin original There is I for the text following the driver name. Each driver is free to use whatever syntax it wants. The only requirement the DBI makes is that all the information is supplied in a single string. You must consult the documentation for the drivers you are using for a description of the syntax they require. =end original ¥É¥é¥¤¥Ð̾¤Î¸å¤í¤Ë¤Ä¤¯Ê¸»úÎó¤Ë¤Ä¤¤¤Æ¤Ï I<ɸ½à¤Ï¤¢¤ê¤Þ¤»¤ó>¡£ ³Æ¥É¥é¥¤¥Ð¤ÏÍߤ·¤¤½ñ¤­Êý¤ò¤É¤ó¤Ê¤â¤Î¤Ç¤â¼«Í³¤Ë»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ DBI ¤¬Í׵᤹¤ë¤Î¤Ï¡¢¤¹¤Ù¤Æ¤Î¾ðÊ󤬰ì¤Ä¤Îʸ»úÎó¤È¤·¤ÆÍ¿¤¨¤é¤ì¤ë¤³¤È¤À¤±¤Ç¤¹¡£ »È¤Ã¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤¬Í׵ᤷ¤Æ¤¤¤ë½ñ¤­Êý¤ÎÀâÌÀ¤ÎÀâÌÀ¤Ë¤Ä¤¤¤Æ¤Ï¡¢¤½¤Î ¥É¥­¥å¥á¥ó¥È¤òÄ´¤Ù¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original It is recommended that drivers support the ODBC style, shown in the last example above. It is also recommended that that they support the three common names 'C', 'C', and 'C' (plus 'C' as an alias for C). This simplifies automatic construction of basic DSNs: C<"dbi:$driver:database=$db;host=$host;port=$port">. Drivers should aim to 'do something reasonable' when given a DSN in this form, but if any part is meaningless for that driver (such as 'port' for Informix) it should generate an error if that part is not empty. =end original ¥É¥é¥¤¥Ð¤Ï¾å½Ò¤ÎºÇ¸å¤ÎÎã¤Ç¤¢¤ë ODBC ·Á¼°¤ËÂбþ¤¹¤ë¤³¤È¤¬¿ä¾©¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤Þ¤¿¡¢»°¤Ä¤Î¶¦Ä̤Î̾Á° 'C', 'C', 'C' (¤ª¤è¤Ó C ¤ÎÊÌ̾¤È¤·¤Æ¤Î 'C') ¤ËÂбþ¤¹¤ë¤³¤È¤â¿ä¾©¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê´ðËÜŪ¤Ê DSN ¤Î¼«Æ°Åª¤Ê¹½ÃÛ¤¬´Êñ¤Ë¤Ê¤ê¤Þ¤¹: C<"dbi:$driver:database=$db;host=$host;port=$port">¡£ ¥É¥é¥¤¥Ð¤Ï¡¢DSN ¤¬¤³¤Î·Á¼°¤ÇÍ¿¤¨¤é¤ì¤¿¤È¤­¡¢¡Ö²¿¤«°ÕÌ£¤Î¤¢¤ë¤³¤È¤ò¤¹¤ë¡× ¤³¤È¤òÌܻؤ¹¤Ù¤­¤Ç¤¹¤¬¡¢(Infomix ¤Ë¤È¤Ã¤Æ¤Î 'port' ¤Î¤è¤¦¤Ë)¤É¤ì¤«¤ÎÉôʬ¤¬ ¤³¤Î¥É¥é¥¤¥Ð¤Ë¤È¤Ã¤Æ°ÕÌ£¤¬¤Ê¤¤¾ì¹ç¡¢¤½¤ÎÉôʬ¤¬¶õ¤Ç¤Ê¤¤¤È¤­¤Ë¤Ï ¥¨¥é¡¼¤òȯÀ¸¤µ¤»¤ë¤Ù¤­¤Ç¤¹¡£ =begin original If the environment variable C is defined (and the driver in C<$data_source> is not "C") then the connect request will automatically be changed to: =end original ´Ä¶­ÊÑ¿ô C ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ì¤Ð(¤½¤·¤Æ C<$data_source> ¤Î ¥Ç¡¼¥¿¥½¡¼¥¹¤¬ "C" ¤Ç¤Ê¤±¤ì¤Ð)¡¢ÀܳÍ×µá¤Ï¼«Æ°Åª¤Ë°Ê²¼¤Î¤è¤¦¤Ë Êѹ¹¤µ¤ì¤Þ¤¹: $ENV{DBI_AUTOPROXY};dsn=$data_source =begin original C is typically set as "C". If $ENV{DBI_AUTOPROXY} doesn't begin with 'C' then "dbi:Proxy:" will be prepended to it first. See the DBD::Proxy documentation for more details. =end original C ¤Ï¡¢Ä̾ï "C" ¤È¤Ê¤ê¤Þ¤¹¡£ $ENV{DBI_AUTOPROXY} ¤¬ 'C' ¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÀèƬ¤Ë "dbi:Proxy:" ¤òÄɲä·¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï DBD::Proxy¥É¥­¥å¥á¥ó¥È ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original If C<$username> or C<$password> are undefined (rather than just empty), then the DBI will substitute the values of the C and C environment variables, respectively. The DBI will warn if the environment variables are not defined. However, the everyday use of these environment variables is not recommended for security reasons. The mechanism is primarily intended to simplify testing. See below for alternative way to specify the username and password. =end original C<$username> ¤Þ¤¿¤Ï C<$password> ¤¬Ì¤ÄêµÁ(¤¢¤ë¤¤¤Ïñ¤Ë¶õ)¤Ê¤é¤Ð¡¢ DBI ¤Ï¤½¤ì¤¾¤ì´Ä¶­ÊÑ¿ô C ¤È C ¤ÎÃͤÇÃÖ¤­´¹¤¨¤Þ¤¹¡£ ¤½¤Î´Ä¶­ÊÑ¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤Ê¤±¤ì¤Ð¡¢DBI ¤Ï·Ù¹ð¤·¤Þ¤¹¡£ ¤·¤«¤·¤Ê¤¬¤é¡¢¤³¤ì¤é¤Î´Ä¶­ÊÑ¿ô¤òÉáÃʻȤ¤¤¹¤ë¤³¤È¤Ï¡¢¥»¥­¥å¥ê¥Æ¥£¾å¤ÎÍýͳ¤«¤é ¤ª´«¤á¤·¤Þ¤»¤ó¡£ ¤³¤Îµ¡Ç½¤Ï´ðËÜŪ¤Ë¥Æ¥¹¥È¤ò´Êñ¤Ë¤¹¤ë¤³¤È¤òÌÜŪ¤È¤·¤Æ¤¤¤Þ¤¹¡£ ¥æ¡¼¥¶¡¼Ì¾¤È¥Ñ¥¹¥ï¡¼¥É¤ò»ØÄꤹ¤ë¤¿¤á¤ÎÂåÂذƤˤĤ¤¤Æ¤Ï¸å½Ò¤·¤Þ¤¹¡£ =begin original Cconnect> automatically installs the driver if it has not been installed yet. Driver installation either returns a valid driver handle, or it I with an error message that includes the string "C" and the underlying problem. So Cconnect> will die on a driver installation failure and will only return C on a connect failure, in which case C<$DBI::errstr> will hold the error message. Use C if you need to catch the "C" error. =end original Cconnect> ¤Ï¡¢¤Þ¤À¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¥É¥é¥¤¥Ð¤ò¼«Æ°Åª¤Ë ¥¤¥ó¥¹¥È¡¼¥ë¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Î¥¤¥ó¥¹¥È¡¼¥ë¤ÏŬÀڤʥɥ饤¥Ð¥Ï¥ó¥É¥ë¤òÊÖ¤¹¤«¡¢ "C" ¤È¤¤¤¦Ê¸»úÎó¤È´ð¤Ë¤Ê¤Ã¤¿ÌäÂ꤬Æþ¤Ã¤¿ ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤È¤È¤â¤Ë die ¤¹¤ë¤«¤Î¤É¤Á¤é¤«¤Ç¤¹¡£ ¤½¤Î¤¿¤á Cconnect> ¤Ï¥É¥é¥¤¥Ð¥¤¥ó¥¹¥È¡¼¥ë¤Î¾ã³²¤Î¤È¤­¤Ë¤Ï die ¤·¤Æ¡¢Àܳ¤Î¾ã³²¤Î¤È¤­¤Ë¤Ï C ¤òÊÖ¤¹¤À¤±¤Ç¤¹; ¤½¤Î¤È¤­¤Ë¤Ï C<$DBI::errstr> ¤Ë¥¨¥é¡¼¤Î¾ðÊó¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£ "C" ¥¨¥é¡¼¤òÊ᪤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ï C ¤ò »È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C<$data_source> argument (with the "C" prefix removed) and the C<$username> and C<$password> arguments are then passed to the driver for processing. The DBI does not define any interpretation for the contents of these fields. The driver is free to interpret the C<$data_source>, C<$username>, and C<$password> fields in any way, and supply whatever defaults are appropriate for the engine being accessed. (Oracle, for example, uses the ORACLE_SID and TWO_TASK environment variables if no C<$data_source> is specified.) =end original C<$data_source> °ú¿ô ( "C" ¤È¤¤¤¦ÀÜƬ¼­¤ò¤È¤Ã¤¿¤â¤Î)¤È C<$username>, C<$password> ¤Î°ú¿ô¤Ï¡¢½èÍý¤Î¤¿¤á¥É¥é¥¤¥Ð¤ËÅϤµ¤ì¤Þ¤¹¡£ DBI ¤Ï¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤ÎÆâÍƤβò¼á¤Ë¤Ä¤¤¤Æ²¿¤âÄêµÁ¤·¤Æ¤¤¤Þ¤»¤ó¡£ ¥É¥é¥¤¥Ð¤Ï C<$data_source>, C<$username>, C<$password> ¤Î¥Õ¥£¡¼¥ë¥É¤ò¡¢ ¤É¤ó¤Ê¤Õ¤¦¤Ë¤â¼«Í³¤Ë²òÀϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤½¤·¤Æ¥¢¥¯¥»¥¹¤µ¤ì¤ë¥¨¥ó¥¸¥ó¤Ë¹ç¤ï¤»¤Æ¡¢¤¤¤«¤Ê¤ë¥Ç¥Õ¥©¥ë¥È¤â ÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (Î㤨¤Ð Oracle ¤Ç¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢´Ä¶­ÊÑ¿ô ORACLE_SID ¤È TWO_TASK ¤ò»È¤¤¤Þ¤¹)¡£ =begin original The C and C attributes for each connection default to "on". (See L and L for more information.) However, it is strongly recommended that you explicitly define C rather than rely on the default. The C attribute defaults to on if $^W is true, i.e., perl is running with warnings enabled. =end original ³Æ¥³¥Í¥¯¥·¥ç¥ó¤Î C ¤È C °À­¤Î¥Ç¥Õ¥©¥ë¥È¤Ï "on" ¤Ç¤¹¡£ (¾ÜºÙ¤Ï C ¤È C ¤ò¤´Í÷¤¯¤À¤µ¤¤)¡£ ¤·¤«¤·¤Ê¤¬¤é¡¢¥Ç¥Õ¥©¥ë¥È¤Ë¤Þ¤«¤Þ¤»¤ë¤è¤ê¤âÌÀ¼¨Åª¤Ë C ¤ò ÄêµÁ¤¹¤ë¤³¤È¤¬¶¯¤¯¿ä¾©¤µ¤ì¤Þ¤¹¡£ $^W ¤¬¿¿¤Ê¤é C °À­¤Î¥Ç¥Õ¥©¥ë¥È¤Ï¥ª¥ó¤Ç¤¹; ¤Ä¤Þ¤ê¡¢perl ¤Ï ·Ù¹ð¤òÍ­¸ú¤Ë¤·¤ÆÆ°ºî¤·¤Þ¤¹¡£ =begin original The C<\%attr> parameter can be used to alter the default settings of C, C, C, and other attributes. For example: =end original C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤ò»È¤Ã¤Æ¡¢C, C, C ¤Ê¤É¤Î°À­¤Î¥Ç¥Õ¥©¥ë¥ÈÃͤòÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ Îã: $dbh = DBI->connect($data_source, $user, $pass, { PrintError => 0, AutoCommit => 0 }); =begin original The username and password can also be specified using the attributes C and C, in which case they take precedence over the C<$username> and C<$password> parameters. =end original ¥æ¡¼¥¶¡¼Ì¾¤È¥Ñ¥¹¥ï¡¼¥É¤Ï°À­ C ¤È C ¤ò»È¤Ã¤Æ¤â »ØÄê¤Ç¤­¡¢¤³¤Î¾ì¹ç¤Ï C<$username> ¤È C<$password> ¤Î¥Ñ¥é¥á¡¼¥¿¤è¤ê Í¥À褵¤ì¤Þ¤¹¡£ =begin original You can also define connection attribute values within the C<$data_source> parameter. For example: =end original C<$data_source> ¥Ñ¥é¥á¡¼¥¿¤ÎÃæ¤ÇÀܳ°À­¤ÎÃͤòÄêµÁ¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ Îã: dbi:DriverName(PrintWarn=>1,PrintError=>0,Taint=>1):... =begin original Individual attributes values specified in this way take precedence over any conflicting values specified via the C<\%attr> parameter to C. =end original ¤³¤ÎÊýË¡¤Ç»ØÄꤵ¤ì¤ë³Æ°À­Ãͤϡ¢C ¤Ø¤Î C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤ò ²ð¤·¤Æ»ØÄꤵ¤ì¤¿ÃͤȤ֤Ĥ«¤Ã¤Æ¤âÍ¥À褵¤ì¤Þ¤¹¡£ =begin original The C attribute can be used to specify which driver method should be called to establish the connection. The only useful values are 'connect', 'connect_cached', or some specialized case like 'Apache::DBI::connect' (which is automatically the default when running within Apache). =end original C °À­¤ÏÀܳ¤ò³ÎΩ¤¹¤ë¤µ¤¤¤Ë¤É¤Á¤é¤Î¥É¥é¥¤¥Ð¥á¥½¥Ã¥É¤¬ ¸Æ¤Ð¤ì¤ë¤Ù¤­¤«¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¤³¤ì¤Ë¤Ï 'connect', 'connect_cached', 'Apache::DBI::connect' ¤³¤ì¤Ï Apache ¤Ç¼Â¹Ô¤µ¤ì¤¿¤È¤­¤Ë¤Ï¼«Æ°Åª¤Ë¥Ç¥Õ¥©¥ë¥È¤Ë¤Ê¤ê¤Þ¤¹)¤Î¤è¤¦¤Ê ¤¢¤ëÆÃÊ̤ʥ±¡¼¥¹¤¬»È¤¨¤Þ¤¹¡£ =begin original Where possible, each session (C<$dbh>) is independent from the transactions in other sessions. This is useful when you need to hold cursors open across transactions--for example, if you use one session for your long lifespan cursors (typically read-only) and another for your short update transactions. =end original ²Äǽ¤Ç¤¢¤ì¤Ð¡¢³Æ¥»¥Ã¥·¥ç¥ó (C<$dbh>) ¤Ï¾¤Î¥»¥Ã¥·¥ç¥ó¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤«¤é ÆÈΩ¤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï¥«¡¼¥½¥ë¤ò¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¤Þ¤¿¤¬¤Ã¤Æ¥ª¡¼¥×¥ó¤·¤¿¤Þ¤Þ¤Ë¤¹¤ëɬÍפ¬¤¢¤ë ¾ì¹ç¤Ë¤ÏÊØÍø¤Ç¤¹¡£ Î㤨¤Ð¤¢¤ë¥»¥Ã¥·¥ç¥ó¤òŤ¤¼÷Ì¿¤ò¤â¤Ä¥«¡¼¥½¥ë(Ä̾ï¤ÏÆɤ߹þ¤ßÀìÍÑ)¤Î¤¿¤á¤Ë»È¤¤¡¢ ¾¤Î¥»¥Ã¥·¥ç¥ó¤Çû¤¤¹¹¿·¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¼Â¹Ô¤¹¤ë¾ì¹ç¤Ç¤¹¡£ =begin original For compatibility with old DBI scripts, the driver can be specified by passing its name as the fourth argument to C (instead of C<\%attr>): =end original ¸Å¤¤ DBI ¥¹¥¯¥ê¥×¥È¤È¤Î¸ß´¹À­¤Î¤¿¤á¤Ë¡¢¥É¥é¥¤¥Ð¤Î̾Á°¤ò C ¤Î 4 ÈÖÌܤΰú¿ô¤È¤·¤Æ(C<\%attr> ¤ÎÂå¤ï¤ê¤Ë)¡¢¥É¥é¥¤¥Ð¤Ë»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹: $dbh = DBI->connect($data_source, $user, $pass, $driver); =begin original In this "old-style" form of C, the C<$data_source> should not start with "C". (If it does, the embedded driver_name will be ignored). Also note that in this older form of C, the C<$dbh-E{AutoCommit}> attribute is I, the C<$dbh-E{PrintError}> attribute is off, and the old C environment variable is checked if C is not defined. Beware that this "old-style" C will soon be withdrawn in a future version of DBI. =end original ¤³¤Î C ¤Î¡Öµì¥¹¥¿¥¤¥ë¡×·Á¼°¤Ç¤Ï¡¢C<$data_source> ¤Ï "C" ¤Ç»Ï¤Þ¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£ (¤â¤·¤½¤¦¤Ç¤¢¤ì¤Ð¡¢Ëä¤á¹þ¤Þ¤ì¤¿¥É¥é¥¤¥Ð̾¤Ï̵»ë¤µ¤ì¤Þ¤¹)¡£ ¤³¤Î¸Å¤¤·Á¼°¤Î C¤Ç¤Ï¡¢C<$dbh-E{AutoCommit}> °À­¤Ï̤ÄêµÁ¡¢ C<$dbh-E{PrintError}> ¤Ï¥ª¥Õ¡¢¤½¤·¤Æ C ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢ ¸Å¤¤ C ´Ä¶­ÊÑ¿ô¤¬¥Á¥§¥Ã¥¯¤µ¤ì¤Þ¤¹¡£ ¤³¤Î¡Öµì¥¹¥¿¥¤¥ë¡×¤Î C ¤Ï DBI ¤Î¶á¤¤¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç űÇѤµ¤ì¤ë¤Ç¤¢¤í¤¦¤È¤¤¤¦¤³¤È¤ËÍÑ¿´¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $dbh = DBI->connect_cached($data_source, $username, $password) or die $DBI::errstr; $dbh = DBI->connect_cached($data_source, $username, $password, \%attr) or die $DBI::errstr; =begin original C is like L, except that the database handle returned is also stored in a hash associated with the given parameters. If another call is made to C with the same parameter values, then the corresponding cached C<$dbh> will be returned if it is still valid. The cached database handle is replaced with a new connection if it has been disconnected or if the C method fails. =end original C ¤ÏÊÖ¤µ¤ì¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤¬Í¿¤¨¤é¤ì¤¿¥Ñ¥é¥á¡¼¥¿¤È ´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¥Ï¥Ã¥·¥å¤Ë¤â³ÊǼ¤µ¤ì¤ë¤È¤¤¤¦ÅÀ¤ò½ü¤±¤Ð¡¢L ¤Ë »÷¤Æ¤¤¤Þ¤¹¡£ Ʊ¤¸¥Ñ¥é¥á¡¼¥¿ÃÍ¤Ç C ¤¬¤â¤¦°ìÅٸƤФì¤ë¤È¡¢¤½¤ì¤¬¤Þ¤À ŬÀڤǤ¢¤ì¤Ð¡¢¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿Âбþ¤¹¤ë C<$dbh> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¤¹¤Ç¤ËÀÚÃǤµ¤ì¤Æ¤¤¤¿¤ê¡¢C ¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤¿¤é¡¢¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ï¿·¤·¤¤Àܳ¤ÇÃÖ¤­¤«¤¨¤é¤ì¤Þ¤¹¡£ =begin original Note that the behaviour of this method differs in several respects from the behaviour of persistent connections implemented by Apache::DBI. However, if Apache::DBI is loaded then C will use it. =end original ¤³¤Î¥á¥½¥Ã¥É¤ÎÆ°¤­¤Ï¡¢Apache::DBI ¤Ë¤è¤Ã¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë±Ê³Àܳ¤ÎÆ°¤­¤È¤Ï ¿¤¯¤ÎÅÀ¤Ç°Û¤Ê¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤·¤«¤·¡¢Apache::DBI ¤¬Æɤ߹þ¤Þ¤ì¤ë¤È¡¢C ¤Ï¤³¤ì¤ò »È¤¤¤Þ¤¹¡£ =begin original Caching connections can be useful in some applications, but it can also cause problems, such as too many connections, and so should be used with care. In particular, avoid changing the attributes of a database handle created via connect_cached() because it will affect other code that may be using the same handle. When connect_cached() returns a handle the attributes will be reset to their initial values. This can cause problems, especially with the C attribute. =end original ¥­¥ã¥Ã¥·¥å¤Ï¡¢¤¢¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤Ã¤Æ¤ÏÊØÍø¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¡¢ ¤¿¤¯¤µ¤óÀܳ¤·¤¹¤®¤ë¤È¤¤¤Ã¤¿ÌäÂê¤â¤ª¤³¤¹¤«¤â¤·¤ì¤Þ¤»¤ó¤·¡¢Ãí°Õ¤·¤Æ »È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ ¤È¤¯¤Ë¡¢connect_cached() ¤ÇºîÀ®¤·¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î°À­¤ò ÊѤ¨¤ë¤³¤È¤ÏÈò¤±¤Æ¤¯¤À¤µ¤¤; Ʊ¤¸¥Ï¥ó¥É¥ë¤ò»È¤Ã¤Æ¤¤¤ë¾¤Î¥³¡¼¥É¤Ë ±Æ¶Á¤òÍ¿¤¨¤ë¤³¤È¤Ë¤Ê¤ë¤«¤é¤Ç¤¹¡£ connect_cached() ¤¬¥Ï¥ó¥É¥ë¤òÊÖ¤¹¤È¤­¡¢Â°À­¤Ï½é´üÃͤ˥ꥻ¥Ã¥È¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï(ÆÃ¤Ë C °À­¤Ç) ÌäÂê¤Ë¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ =begin original Where multiple separate parts of a program are using connect_cached() to connect to the same database with the same (initial) attributes it is a good idea to add a private attribute to the connect_cached() call to effectively limit the scope of the caching. For example: =end original ¥×¥í¥°¥é¥à¤ÎÊ£¿ô¤ÎÉôʬ¤¬connect_cached()¤ò»ÈÍѤ·¤Æ¡¢Æ±¤¸(½é´ü)°À­¤ÇƱ¤¸¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÀܳ¤·¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢connect_cached()¥³¡¼¥ë¤Ë¥×¥é¥¤¥Ù¡¼¥È°À­¤òÄɲ䷤ơ¢¥­¥ã¥Ã¥·¥å¤ÎÈϰϤò¸ú²ÌŪ¤ËÀ©¸Â¤¹¤ë¤³¤È¤ò¤ªÁ¦¤á¤·¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) DBI->connect_cached(..., { private_foo_cachekey => "Bar", ... }); =begin original Handles returned from that connect_cached() call will only be returned by other connect_cached() call elsewhere in the code if those other calls also pass in the same attribute values, including the private one. (I've used C here as an example, you can use any attribute name with a C prefix.) =end original ¤½¤Îconnect_cached()¸Æ¤Ó½Ð¤·¤«¤éÊÖ¤µ¤ì¤¿¥Ï¥ó¥É¥ë¤Ï¡¢¥³¡¼¥ÉÆâ¤Î¾¤Îconnect_cached()¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤Æ¤âƱ¤¸Â°À­ÃÍ(¥×¥é¥¤¥Ù¡¼¥ÈÃͤò´Þ¤à)¤¬ÅϤµ¤ì¤ë¾ì¹ç¤Ë¤Î¤ß¡¢¤½¤Î¾¤Îconnect_cached()¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤Þ¤¹(¤³¤³¤Ç¤ÏÎã¤È¤·¤ÆC¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£ C¥×¥ì¥Õ¥£¥¯¥¹¤ò»ý¤ÄǤ°Õ¤Î°À­Ì¾¤ò»ÈÍѤǤ­¤Þ¤¹)¡£ (TBR) =begin original Taking that one step further, you can limit a particular connect_cached() call to return handles unique to that one place in the code by setting the private attribute to a unique value for that place: =end original ¤³¤ì¤ò¤µ¤é¤Ë°ìÊâ¿Ê¤á¤Æ¡¢private°À­¤ò¤½¤Î¾ì½ê¤Ë¸ÇÍ­¤ÎÃͤËÀßÄꤹ¤ë¤³¤È¤Ç¡¢ÆÃÄê¤Îconnect_cached()¸Æ¤Ó½Ð¤·¤¬¥³¡¼¥ÉÆâ¤Î¤½¤Î¾ì½ê¤Ë¸ÇÍ­¤Î¥Ï¥ó¥É¥ë¤òÊÖ¤¹¤è¤¦¤ËÀ©¸Â¤Ç¤­¤Þ¤¹¡£ (TBR) DBI->connect_cached(..., { private_foo_cachekey => __FILE__.__LINE__, ... }); =begin original By using a private attribute you still get connection caching for the individual calls to connect_cached() but, by making separate database connections for separate parts of the code, the database handles are isolated from any attribute changes made to other handles. =end original private°À­¤ò»ÈÍѤ·¤Æ¤â¡¢connect_cached()¤Î¸Ä¡¹¤Î¸Æ¤Ó½Ð¤·¤ÎÀܳ¥­¥ã¥Ã¥·¥å¤ò¼èÆÀ¤Ç¤­¤Þ¤¹¤¬¡¢¥³¡¼¥É¤ÎÊÌ¡¹¤ÎÉôʬ¤ËÂФ·¤ÆÊÌ¡¹¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤òºîÀ®¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ï¡¢Â¾¤Î¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¹Ô¤ï¤ì¤¿Â°À­¤ÎÊѹ¹¤«¤éʬΥ¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original The cache can be accessed (and cleared) via the L attribute: =end original ¥­¥ã¥Ã¥·¥å¤Ï L °À­¤ò²ð¤·¤Æ¥¢¥¯¥»¥¹(¤½¤·¤Æ¥¯¥ê¥¢)¤¹¤ë¤³¤È¤¬ ¤Ç¤­¤Þ¤¹: my $CachedKids_hashref = $dbh->{Driver}->{CachedKids}; %$CachedKids_hashref = () if $CachedKids_hashref; =head3 C @ary = DBI->available_drivers; @ary = DBI->available_drivers($quiet); =begin original Returns a list of all available drivers by searching for C modules through the directories in C<@INC>. By default, a warning is given if some drivers are hidden by others of the same name in earlier directories. Passing a true value for C<$quiet> will inhibit the warning. =end original C<@INC> ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤«¤é C ¥â¥¸¥å¡¼¥ë¤ò¸¡º÷¤·¤Æ¡¢»ÈÍѲÄǽ¤Ê ¥É¥é¥¤¥Ð¤Î¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢Àè¤Ë¸«¤Ä¤«¤Ã¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¢¤ëƱ¤¸Ì¾Á°¤Î¤â¤Î¤Ë¤è¤ê¡¢ ±£¤µ¤ì¤Æ¤·¤Þ¤¦¥É¥é¥¤¥Ð¤¬¤¢¤ì¤Ð·Ù¹ð¤·¤Þ¤¹¡£ ·Ù¹ð¤òÍ޻ߤ¹¤ë¤Ë¤Ï C<$quiet> ¤ò¿¿¤ÎÃͤˤ·¤Þ¤¹¡£ =head3 C %drivers = DBI->installed_drivers(); =begin original Returns a list of driver name and driver handle pairs for all drivers 'installed' (loaded) into the current process. The driver name does not include the 'DBD::' prefix. =end original ¸½ºß¤Î¥×¥í¥»¥¹¤Ë¡Ö¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤¿¡×(Æɤ߹þ¤Þ¤ì¤¿)Á´¤Æ¤Î¥É¥é¥¤¥Ð¤Î ¥É¥é¥¤¥Ð̾¤È¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¤ÎÁȤΥꥹ¥È¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð̾¤Ë¤Ï 'DBD::' ÀÜƬ¼­¤ÏÉÕ¤¤¤Æ¤¤¤Þ¤»¤ó¡£ =begin original To get a list of all drivers available in your perl installation you can use L. =end original ¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë perl ¤ÇÍøÍѲÄǽ¤ÊÁ´¤Æ¤Î¥É¥é¥¤¥Ð¤Î¥ê¥¹¥È¤òÆÀ¤ë¤Ë¤Ï¡¢ L ¤¬»È¤¨¤Þ¤¹¡£ =begin original Added in DBI 1.49. =end original DBI 1.49 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C DBI->installed_versions; @ary = DBI->installed_versions; %hash = DBI->installed_versions; =begin original Calls available_drivers() and attempts to load each of them in turn using install_driver(). For each load that succeeds the driver name and version number are added to a hash. When running under L drivers which appear not be pure-perl are ignored. =end original available_drivers() ¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢¤½¤Î¤½¤ì¤¾¤ì¤ËÂФ·¤Æ install_driver() ¤ò »È¤Ã¤ÆÆɤ߹þ¤â¤¦¤È¤·¤Þ¤¹¡£ Æɤ߹þ¤ß¤ËÀ®¸ù¤·¤¿¥É¥é¥¤¥Ð¤Î̾Á°¤È¥Ð¡¼¥¸¥ç¥óÈÖ¹æ¤Ï¥Ï¥Ã¥·¥å¤ËÄɲ䵤ì¤Þ¤¹¡£ L ¥É¥é¥¤¥Ð¤Ç¼Â¹Ô¤¹¤ë¤È¥Ô¥å¥¢ perl ¤Ç¤Ê¤¤¤è¤¦¤Ë¸«¤¨¤ë ¥É¥é¥¤¥Ð¤Ï̵»ë¤µ¤ì¤Þ¤¹¡£ =begin original When called in array context the list of successfully loaded drivers is returned (without the 'DBD::' prefix). =end original ÇÛÎó¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢Æɤ߹þ¤ß¤ËÀ®¸ù¤·¤¿¥É¥é¥¤¥Ð¤Î¥ê¥¹¥È¤¬ ('DBD::' ¤ÎÀÜƬ¼­¤Ê¤·¤Ç) ÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original When called in scalar context a reference to the hash is returned and the hash will also contain other entries for the C version, C name, etc. =end original ¥¹¥«¥é¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢¥Ï¥Ã¥·¥å¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤¬ÊÖ¤µ¤ì¡¢ ¤³¤Î¥Ï¥Ã¥·¥å¤Ë¤Ï C ¥Ð¡¼¥¸¥ç¥ó¡¢C ̾¤Ê¤É¤Î¤½¤Î¾¤Î¥¨¥ó¥È¥ê¤â ´Þ¤Þ¤ì¤Þ¤¹¡£ =begin original When called in a void context the installed_versions() method will print out a formatted list of the hash contents, one per line. =end original ̵¸ú¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢installed_versions() ¥á¥½¥Ã¥É¤Ï ¥Ï¥Ã¥·¥å¤ÎÆâÍƤò¹Ôñ°Ì¤Ç¥Õ¥©¡¼¥Þ¥Ã¥È¤·¤¿¥ê¥¹¥È¤ò½ÐÎϤ·¤Þ¤¹¡£ =begin original Due to the potentially high memory cost and unknown risks of loading in an unknown number of drivers that just happen to be installed on the system, this method is not recommended for general use. Use available_drivers() instead. =end original ÀøºßŪ¤Ë¥á¥â¥ê¥³¥¹¥È¤¬¹â¤¤¤³¤È¤È¡¢²¿¸Ä¤«Ê¬¤«¤é¤Ê¤¤¥·¥¹¥Æ¥à¤Ë ¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤òÆɤ߹þ¤à¤È¤¤¤¦ÉÔÌÀ¤Ê¥ê¥¹¥¯¤¬¤¢¤ë¤Î¤Ç¡¢ ¤³¤Î¥á¥½¥Ã¥É¤Ï°ìÈÌŪ¤Ê»ÈÍѤϿ侩¤µ¤ì¤Þ¤»¤ó¡£ Âå¤ï¤ê¤Ë available_drivers() ¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =begin original The installed_versions() method is primarily intended as a quick way to see from the command line what's installed. For example: =end original installed_versions() ¥á¥½¥Ã¥É¤Ï¼ç¤È¤·¤Æ¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò ¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤éÁÇÁ᤯¸«¤ë¤³¤È¤òÌÜŪ¤È¤·¤Æ¤¤¤Þ¤¹¡£ Î㤨¤Ð: perl -MDBI -e 'DBI->installed_versions' =begin original The installed_versions() method was added in DBI 1.38. =end original installed_versions() ¥á¥½¥Ã¥É¤Ï DBI 1.38 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C @ary = DBI->data_sources($driver); @ary = DBI->data_sources($driver, \%attr); =begin original Returns a list of data sources (databases) available via the named driver. If C<$driver> is empty or C, then the value of the C environment variable is used. =end original »ØÄꤵ¤ì¤¿Ì¾Á°¤Î¥É¥é¥¤¥Ð¤Ç»È¤¦¤³¤È¤¬¤Ç¤­¤ë¥Ç¡¼¥¿¥½¡¼¥¹(¥Ç¡¼¥¿¥Ù¡¼¥¹)¤Î ¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£ C<$driver> ¤¬¶õ¤â¤·¤¯¤Ï C ¤Ç¤¢¤ì¤Ð¡¢´Ä¶­ÊÑ¿ô C ¤ÎÃͤ¬ »È¤ï¤ì¤Þ¤¹¡£ =begin original The driver will be loaded if it hasn't been already. Note that if the driver loading fails then data_sources() I with an error message that includes the string "C" and the underlying problem. =end original ¤Þ¤À¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¥É¥é¥¤¥Ð¤Ï¥í¡¼¥É¤µ¤ì¤Þ¤¹¡£ ¤â¤·¥É¥é¥¤¥Ð¤Î¥í¡¼¥Ç¥£¥ó¥°¤¬¼ºÇÔ¤·¤¿¤é¡¢"C" ¤È¤¤¤¦Ê¸»úÎó¤È ¤½¤³¤Ë¤¢¤ëÌäÂ꤬Æþ¤Ã¤¿¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ç I ¤¹¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Data sources are returned in a form suitable for passing to the L method (that is, they will include the "C" prefix). =end original ¥Ç¡¼¥¿¥½¡¼¥¹¤Ï L ¥á¥½¥Ã¥É¤ËÅϤ¹¤Î¤ËŬ¤·¤¿¤Ê·Á¼°¤ÇÊÖ¤µ¤ì¤Þ¤¹ (¤Ä¤Þ¤êÀÜƬ¼­ "C" ¤¬Æþ¤ê¤Þ¤¹¡£) =begin original Note that many drivers have no way of knowing what data sources might be available for it. These drivers return an empty or incomplete list or may require driver-specific attributes. =end original ¿¤¯¤Î¥É¥é¥¤¥Ð¤¬ÍøÍѤǤ­¤ë¥Ç¡¼¥¿¥½¡¼¥¹¤òÄ´¤Ù¤ëÊýË¡¤ò »ý¤Ã¤Æ¤¤¤Ê¤¤¤È¤¤¤¦¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤ì¤é¤Î¥É¥é¥¤¥Ð¤Ï¶õ¤â¤·¤¯¤ÏÉÔ´°Á´¤Ê¥ê¥¹¥È¤¬ÊÖ¤·¤¿¤ê¡¢ ¤¢¤ë¤¤¤Ï¥É¥é¥¤¥ÐÆÃÍ­¤Î°À­¤¬Í¿¤¨¤é¤ì¤ë¤³¤È¤òɬÍפȤ¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original There is also a data_sources() method defined for database handles. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î¤¿¤á¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë data_sources() ¥á¥½¥Ã¥É¤â ¤¢¤ê¤Þ¤¹¡£ =head3 C DBI->trace($trace_setting) DBI->trace($trace_setting, $trace_filename) DBI->trace($trace_setting, $trace_filehandle) $trace_setting = DBI->trace; =begin original The Ctrace> method sets the I trace settings and returns the I trace settings. It can also be used to change where the trace output is sent. =end original Ctrace> ¥á¥½¥Ã¥É¤Ï I<¥°¥í¡¼¥Ð¥ë¤Ë¥Ç¥Õ¥©¥ë¥È¤Î> ¥È¥ì¡¼¥¹ÀßÄê¤ò ¥»¥Ã¥È¤·¡¢I<°ÊÁ°¤Î> ¥È¥ì¡¼¥¹ÀßÄê¤òÊÖ¤·¤Þ¤¹¡£ ¤³¤ì¤Ï¤Þ¤¿¡¢¥È¥ì¡¼¥¹½ÐÎϤò¤É¤³¤ËÁ÷¤ë¤«¤òÊѹ¹¤¹¤ë¤¿¤á¤Ë¤â»È¤¤¤Þ¤¹¡£ =begin original There's a similar method, C<$h-Etrace>, which sets the trace settings for the specific handle it's called on. =end original »÷¤¿¤è¤¦¤Ê¥á¥½¥Ã¥É¤·¤Æ C<$h-Etrace> ¤¬¤¢¤ê¡¢¤³¤ì¤Ï¸Æ¤Ó½Ð¤µ¤ì¤¿ ÆÃÄê¤Î¥Ï¥ó¥É¥ë¤Î¥È¥ì¡¼¥¹ÀßÄê¤òÀßÄꤷ¤Þ¤¹¡£ =begin original See the L section for full details about the DBI's powerful tracing facilities. =end original DBI ¤Î¶¯ÎϤʥȥ졼¥¹µ¡Ç½¤Ë´Ø¤¹¤ë´°Á´¤Ê¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤Î¾Ï¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C DBI->visit_handles( $coderef ); DBI->visit_handles( $coderef, $info ); =begin original Where $coderef is a reference to a subroutine and $info is an arbitrary value which, if undefined, defaults to a reference to an empty hash. Returns $info. =end original $coderef ¤Ï¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¡¢$info ¤ÏǤ°Õ¤ÎÃͤǤ¢¤ê¡¢ ¤â¤·Ì¤ÄêµÁ¤Ê¤é¥Ç¥Õ¥©¥ë¥È¤Ï¤«¤é¥Ï¥Ã¥·¥å¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤È¤Ê¤ê¤Þ¤¹¡£ $info ¤òÊÖ¤·¤Þ¤¹¡£ =begin original For each installed driver handle, if any, $coderef is invoked as: =end original ¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤¬¤¢¤ì¤Ð¡¢¤½¤Î¥Ï¥ó¥É¥ëËè¤Ë¡¢ $coderef ¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æµ¯Æ°¤µ¤ì¤Þ¤¹: $coderef->($driver_handle, $info); =begin original If the execution of $coderef returns a true value then L is called on that child handle and passed the returned value as $info. =end original $coderef ¤Î¼Â¹Ô¤Ë¤è¤Ã¤Æ¿¿¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤È¡¢L ¤¬ »Ò¥Ï¥ó¥É¥ë¤Ë¸Æ¤Ó½Ð¤µ¤ì¡¢ÊÖ¤µ¤ì¤¿Ãͤò $info ¤È¤·¤ÆÅϤ·¤Þ¤¹¡£ =begin original For example: =end original Î㤨¤Ð: my $info = $dbh->{Driver}->visit_child_handles(sub { my ($h, $info) = @_; ++$info->{ $h->{Type} }; # count types of handles (dr/db/st) return $info; # visit kids }); =begin original See also L. =end original L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 DBI Utility Functions (DBI ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô) =begin original In addition to the DBI methods listed in the previous section, the DBI package also provides several utility functions. =end original Á°¤Î¥»¥¯¥·¥ç¥ó¤Ç°ìÍ÷¤·¤·¤¿¥á¥½¥Ã¥É¤Ë²Ã¤¨¤Æ¡¢DBI¥Ñ¥Ã¥±¡¼¥¸¤Ï¤¤¤¯¤Ä¤«¤Î ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô¤âÄ󶡤·¤Æ¤¤¤Þ¤¹¡£ =begin original These can be imported into your code by listing them in the C statement. For example: =end original ¤³¤ì¤é¤Ï C ʸ¤Ç¥ê¥¹¥È¤¹¤ë¤³¤È¤Ç¤¢¤Ê¤¿¤Î¥³¡¼¥É¤Ë¥¤¥ó¥Ý¡¼¥È¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð: use DBI qw(neat data_diff); =begin original Alternatively, all these utility functions (except hash) can be imported using the C<:utils> import tag. For example: =end original ¤¢¤ë¤¤¤Ï¡¢(hash ¤ò½ü¤¯)¤³¤ì¤é¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¤¹Á´¤Æ¤ò C<:utils> ¥¤¥ó¥Ý¡¼¥È¥¿¥°¤ò»È¤Ã¤Æ¥¤¥ó¥Ý¡¼¥È¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð: use DBI qw(:utils); =head3 C $description = data_string_desc($string); =begin original Returns an informal description of the string. For example: =end original ʸ»úÎó¤Ë´Ø¤¹¤ëά¼°¤Îµ­½Ò¤òÊÖ¤·¤Þ¤¹¡£ Î㤨¤Ð: UTF8 off, ASCII, 42 characters 42 bytes UTF8 off, non-ASCII, 42 characters 42 bytes UTF8 on, non-ASCII, 4 characters 6 bytes UTF8 on but INVALID encoding, non-ASCII, 4 characters 6 bytes UTF8 off, undef =begin original The initial C on/off refers to Perl's internal SvUTF8 flag. If $string has the SvUTF8 flag set but the sequence of bytes it contains are not a valid UTF-8 encoding then data_string_desc() will report C. =end original ºÇ½é¤Î C on/off ¤Ï Perl ÆâÉô¤Î SvUTF8 ¥Õ¥é¥°¤ò»²¾È¤·¤Þ¤¹¡£ $string ¤Ë SvUTF8 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¤±¤ì¤É¤â¤½¤ÎÆâÍƤ¬Í­¸ú¤Ê UTF-8 ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç¤Ê¤¤¾ì¹ç¡¢data_string_desc() ¤Ï C ¤ÈÊó¹ð¤·¤Þ¤¹¡£ =begin original The C vs C portion shows C if I the characters in the string are ASCII (have code points <= 127). =end original C ¤È C ¤ÎÉôʬ¤Ï¡¢Ê¸»úÎó¤Î I<Á´¤Æ¤Î> ʸ»ú¤¬ ASCII (ʸ»ú°ÌÃÖ¤¬ <= 127) ¤Ê¤é C ¤È¤Ê¤ê¤Þ¤¹¡£ =begin original The data_string_desc() function was added in DBI 1.46. =end original data_string_desc() ´Ø¿ô¤Ï DBI 1.46 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $diff = data_string_diff($a, $b); =begin original Returns an informal description of the first character difference between the strings. If both $a and $b contain the same sequence of characters then data_string_diff() returns an empty string. For example: =end original Æó¤Ä¤Îʸ»úÎó¤Î´Ö¤ÇºÇ½é¤Ë°Û¤Ê¤ëʸ»ú¤ÎÈó¸ø¼°¤ÊÀâÌÀ¤òÊÖ¤·¤Þ¤¹¡£ $a ¤È $b ¤¬Æ±¤¸Ê¸»úʤӤʤ顢data_string_diff() ¤Ï¶õʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£ Î㤨¤Ð: Params a & b Result ------------ ------ 'aaa', 'aaa' '' 'aaa', 'abc' 'Strings differ at index 2: a[2]=a, b[2]=b' 'aaa', undef 'String b is undef, string a has 3 characters' 'aaa', 'aa' 'String b truncated after 2 characters' =begin original Unicode characters are reported in C<\x{XXXX}> format. Unicode code points in the range U+0800 to U+08FF are unassigned and most likely to occur due to double-encoding. Characters in this range are reported as C<\x{08XX}='C'> where C is the corresponding latin-1 character. =end original Unicode ʸ»ú¤Ï C<\x{XXXX}> ·Á¼°¤ÇÊó¹ð¤µ¤ì¤Þ¤¹¡£ U+0800 ¤«¤é U+08FF ¤ÎÈϰϤΠUnicode Éä¹æ°ÌÃÖ¤Ï̤ÄêµÁ¤Ç¡¢¤â¤Ã¤È¤â ¤¢¤ê¤½¤¦¤Ê¤³¤È¤ÏÆó½Å¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç¤¹¡£ ¤³¤ÎÈϰϤÎʸ»ú¤Ï C<\x{08XX}='C'> ¤È¤·¤ÆÊó¹ð¤µ¤ì¤Þ¤¹; ¤³¤³¤Ç C ¤ÏÂбþ¤¹¤ë latin-1 ʸ»ú¤Ç¤¹¡£ =begin original The data_string_diff() function only considers logical I and not the underlying encoding. See L for an alternative. =end original data_string_diff() ´Ø¿ô¤Ï¡¢ÏÀÍýŪ¤Ê I<ʸ»ú> ¤À¤±¤ò¹Íθ¤·¡¢¤½¤Î ´ðÁäȤʤ륨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ï¹Íθ¤·¤Þ¤»¤ó¡£ ÂåÂذƤ˴ؤ·¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The data_string_diff() function was added in DBI 1.46. =end original data_string_diff() ´Ø¿ô¤Ï DBI 1.46 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $diff = data_diff($a, $b); $diff = data_diff($a, $b, $logical); =begin original Returns an informal description of the difference between two strings. It calls L and L and returns the combined results as a multi-line string. =end original Æó¤Ä¤Îʸ»úÎó¤Î°ã¤¤¤Ë´Ø¤¹¤ëÈó¸ø¼°¤ÊÀâÌÀ¤òÊÖ¤·¤Þ¤¹¡£ ¤³¤ì¤Ï L ¤È L ¤ò¸Æ¤Ó½Ð¤·¡¢ ·ë¹ç¤·¤¿·ë²Ì¤òÊ£¿ô¹Ô¤Îʸ»úÎó¤È¤·¤ÆÊÖ¤·¤Þ¤¹¡£ =begin original For example, C will return: =end original Î㤨¤Ð¡¢C ¤Ï°Ê²¼¤Î¤â¤Î¤òÊÖ¤·¤Þ¤¹: a: UTF8 off, ASCII, 3 characters 3 bytes b: UTF8 on, non-ASCII, 3 characters 5 bytes Strings differ at index 2: a[2]=c, b[2]=\x{263A} =begin original If $a and $b are identical in both the characters they contain I their physical encoding then data_diff() returns an empty string. If $logical is true then physical encoding differences are ignored (but are still reported if there is a difference in the characters). =end original $a ¤È $b ¤¬¡¢´Þ¤Þ¤ì¤Æ¤¤¤ëʸ»úÎó I<¤ª¤è¤Ó> ¤½¤ÎʪÍýŪ¤Ê¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î ξÊý¤Ë¤ª¤¤¤ÆƱ°ì¤Î¾ì¹ç¡¢data_diff() ¤Ï¶õʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£ $logical ¤¬¿·¤Ê¤éʪÍýŪ¤Ê¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î°ã¤¤¤Ï̵»ë¤µ¤ì¤Þ¤¹ (¤·¤«¤·Ê¸»ú¤Ë°ã¤¤¤¬¤¢¤ì¤Ð¤ä¤Ï¤êÊó¹ð¤µ¤ì¤Þ¤¹)¡£ =begin original The data_diff() function was added in DBI 1.46. =end original data_diff() ´Ø¿ô¤Ï DBI 1.46 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $str = neat($value); $str = neat($value, $maxlen); =begin original Return a string containing a neat (and tidy) representation of the supplied value. =end original Í¿¤¨¤é¤ì¤¿Ê¸»úÎó¤òÀ°Á³¤È(¤½¤·¤Æ¤­¤ì¤¤¤Ë)À°¤¨¤é¤ì¤¿Ê¸»úÎó¤òÊÖ¤·¤Þ¤¹¡£ =begin original Strings will be quoted, although internal quotes will I be escaped. Values known to be numeric will be unquoted. Undefined (NULL) values will be shown as C (without quotes). =end original ʸ»úÎó¤Ï¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¤Ç°Ï¤Þ¤ì¤Þ¤¹¤¬¡¢Ê¸»úÎó¤ÎÃæ¤Î¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¤Ï ¥¨¥¹¥±¡¼¥× I<¤µ¤ì¤Þ¤»¤ó>¡£ ¿ôÃͤǤ¢¤ë¤È¤ï¤«¤Ã¤Æ¤¤¤ëÃͤϥ¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¤Ç°Ï¤Þ¤ì¤Þ¤»¤ó¡£ ̤ÄêµÁ(NULL) ÃͤÏ(¥¯¥©¡¼¥È¤Ê¤·¤Ç)C ¤Çɽ¤µ¤ì¤Þ¤¹¡£ =begin original If the string is flagged internally as utf8 then double quotes will be used, otherwise single quotes are used and unprintable characters will be replaced by dot (.). =end original ʸ»úÎó¤¬ÆâÉô¤Ç UTF8 ¤È¤·¤Æµ­Ï¿¤µ¤ì¤Æ¤¤¤ë¤È¡¢¥À¥Ö¥ë¥¯¥©¡¼¥È¤¬»È¤ï¤ì¡¢ ¤µ¤â¤Ê¤±¤ì¤Ð¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤¬»È¤ï¤ì¡¢É½¼¨¤Ç¤­¤Ê¤¤Ê¸»ú¤ÏÅÀ(.)¤Ç ÃÖ¤­´¹¤¨¤é¤ì¤Þ¤¹¡£ =begin original For result strings longer than C<$maxlen> the result string will be truncated to C<$maxlen-4> and "C<...'>" will be appended. If C<$maxlen> is 0 or C, it defaults to C<$DBI::neat_maxlen> which, in turn, defaults to 400. =end original ÊÑ´¹·ë²Ì¤Îʸ»úÎó¤¬ C<$masxlen> ¤è¤ê¤âŤ±¤ì¤Ð¡¢Ê¸»úÎó¤Ï C<$maxlen-4> ¤Î Ťµ¤ËÀÚ¤êµÍ¤á¡¢"C<...'>" ¤¬¸å¤í¤Ë¤Ä¤±¤é¤ì¤Þ¤¹¡£ C<$maxlen> ¤¬ 0 ¤Þ¤¿¤Ï C ¤Ç¤¢¤ì¤Ð¡¢C<$DBI::neat_maxlen> (¥Ç¥Õ¥©¥ë¥È¤Ï400)¤¬Âå¤ê¤Ë¥Ç¥Õ¥©¥ë¥È¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original This function is designed to format values for human consumption. It is used internally by the DBI for L output. It should typically I be used for formatting values for database use. (See also L.) =end original ¤³¤Î´Ø¿ô¤Ï¿Í¤ÎÌܤˤ狼¤ê¤ä¤¹¤¤¤è¤¦¤ËÃͤηÁ¼°¤òÀ°¤¨¤ë¤è¤¦¤Ë¹Í¤¨¤é¤ì¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï DBI ÆâÉô¤Ç L ½ÐÎϤ˻Ȥï¤ì¤Æ¤¤¤Þ¤¹¡£ Ä̾ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ÍøÍѤ¹¤ë¤è¤¦¡¢ÃͤηÁ¤òÀ°¤¨¤ë¤¿¤á¤Ë»È¤Ã¤Æ¤Ï I<¤¤¤±¤Þ¤»¤ó> (L ¤â¤´Í÷¤¯¤À¤µ¤¤)¡£ =head3 C $str = neat_list(\@listref, $maxlen, $field_sep); =begin original Calls C on each element of the list and returns a string containing the results joined with C<$field_sep>. C<$field_sep> defaults to C<", ">. =end original ¥ê¥¹¥È¤Î³ÆÍ×ÁÇ¤Ë C ¤ò¸Æ¤Ó½Ð¤·¡¢¤½¤Î·ë²Ì¤ò C<$field_sep> ¤Ç¤Ä¤Ê¤²¤¿ ·ë²Ì¤Îʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£ C<$field_sep> ¤Î¥Ç¥Õ¥©¥ë¥È¤Ï C<", "> ¤Ç¤¹¡£ =head3 C @bool = looks_like_number(@array); =begin original Returns true for each element that looks like a number. Returns false for each element that does not look like a number. Returns C for each element that is undefined or empty. =end original ¥ê¥¹¥È¤Î³ÆÍ×ÁǤˤĤ¤¤Æ¿ôÃͤ˸«¤¨¤Ð¿¿¤òÊÖ¤·¤Þ¤¹¡£ ³ÆÍ×ÁǤ¬¿ôÃͤ˸«¤¨¤Ê¤±¤ì¤Ðµ¶¤òÊÖ¤·¤Þ¤¹¡£ ³ÆÍ×ÁǤ¬Ì¤ÄêµÁ¤¢¤ë¤¤¤Ï¶õ¤Ç¤¢¤ì¤Ð¡¢C ¤â¤·¤¯¤Ï¶õ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C $hash_value = DBI::hash($buffer, $type); =begin original Return a 32-bit integer 'hash' value corresponding to the contents of $buffer. The $type parameter selects which kind of hash algorithm should be used. =end original $buffer ¤ÎÆâÍƤËÂбþ¤¹¤ë 32 ¥Ó¥Ã¥ÈÀ°¿ô¤Î¡Ö¥Ï¥Ã¥·¥å¡×ÃͤòÊÖ¤·¤Þ¤¹¡£ $type ¥Ñ¥é¥á¡¼¥¿¤Ï»ÈÍѤ¹¤ë¥Ï¥Ã¥·¥å¥¢¥ë¥´¥ê¥º¥à¤òÁªÂò¤·¤Þ¤¹¡£ =begin original For the technically curious, type 0 (which is the default if $type isn't specified) is based on the Perl 5.1 hash except that the value is forced to be negative (for obscure historical reasons). Type 1 is the better "Fowler / Noll / Vo" (FNV) hash. See L for more information. Both types are implemented in C and are very fast. =end original µ»½ÑŪ¹¥´ñ¿´¤Î¤¿¤á¤Ë¡¢·¿ 0 (¤³¤ì¤Ï $type ¤¬»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¤È¤­¤Î ¥Ç¥Õ¥©¥ë¥È¤Ç¤¹) ¤Ï Perl 5.1 ¥Ï¥Ã¥·¥å¤ò´ð¤Ë¤·¤Æ¤¤¤Þ¤¹¤¬¡¢(¤Ï¤Ã¤­¤ê¤·¤Ê¤¤ Îò»ËŪ¤ÊÍýͳ¤Ë¤è¤ê) ÃͤÏÉé¿ô¤ËÀ©¸Â¤µ¤ì¤Þ¤¹¡£ ·¿ 1 ¤Ï¤è¤ê¤è¤ê "Fowler / Noll / Vo" (FNV) ¥Ï¥Ã¥·¥å¤Ç¤¹¡£ ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤É¤Á¤é¤Î·¿¤â C ¤Ç¼ÂÁõ¤µ¤ì¤Æ¤¤¤Æ¤È¤Æ¤â®¤¤¤Ç¤¹¡£ =begin original This function doesn't have much to do with databases, except that it can be handy to store hash values in a database. =end original ¤³¤Î´Ø¿ô¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂФ·¤Æ²¿¤«¤ò¤¹¤ë¤È¤¤¤¦¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¢ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¥Ï¥Ã¥·¥åÃͤòÊä´°¤¹¤ë¤Î¤ËÊØÍø¤Ç¤¹¡£ =head3 C $sts = DBI->sql_type_cast($sv, $sql_type, $flags); =begin original sql_type_cast attempts to cast C<$sv> to the SQL type (see L) specified in C<$sql_type>. At present only the SQL types C, C and C are supported. =end original sql_type_cast ¤Ï C<$sv> ¤ò C<$sql_type> ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë SQL ·¿ (L »²¾È) ¤Ë¥­¥ã¥¹¥È¤·¤è¤¦¤È¤·¤Þ¤¹¡£ ¸½ºß¤Î¤È¤³¤í SQL ·¿ C, C, C ¤Î¤ß¤Ë Âбþ¤·¤Æ¤¤¤Þ¤¹¡£ =begin original For C the effect is similar to using the value in an expression that requires an integer. It gives the perl scalar an 'integer aspect'. (Technically the value gains an IV, or possibly a UV or NV if the value is too large for an IV.) =end original C¤Î¾ì¹ç¡¢¤³¤Î¸ú²Ì¤Ï¡¢À°¿ô¤òɬÍפȤ¹¤ë¼°¤ÇÃͤò»ÈÍѤ¹¤ë¤Î¤È»÷¤Æ¤¤¤Þ¤¹¡£ perl¥¹¥«¥é¡¼¤Ë¡ÖÀ°¿ô¥¢¥¹¥Ú¥¯¥È¡×¤òÍ¿¤¨¤Þ¤¹¡£ (µ»½ÑŪ¤Ë¤Ï¡¢ÃͤÏIV¤ò¼èÆÀ¤·¤Þ¤¹¡£ IV¤ËÂФ·¤ÆÃͤ¬Â礭¤¹¤®¤ë¾ì¹ç¤Ï¡¢UV¤Þ¤¿¤ÏNV¤ò¼èÆÀ¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ) (TBR) =begin original For C the effect is similar to using the value in an expression that requires a general numeric value. It gives the perl scalar a 'numeric aspect'. (Technically the value gains an NV.) =end original C¤Î¾ì¹ç¡¢¤³¤Î¸ú²Ì¤Ï¡¢°ìÈÌŪ¤Ê¿ôÃͤòɬÍפȤ¹¤ë¼°¤ÇÃͤò»ÈÍѤ¹¤ë¤³¤È¤Ë»÷¤Æ¤¤¤Þ¤¹¡£ perl¥¹¥«¥é¡¼¤Ë¡Ö¿ôÃÍŪ¤Ê¦Ì̡פòÍ¿¤¨¤Þ¤¹(µ»½ÑŪ¤Ë¤Ï¡¢ÃͤÏNV¤ò³ÍÆÀ¤·¤Þ¤¹)¡£ (TBR) =begin original C is similar to C or C but more general and more cautious. It will look at the string first and if it looks like an integer (that will fit in an IV or UV) it will act like C, if it looks like a floating point value it will act like C, if it looks like neither then it will do nothing - and thereby avoid the warnings that would be generated by C and C when given non-numeric data. =end original C¤ÏC¤äC¤Ë»÷¤Æ¤¤¤Þ¤¹¤¬¡¢¤è¤ê°ìÈÌŪ¤Ç¤è¤ê¿µ½Å¤Ç¤¹¡£ C¤Ïʸ»úÎó¤òºÇ½é¤Ë¸«¤Æ¡¢(IV¤Þ¤¿¤ÏUV¤ËŬ¹ç¤¹¤ë)À°¿ô¤Î¤è¤¦¤Ë¸«¤¨¤ë¾ì¹ç¤ÏC¤Î¤è¤¦¤ËÆ°ºî¤·¡¢ÉâÆ°¾®¿ôÅÀÃͤΤ褦¤Ë¸«¤¨¤ë¾ì¹ç¤ÏC¤Î¤è¤¦¤ËÆ°ºî¤·¡¢¤É¤Á¤é¤Ç¤â¤Ê¤¤¤è¤¦¤Ë¸«¤¨¤ë¾ì¹ç¤Ï²¿¤â¤·¤Þ¤»¤ó¡£ ¤³¤ì¤Ë¤è¤ê¡¢Èó¿ôÃͥǡ¼¥¿¤¬Í¿¤¨¤é¤ì¤¿¤È¤­¤ËC¤ÈC¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤ë·Ù¹ð¤ò²óÈò¤·¤Þ¤¹¡£ (TBR) =begin original C<$flags> may be: =end original C<$flags> ¤Ï: =over 4 =item C =begin original If this flag is specified then when the driver successfully casts the bound perl scalar to a non-string type then the string portion of the scalar will be discarded. =end original ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢¥É¥é¥¤¥Ð¤¬¥Ð¥¤¥ó¥É¤µ¤ì¤¿perl¥¹¥«¥é¡¼¤òʸ»úÎó°Ê³°¤Î·¿¤Ë¥­¥ã¥¹¥È¤·¤¿¤È¤­¤Ë¡¢¥¹¥«¥é¡¼¤Îʸ»úÎóÉôʬ¤¬ÇË´þ¤µ¤ì¤Þ¤¹¡£ (TBR) =item C =begin original If C<$sv> cannot be cast to the requested C<$sql_type> then by default it is left untouched and no error is generated. If you specify C and the cast fails, this will generate an error. =end original C<$sv>¤¬Í׵ᤵ¤ì¤¿C<$sql_type>¤Ë¥­¥ã¥¹¥È¤Ç¤­¤Ê¤¤¾ì¹ç¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤ÏÊѹ¹¤µ¤ì¤º¡¢¥¨¥é¡¼¤ÏÀ¸À®¤µ¤ì¤Þ¤»¤ó¡£ C¤ò»ØÄꤷ¤Æ¥­¥ã¥¹¥È¤¬¼ºÇÔ¤¹¤ë¤È¡¢¥¨¥é¡¼¤¬À¸À®¤µ¤ì¤Þ¤¹¡£ (TBR) =back =begin original The returned C<$sts> value is: =end original ÊÖ¤µ¤ì¤¿ C<$sts> ¤ÎÃͤÏ: -2 sql_type is not handled -1 sv is undef so unchanged 0 sv could not be cast cleanly and DBIstcf_STRICT was used 1 sv could not be case and DBIstcf_STRICT was not used 2 sv was cast successfully =begin original This method is exported by the :utils tag and was introduced in DBI 1.611. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï :utils ¥¿¥°¤Ç¥¨¥¯¥¹¥Ý¡¼¥È¤µ¤ì¡¢DBI 1.611 ¤Ç ƳÆþ¤µ¤ì¤Þ¤·¤¿¡£ =head2 DBI Dynamic Attributes (DBI ưŪ°À­) =begin original Dynamic attributes are always associated with the I (that handle is represented by C<$h> in the descriptions below). =end original ưŪ°À­¤Ï I<ºÇ¸å¤Ë»È¤ï¤ì¤¿¥Ï¥ó¥É¥ë> ¤Ë´ØÏ¢¤Å¤±¤é¤ì¤Þ¤¹¡£ (¤½¤Î¥Ï¥ó¥É¥ë¤Ï°Ê²¼¤ÎÀâÌÀ¤Ç¤Ï C<$h> ¤Ç¼¨¤µ¤ì¤Þ¤¹) =begin original Where an attribute is equivalent to a method call, then refer to the method call for all related documentation. =end original °À­¤¬¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ÈƱÍͤΤȤ³¤í¤Ç¤Ï¡¢¤¹¤Ù¤Æ¤Î´ØÏ¢¤¹¤ë ¥É¥­¥å¥á¥ó¥Æ¡¼¥·¥ç¥ó¤Ç¤½¤Î¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Warning: these attributes are provided as a convenience but they do have limitations. Specifically, they have a short lifespan: because they are associated with the last handle used, they should only be used I after calling the method that "sets" them. If in any doubt, use the corresponding method call. =end original ·Ù¹ð: Êص¹¾å¡¢¤³¤ì¤é¤Î°À­¤òÍÑ°Õ¤·¤Æ¤¤¤Þ¤¹¤¬¡¢¸Â³¦¤¬¤¢¤ê¤Þ¤¹¡£ Æäˤ³¤ì¤é¤ÎÍ­¸ú¤Ê»þ´Ö¤ÏŤ¯¤¢¤ê¤Þ¤»¤ó: ºÇ¸å¤Ë»È¤ï¤ì¤¿¥Ï¥ó¥É¥ë¤Ë ´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¤¿¤á¤Ë¡¢¤½¤ì¤é¤ò¡ÖÀßÄꤷ¤¿¡×¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤¿ I<¤¹¤°¸å> ¤Ë¤·¤«»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£ ¾¯¤·¤Ç¤âµ¿Ì䤬¤¢¤ì¤Ð¡¢Âбþ¤¹¤ë¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =head3 C<$DBI::err> =begin original Equivalent to C<$h-Eerr>. =end original C<$h-Eerr> ¤ÈÅù²Á¤Ç¤¹¡£ =head3 C<$DBI::errstr> =begin original Equivalent to C<$h-Eerrstr>. =end original C<$h-Eerrstr> ¤ÈÅù²Á¤Ç¤¹¡£ =head3 C<$DBI::state> =begin original Equivalent to C<$h-Estate>. =end original C<$h-Estate> ¤ÈÅù²Á¤Ç¤¹¡£ =head3 C<$DBI::rows> =begin original Equivalent to C<$h-Erows>. Please refer to the documentation for the L method. =end original C<$h-Erows> ¤ÈÅù²Á¤Ç¤¹¡£ L ¥á¥½¥Ã¥É¤Îʸ½ñ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C<$DBI::lasth> =begin original Returns the DBI object handle used for the most recent DBI method call. If the last DBI method call was a DESTROY then $DBI::lasth will return the handle of the parent of the destroyed handle, if there is one. =end original ºÇ¸å¤Î DBI ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤Ë»È¤ï¤ì¤¿ DBI ¥ª¥Ö¥¸¥§¥¯¥È¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ ºÇ¸å¤Î DBI ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤¬ DESTROY ¤Ç¤¢¤ì¤Ð¡¢$DBI::lasth ¤Ï¤â¤·¤¢¤ì¤Ð¡¢ Ç˲õ¤µ¤ì¤¿¥Ï¥ó¥É¥ë¤Î¿Æ¤Î¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ =head1 METHODS COMMON TO ALL HANDLES (Á´¤Æ¤Î¥Ï¥ó¥É¥ë¤Ë¶¦Ä̤Υ᥽¥Ã¥É) =begin original The following methods can be used by all types of DBI handles. =end original °Ê²¼¤Î¥á¥½¥Ã¥É¤Ï DBI ¥Ï¥ó¥É¥ë¤Î¤¹¤Ù¤Æ¤Î¥¿¥¤¥×¤Ë»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =head3 C $rv = $h->err; =begin original Returns the I database engine error code from the last driver method called. The code is typically an integer but you should not assume that. =end original ºÇ¸å¤Î¥É¥é¥¤¥Ð´Ø¿ô¸Æ¤Ó½Ð¤·¤Ë¤Ä¤¤¤Æ I<¥Í¥¤¥Æ¥£¥Ö> ¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó ¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£ ¥³¡¼¥É¤Ïŵ·¿Åª¤Ë¤ÏÀ°¿ô¤Ç¤¹¤¬¡¢¤½¤ì¤òÁÛÄꤹ¤ë¤Ù¤­¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original The DBI resets $h->err to undef before almost all DBI method calls, so the value only has a short lifespan. Also, for most drivers, the statement handles share the same error variable as the parent database handle, so calling a method on one handle may reset the error on the related handles. =end original DBI ¤Ï¤Û¤È¤ó¤ÉÁ´¤Æ¤Î DBI ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë $h->err ¤ò undef ¤Ë ¥ê¥»¥Ã¥È¤¹¤ë¤Î¤Ç¡¢¤³¤ÎÃͤÏû¤¤´Ö¤À¤±Í­¸ú¤Ç¤¹¡£ ¤Þ¤¿¤Û¤È¤ó¤É¤Î¥É¥é¥¤¥Ð¤Ç¤Ï¡¢Ê¸¥Ï¥ó¥É¥ë¤ÏƱ¤¸¥¨¥é¡¼ÊÑ¿ô¤ò ¿Æ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤È¶¦Í­¤¹¤ë¤Î¤Ç¡¢¤¢¤ë¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤È¡¢ ´ØÏ¢¤¹¤ët¥Ï¥ó¥É¥ë¤Î¥¨¥é¡¼¤ò¥ê¥»¥Ã¥È¤¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original (Methods which don't reset err before being called include err() and errstr(), obviously, state(), rows(), func(), trace(), trace_msg(), ping(), and the tied hash attribute FETCH() and STORE() methods.) =end original (¥³¡¼¥ë¤µ¤ì¤ëÁ°¤Ëerr¤ò¥ê¥»¥Ã¥È¤·¤Ê¤¤¥á¥½¥Ã¥É¤Ë¤Ï¡¢err()¤Èerrstr()¡¢¤â¤Á¤í¤óstate()¡¢rows()¡¢func()¡¢trace()¡¢trace_msg()¡¢ping()¡¢¤½¤·¤Æ¥¿¥¤¥Ï¥Ã¥·¥å°À­¤ÎFETCH()¥á¥½¥Ã¥É¤ÈSTORE()¥á¥½¥Ã¥É¤¬´Þ¤Þ¤ì¤Þ¤¹¡£ (TBR) =begin original If you need to test for specific error conditions I have your program be portable to different database engines, then you'll need to determine what the corresponding error codes are for all those engines and test for all of them. =end original ÆÃÄê¤Î¥¨¥é¡¼¾õ¶·¤Ë¤Ä¤¤¤Æ¥Æ¥¹¥È¤¹¤ëɬÍפ¬¤¢¤ê¡¢I<¤«¤Ä> ¤¢¤Ê¤¿¤Î¥×¥í¥°¥é¥à¤¬ ¾¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥¨¥ó¥¸¥ó¤ËÂФ·¤Æ°Ü¿¢²Äǽ¤Ë¤¹¤ëɬÍפ¬¤¢¤ì¤Ð¡¢¤½¤ì¤é ¤¹¤Ù¤Æ¤Î¥¨¥ó¥¸¥ó¤Ë¤Ä¤¤¤ÆÂбþ¤¹¤ë¥¨¥é¡¼¥³¡¼¥É¤¬²¿¤«¤òȽÄꤷ¡¢¤½¤ì¤é¤Î ¤¹¤Ù¤Æ¤Ë¤Ä¤¤¤Æ¥Æ¥¹¥È¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ =begin original The DBI uses the value of $DBI::stderr as the C value for internal errors. Drivers should also do likewise. The default value for $DBI::stderr is 2000000000. =end original DBI ¤Ï $DBI::stderr ¤ÎÃͤò¡¢ÆâÉô¥¨¥é¡¼¤Î¤¿¤á¤Î C ÃͤȤ·¤Æ»È¤¤¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤â»÷¤¿¤è¤¦¤Ê¤³¤È¤ò¤·¤Þ¤¹¡£ $DBI::stderr ¤Î¥Ç¥Õ¥©¥ë¥ÈÃÍ¤Ï 2000000000 ¤Ç¤¹¡£ =begin original A driver may return C<0> from err() to indicate a warning condition after a method call. Similarly, a driver may return an empty string to indicate a 'success with information' condition. In both these cases the value is false but not undef. The errstr() and state() methods may be used to retrieve extra information in these cases. =end original ¥É¥é¥¤¥Ð¤Ïerr()¤«¤éC<0>¤òÊÖ¤·¤Æ¡¢¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¸å¤Î·Ù¹ð¾ò·ï¤ò¼¨¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ƱÍͤˡ¢¥É¥é¥¤¥Ð¤Ï'success with information'¾ò·ï¤ò¼¨¤¹¤¿¤á¤Ë¶õ¤Îʸ»úÎó¤òÊÖ¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤³¤ì¤é¤ÎξÊý¤Î¾ì¹ç¡¢ÃͤÏfalse¤Ç¤¹¤¬¡¢undef¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ errstr()¤ª¤è¤Óstate()¥á¥½¥Ã¥É¤Ï¡¢¤³¤ì¤é¤Î¾ì¹ç¤ËÄɲþðÊó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë»ÈÍѤǤ­¤Þ¤¹¡£ (TBR) =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $str = $h->errstr; =begin original Returns the native database engine error message from the last DBI method called. This has the same lifespan issues as the L method described above. =end original ºÇ¸å¤Î DBI ´Ø¿ô¸Æ¤Ó½Ð¤·¤Ë¤Ä¤¤¤Æ¡¢¥Í¥¤¥Æ¥£¥Ö¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÊÖ¤·¤Þ¤¹¡£ ¾åµ­¤ÇÀâÌÀ¤·¤¿ L ¥á¥½¥Ã¥É¤ÈƱ¤¸Í­¸ú´ü´Ö¤ÎÌäÂê¤ò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£ =begin original The returned string may contain multiple messages separated by newline characters. =end original ÊÖ¤µ¤ì¤¿Ê¸»úÎó¤Ï²þ¹Ôʸ»ú¤Ç¶èÀÚ¤é¤ì¤¿Ê£¿ô¤Î¥á¥Ã¥»¡¼¥¸¤ò ´Þ¤ó¤Ç¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original The errstr() method should not be used to test for errors, use err() for that, because drivers may return 'success with information' or warning messages via errstr() for methods that have not 'failed'. =end original ¥¨¥é¡¼¤Î¥Æ¥¹¥È¤Ë¤Ïerrstr()¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ ¥¨¥é¡¼¤Î¥Æ¥¹¥È¤Ë¤Ïerr()¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤ì¤Ï¡¢¡Ö¼ºÇԡפ·¤Æ¤¤¤Ê¤¤¥á¥½¥Ã¥É¤ËÂФ·¤Æ¡¢¥É¥é¥¤¥Ð¤¬errstr()¤ò²ð¤·¤Æ¡Ö¾ðÊóÉÕ¤­¤ÎÀ®¸ù¡×¤Þ¤¿¤Ï·Ù¹ð¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¤Ç¤¹¡£ (TBR) =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $str = $h->state; =begin original Returns a state code in the standard SQLSTATE five character format. Note that the specific success code C<00000> is translated to any empty string (false). If the driver does not support SQLSTATE (and most don't), then state() will return C (General Error) for all errors. =end original ¥¨¥é¡¼¥³¡¼¥É¤òɸ½à¤Î SQLSTATE ¤Î 5 ʸ»ú·Á¼°¤ÇÊÖ¤·¤Þ¤¹¡£ ¤¢¤ëÀµ¾ï¥³¡¼¥É C<00000> ¤Ï¡¢¶õʸ»úÎó(µ¶)¤ËÊÑ´¹¤µ¤ì¤Æ¤·¤Þ¤¦¤³¤È¤Ë Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤â¤·¥É¥é¥¤¥Ð¤¬ SQLSTATE ¤ËÂбþ¤·¤Æ¤¤¤Ê¤±¤ì¤Ð(¤Û¤È¤ó¤É¤¬ Âбþ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¤¹¤¬)¡¢state() ¤Ï¤¹¤Ù¤Æ¤Î¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ C(°ìÈÌ¥¨¥é¡¼)¤òÊÖ¤·¤Þ¤¹¡£ =begin original The driver is free to return any value via C, e.g., warning codes, even if it has not declared an error by returning a true value via the L method described above. =end original ¥É¥é¥¤¥Ð¤Ï C ¤Ç¤É¤Î¤è¤¦¤ÊÃͤòÊÖ¤¹¤³¤È¤â¼«Í³¤Ç¤¹; Î㤨¤Ð ·Ù¹ð¥³¡¼¥É; ¾åµ­¤Î L ¥á¥½¥Ã¥É¤ò²ð¤·¤Æ¿¿¤ÎÃͤòÊÖ¤¹¤³¤È¤Ë¤è¤ê Àë¸À¤µ¤ì¤ë¥¨¥é¡¼¤Ç¤Ê¤«¤Ã¤¿¤È¤·¤Æ¤â¡£ =begin original The state() method should not be used to test for errors, use err() for that, because drivers may return a 'success with information' or warning state code via state() for methods that have not 'failed'. =end original state()¥á¥½¥Ã¥É¤Ï¥¨¥é¡¼¤Î¥Æ¥¹¥È¤Ë¤Ï»ÈÍѤ·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ err()¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤ì¤Ï¡¢¥É¥é¥¤¥Ð¤¬'¾ðÊóÉÕ¤­¤ÎÀ®¸ù'¤òÊÖ¤¹¾ì¹ç¤ä¡¢'¼ºÇÔ'¤·¤Æ¤¤¤Ê¤¤¥á¥½¥Ã¥É¤ËÂФ·¤Æstate()¤ò²ð¤·¤Æ·Ù¹ð¾õÂÖ¥³¡¼¥É¤òÊÖ¤¹¾ì¹ç¤¬¤¢¤ë¤¿¤á¤Ç¤¹¡£ (TBR) =head3 C $rv = $h->set_err($err, $errstr); $rv = $h->set_err($err, $errstr, $state); $rv = $h->set_err($err, $errstr, $state, $method); $rv = $h->set_err($err, $errstr, $state, $method, $rv); =begin original Set the C, C, and C values for the handle. This method is typically only used by DBI drivers and DBI subclasses. =end original ¥Ï¥ó¥É¥ë¤Î¤¿¤á¤Î C, C, C ¤ÎÃͤòÀßÄꤷ¤Þ¤¹¡£ ¤³¤Î¥á¥½¥Ã¥É¤Ïŵ·¿Åª¤Ë¤Ï DBI ¥É¥é¥¤¥Ð¤È DBI ¥µ¥Ö¥¯¥é¥¹¤Ç¤Î¤ß»ÈÍѤµ¤ì¤Þ¤¹¡£ =begin original If the L attribute holds a reference to a subroutine it is called first. The subroutine can alter the $err, $errstr, $state, and $method values. See L for full details. If the subroutine returns a true value then the handle C, C, and C values are not altered and set_err() returns an empty list (it normally returns $rv which defaults to undef, see below). =end original L°À­¤¬¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î»²¾È¤òÊÝ»ý¤·¤Æ¤¤¤ë¾ì¹ç¡¢¤½¤ì¤¬ºÇ½é¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢$err¡¢$errstr¡¢$state¡¢¤ª¤è¤Ó$methodÃͤòÊѹ¹¤Ç¤­¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤¬¿¿¤ÎÃͤòÊÖ¤¹¾ì¹ç¡¢¥Ï¥ó¥É¥ëC¡¢C¡¢¤ª¤è¤ÓCÃͤÏÊѹ¹¤µ¤ì¤º¡¢set_err()¤Ï¶õ¤Î¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹(Ä̾ï¤Ï$rv¤òÊÖ¤·¡¢¥Ç¥Õ¥©¥ë¥È¤Ïundef¤Ç¤¹¡£ °Ê²¼¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£ (TBR) =begin original Setting C to a I value indicates an error and will trigger the normal DBI error handling mechanisms, such as C and C, if they are enabled, when execution returns from the DBI back to the application. =end original C¤òIÃͤËÀßÄꤹ¤ë¤È¡¢¥¨¥é¡¼¤¬¼¨¤µ¤ì¡¢C¤äC¤Ê¤É¤ÎÄ̾ï¤ÎDBI¥¨¥é¡¼½èÍý¥á¥«¥Ë¥º¥à¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢DBI¤«¤é¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¼Â¹Ô¤¬Ìᤵ¤ì¤¿¤È¤­¤Ë¡¢¤³¤ì¤é¤Î¥á¥«¥Ë¥º¥à¤¬¥È¥ê¥¬¡¼¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Setting C to C<""> indicates an 'information' state, and setting it to C<"0"> indicates a 'warning' state. Setting C to C also sets C to undef, and C to C<"">, irrespective of the values of the $errstr and $state parameters. =end original C¤òC<"">¤ËÀßÄꤹ¤ë¤È¡Ö¾ðÊó¡×¾õÂÖ¤ò¼¨¤·¡¢C<"0">¤ËÀßÄꤹ¤ë¤È¡Ö·Ù¹ð¡×¾õÂÖ¤ò¼¨¤·¤Þ¤¹¡£ C¤òC¤ËÀßÄꤹ¤ë¤È¡¢$errstr¤ª¤è¤Ó$state¥Ñ¥é¥á¡¼¥¿¤ÎÃͤ˴ط¸¤Ê¤¯¡¢C¤¬undef¤Ë¡¢C¤¬C<"">¤ËÀßÄꤵ¤ì¤Þ¤¹¡£ (TBR) =begin original The $method parameter provides an alternate method name for the C/C/C error string instead of the fairly unhelpful 'C'. =end original $method¥Ñ¥é¥á¡¼¥¿¤Ï¡¢C/C/C¥¨¥é¡¼Ê¸»úÎó¤ËÂФ·¤Æ¡¢¤¢¤Þ¤êÌò¤ËΩ¤¿¤Ê¤¤'C'¤Ç¤Ï¤Ê¤¯¡¢ÂåÂإ᥽¥Ã¥É̾¤òÄ󶡤·¤Þ¤¹¡£ (TBR) =begin original The C method normally returns undef. The $rv parameter provides an alternate return value. =end original C ¥á¥½¥Ã¥É¤ÏÉáÄÌ¤Ï undef ¤òÊÖ¤·¤Þ¤¹¡£ $rv ¥Ñ¥é¥á¡¼¥¿¤ÏÂåÂؤȤʤëÊÖ¤êÃͤòÄ󶡤·¤Þ¤¹¡£ =begin original Some special rules apply if the C or C values for the handle are I set... =end original ¥Ï¥ó¥É¥ë¤Î¤¿¤á¤Î C ¤ä C ¤ÎÃͤ¬ I<´û¤Ë> ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢ ¤¤¤¯¤Ä¤«¤ÎÆÃÊ̥롼¥ë¤¬Å¬ÍѤµ¤ì¤Þ¤¹¡Ä =begin original If C is true then: "C< [err was %s now %s]>" is appended if $err is true and C is already true and the new err value differs from the original one. Similarly "C< [state was %s now %s]>" is appended if $state is true and C is already true and the new state value differs from the original one. Finally "C<\n>" and the new $errstr are appended if $errstr differs from the existing errstr value. Obviously the C<%s>'s above are replaced by the corresponding values. =end original C¤¬true¤Î¾ì¹ç¡¢$err¤¬true¤Ç¡¢C¤¬¤¹¤Ç¤Ëtrue¤Ç¡¢¿·¤·¤¤errÃͤ¬¸µ¤ÎÃͤȰۤʤë¾ì¹ç¤Ï¡¢¡ÖC< [err was %s now %s]>¡×¤¬Äɲ䵤ì¤Þ¤¹¡£ ƱÍͤˡ¢$state¤¬true¤Ç¡¢C¤¬¤¹¤Ç¤Ëtrue¤Ç¡¢¿·¤·¤¤stateÃͤ¬¸µ¤ÎÃͤȰۤʤë¾ì¹ç¤Ï¡¢¡ÖC< [state was %s now %s]>¡×¤¬Äɲ䵤ì¤Þ¤¹¡£ ºÇ¸å¤Ë¡¢$errstr¤¬´û¸¤ÎerrstrÃͤȰۤʤë¾ì¹ç¤Ï¡¢¡ÖC<\n>¡×¤È¿·¤·¤¤$errstr¤¬Äɲ䵤ì¤Þ¤¹¡£ ÌÀ¤é¤«¤Ë¡¢¾åµ­¤ÎC<%s>¤ÏÂбþ¤¹¤ëÃͤËÃÖ¤­´¹¤¨¤é¤ì¤Þ¤¹¡£ (TBR) =begin original The handle C value is set to $err if: $err is true; or handle C value is undef; or $err is defined and the length is greater than the handle C length. The effect is that an 'information' state only overrides undef; a 'warning' overrides undef or 'information', and an 'error' state overrides anything. =end original $err¤¬true¤Î¾ì¹ç¡¢¤Þ¤¿¤Ï¥Ï¥ó¥É¥ëC¤ÎÃͤ¬undef¤Î¾ì¹ç¡¢¤Þ¤¿¤Ï$err¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Æ¡¢¤½¤ÎŤµ¤¬¥Ï¥ó¥É¥ëC¤ÎŤµ¤è¤ê¤âŤ¤¾ì¹ç¡¢¥Ï¥ó¥É¥ëC¤ÎÃͤÏ$err¤ËÀßÄꤵ¤ì¤Þ¤¹¡£ ¤½¤Î·ë²Ì¡¢'information'¾õÂÖ¤Ïundef¤Î¤ß¤ò¾å½ñ¤­¤·¡¢'warning'¤Ïundef¤Þ¤¿¤Ï'information'¤ò¾å½ñ¤­¤·¡¢'error'¾õÂ֤Ϥ¹¤Ù¤Æ¤ò¾å½ñ¤­¤·¤Þ¤¹¡£ (TBR) =begin original The handle C value is set to $state if $state is true and the handle C value was set (by the rules above). =end original $state ¤¬¿¿¤Ç¥Ï¥ó¥É¥ë¤Î C Ãͤ¬ (¾å½Ò¤Î¥ë¡¼¥ë¤Ë¤è¤ê) ÀßÄꤵ¤ì¤Æ¤¤¤ë¤Ê¤é¡¢¥Ï¥ó¥É¥ë¤Î C ¤ÎÃÍ¤Ï $state ¤ËÀßÄꤵ¤ì¤Þ¤¹¡£ =begin original Support for warning and information states was added in DBI 1.41. =end original ·Ù¹ð¤È¾ðÊó¾õÂÖ¤ÎÂбþ¤Ï DBI 1.41 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $h->trace($trace_settings); $h->trace($trace_settings, $trace_filename); $trace_settings = $h->trace; =begin original The trace() method is used to alter the trace settings for a handle (and any future children of that handle). It can also be used to change where the trace output is sent. =end original trace() ¥á¥½¥Ã¥É¤Ï¡¢¥Ï¥ó¥É¥ë(¤ª¤è¤Ó¤½¤Î¥Ï¥ó¥É¥ë¤Î¾­Íè¤Î»Ò) ¤Î ¥È¥ì¡¼¥¹ÀßÄê¤òÊѹ¹¤¹¤ë¤Î¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï¤Þ¤¿¥È¥ì¡¼¥¹½ÐÎϤò¤É¤³¤ËÁ÷¤ë¤Î¤«¤òÊѹ¹¤¹¤ë¤Î¤Ë¤â»È¤ï¤ì¤Þ¤¹¡£ =begin original There's a similar method, Ctrace>, which sets the global default trace settings. =end original »÷¤¿¤è¤¦¤Ê¥á¥½¥Ã¥É¤È¤·¤Æ Ctrace> ¤¬¤¢¤ê¡¢¤³¤ì¤Ï¥°¥í¡¼¥Ð¥ë¤Ê ¥Ç¥Õ¥©¥ë¥È¥È¥ì¡¼¥¹ÀßÄê¤òÀßÄꤷ¤Þ¤¹¡£ =begin original See the L section for full details about the DBI's powerful tracing facilities. =end original DBI ¤Î¶¯ÎϤʥȥ졼¥¹µ¡Ç½¤Ë´Ø¤¹¤ë´°Á´¤Ê¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤Î¾Ï¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $h->trace_msg($message_text); $h->trace_msg($message_text, $min_level); =begin original Writes C<$message_text> to the trace file if the trace level is greater than or equal to $min_level (which defaults to 1). Can also be called as Ctrace_msg($msg)>. =end original ¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤¬ $min_level (¥Ç¥Õ¥©¥ë¥È¤Ï 1)°Ê¾å¤Î¾ì¹ç¤Î¾ì¹ç¡¢ C<$message_text> ¤ò¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹¡£ Ctrace_msg($msg)> ¤È¸Æ¤Ó½Ð¤¹¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ =begin original See L for more details. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $h->func(@func_arguments, $func_name) or die ...; =begin original The C method can be used to call private non-standard and non-portable methods implemented by the driver. Note that the function name is given as the I argument. =end original C ¥á¥½¥Ã¥É¤Ë¤è¤ê¡¢¥É¥é¥¤¥Ð¤¬¼ÂÁõ¤·¤Æ¤¤¤ë¥×¥é¥¤¥Ù¡¼¥È¤Êɸ½à¤Ç¤Ê¤¯¡¢ °Ü¿¢¤Ç¤­¤Ê¤¤¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ´Ø¿ô̾¤¬ I<ºÇ¸å¤Î> °ú¿ô¤ÇÍ¿¤¨¤é¤ì¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original It's also important to note that the func() method does not clear a previous error ($DBI::err etc.) and it does not trigger automatic error detection (RaiseError etc.) so you must check the return status and/or $h->err to detect errors. =end original ¤Þ¤¿¡¢func()¥á¥½¥Ã¥É¤Ï°ÊÁ°¤Î¥¨¥é¡¼($DBI::err¤Ê¤É)¤ò¥¯¥ê¥¢¤»¤º¡¢¼«Æ°¥¨¥é¡¼¸¡½Ð(RaiseError¤Ê¤É)¤ò¥È¥ê¥¬¡¼¤·¤Ê¤¤¤³¤È¤ËÃí°Õ¤¹¤ë¤³¤È¤â½ÅÍפǤ¹¡£ ¥¨¥é¡¼¤ò¸¡½Ð¤¹¤ë¤Ë¤Ï¡¢¥ê¥¿¡¼¥ó¥¹¥Æ¡¼¥¿¥¹¤ä$h->err¤ò¥Á¥§¥Ã¥¯¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original (This method is not directly related to calling stored procedures. Calling stored procedures is currently not defined by the DBI. Some drivers, such as DBD::Oracle, support it in non-portable ways. See driver documentation for more details.) =end original (¤³¤Î¥á¥½¥Ã¥É¤Ï¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã¤Î¸Æ¤Ó½Ð¤·¤Ë¡¢Ä¾Àܤϴط¸¤·¤Æ¤¤¤Þ¤»¤ó¡£ ¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã¸Æ¤Ó½Ð¤·¤Ï¡¢¤¤¤Þ¤Î¤È¤³¤í DBI ¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ DBD::Oracle ¤Î¤è¤¦¤Ë¤¤¤¯¤Ä¤«¤Î¥É¥é¥¤¥Ð¤¬°Ü¿¢¤Ç¤­¤Ê¤¤·Á¤Ç¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¥É¥é¥¤¥Ð¤Î¥É¥­¥å¥á¥ó¥È¤ò¤´Í÷¤¯¤À¤µ¤¤¡£) =begin original See also install_method() in L for how you can avoid needing to use func() and gain direct access to driver-private methods. =end original func() ¤Î»ÈÍѤòÈò¤±¤Æ¡¢¥É¥é¥¤¥Ð¸ÇÍ­¤Î¥á¥½¥Ã¥É¤ËľÀÜ¥¢¥¯¥»¥¹¤¹¤ë ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï L ¤Î install_method() ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $is_implemented = $h->can($method_name); =begin original Returns true if $method_name is implemented by the driver or a default method is provided by the DBI. It returns false where a driver hasn't implemented a method and the default method is provided by the DBI is just an empty stub. =end original $method_name ¤¬¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤«¡¢¥Ç¥Õ¥©¥ë¥È¥á¥½¥Ã¥É¤¬ DBI ¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤Æ¤¤¤ë¤Ê¤é¿¿¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤¬¤³¤Î¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤Æ¤ª¤é¤º¡¢DBI ¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤Æ¤¤¤ë ¥Ç¥Õ¥©¥ë¥È¥á¥½¥Ã¥É¤¬¶õ¤Î¥¹¥¿¥Ö¤Ç¤¢¤ë¾ì¹ç¤Ïµ¶¤òÊÖ¤·¤Þ¤¹¡£ =head3 C $trace_settings_integer = $h->parse_trace_flags($trace_settings); =begin original Parses a string containing trace settings and returns the corresponding integer value used internally by the DBI and drivers. =end original ¥È¥ì¡¼¥¹ÀßÄê¤ò´Þ¤àʸ»úÎó¤ò¥Ñ¡¼¥¹¤·¤Æ¡¢DBI ¤È¥É¥é¥¤¥Ð¤ÇÆâÉô¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤ë Âбþ¤¹¤ëÀ°¿ôÃͤòÊÖ¤·¤Þ¤¹¡£ =begin original The $trace_settings argument is a string containing a trace level between 0 and 15 and/or trace flag names separated by vertical bar ("C<|>") or comma ("C<,>") characters. For example: C<"SQL|3|foo">. =end original $trace_settings °ú¿ô¤Ï½ÄËÀ ("C<|>") ¤Þ¤¿¤Ï¥«¥ó¥Þ ("C<,>") ʸ»ú¤Ç¶èÀÚ¤é¤ì¤¿¡¢ 0 ¤«¤é 15 ¤Î¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤ä¥È¥ì¡¼¥¹¥Õ¥é¥°Ì¾¤«¤é¤Ê¤ëʸ»úÎó¤Ç¤¹¡£ Îã: C<"SQL|3|foo">¡£ =begin original It uses the parse_trace_flag() method, described below, to process the individual trace flag names. =end original ¤³¤ì¤Ï¸Ä¡¹¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°Ì¾¤ò½èÍý¤¹¤ë¤¿¤á¤Ë¸å½Ò¤¹¤ë parse_trace_flag() ¥á¥½¥Ã¥É¤ò»È¤¤¤Þ¤¹¡£ =begin original The parse_trace_flags() method was added in DBI 1.42. =end original parse_trace_flags() ¥á¥½¥Ã¥É¤Ï DBI 1.42 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $bit_flag = $h->parse_trace_flag($trace_flag_name); =begin original Returns the bit flag corresponding to the trace flag name in $trace_flag_name. Drivers are expected to override this method and check if $trace_flag_name is a driver specific trace flags and, if not, then call the DBI's default parse_trace_flag(). =end original $trace_flag_name ¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°Ì¾¤ËÂбþ¤¹¤ë¥Ó¥Ã¥È¥Õ¥é¥°¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ¡¢$trace_flag_name ¤¬ ¥É¥é¥¤¥Ð¸ÇÍ­¤Î¥Õ¥é¥°¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤·¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð DBI ¤Î ¥Ç¥Õ¥©¥ë¥È¤Î parse_trace_flag() ¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤òÁÛÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original The parse_trace_flag() method was added in DBI 1.42. =end original parse_trace_flag() ¥á¥½¥Ã¥É¤Ï DBI 1.42 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $hash_ref = $h->private_attribute_info(); =begin original Returns a reference to a hash whose keys are the names of driver-private handle attributes available for the kind of handle (driver, database, statement) that the method was called on. =end original ¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¥Ï¥ó¥É¥ë¤Î¼ïÎà(¥É¥é¥¤¥Ð¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¡¢Ê¸)¤Ç ÍøÍѲÄǽ¤Ê¥É¥é¥¤¥Ð¸ÇÍ­¤Î¥Ï¥ó¥É¥ë°À­¤Î̾Á°¤ò¥­¡¼¤È¤·¤¿¥Ï¥Ã¥·¥å¤Ø¤Î ¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original For example, the return value when called with a DBD::Sybase $dbh could look like this: =end original Î㤨¤Ð¡¢DBD::Sybase $dbh ¤Ç¸Æ¤Ó½Ð¤·¤¿¤È¤­¤ÎÊÖ¤êÃͤϰʲ¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: { syb_dynamic_supported => undef, syb_oc_version => undef, syb_server_version => undef, syb_server_version_string => undef, } =begin original and when called with a DBD::Sybase $sth they could look like this: =end original ¤½¤·¤Æ DBD::Sybase $sth ¤Ç¸Æ¤Ó½Ð¤·¤¿¤È¤­¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: { syb_types => undef, syb_proc_status => undef, syb_result_type => undef, } =begin original The values should be undef. Meanings may be assigned to particular values in future. =end original ÃÍ¤Ï undef ¤Ç¤¢¤ë¤Ù¤­¤Ç¤¹¡£ ¾­ÍèÆÃÄê¤ÎÃͤ˴ؤ¹¤ë³ä¤êÅö¤Æ¤¬¹Ô¤ï¤ì¤Þ¤¹¡£ =head3 C $rc = $h1->swap_inner_handle( $h2 ); $rc = $h1->swap_inner_handle( $h2, $allow_reparent ); =begin original Brain transplants for handles. You don't need to know about this unless you want to become a handle surgeon. =end original ¥Ï¥ó¥É¥ë¤ÎǾ°Ü¿¢¤Ç¤¹¡£ ¥Ï¥ó¥É¥ë¤Î³°²Ê°å¤Ë¤Ê¤í¤¦¤È»×¤Ã¤Æ¤¤¤ë¤Î¤Ç¤Ê¤¤¸Â¤ê¤³¤ì¤Ë¤Ä¤¤¤ÆÃΤë ɬÍפϤ¢¤ê¤Þ¤»¤ó¡£ =begin original A DBI handle is a reference to a tied hash. A tied hash has an I hash that actually holds the contents. The swap_inner_handle() method swaps the inner hashes between two handles. The $h1 and $h2 handles still point to the same tied hashes, but what those hashes are tied to has been swapped. In effect $h1 I $h2 and vice-versa. This is powerful stuff, expect problems. Use with care. =end original DBI ¥Ï¥ó¥É¥ë¤Ï tie ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¹¡£ tie ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤Ï¼ÂºÝ¤ËÆâÍƤòÊÝ»ý¤·¤Æ¤¤¤ë I<ÆâÉô> ¥Ï¥Ã¥·¥å¤ò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£ swap_inner_handle() ¥á¥½¥Ã¥É¤ÏÆó¤Ä¤Î¥Ï¥ó¥É¥ë¤ÎÆâÉô¥Ï¥Ã¥·¥å¤òÆþ¤ìÂؤ¨¤Þ¤¹¡£ $h1 ¤È $h2 ¤Î¥Ï¥ó¥É¥ë¤ÏƱ¤¸ tie ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤ò¼¨¤·¤¿¤Þ¤Þ¤Ç¤¹¤¬¡¢ ¤É¤Î¥Ï¥Ã¥·¥å¤Ë tie ¤·¤Æ¤¤¤ë¤«¤ÏÆþ¤ìÂؤï¤ê¤Þ¤¹¡£ »ö¼Â¾å $h1 ¤Ï $h2 ¤Ë I<¤Ê¤ê>¡¢µÕ¤â¤Þ¤¿¿¿¤Ê¤ê¤Ç¤¹¡£ ¤³¤ì¤ÏÌäÂê¤â¤Ï¤é¤ó¤Ç¤¤¤ë¡¢¶¯ÎϤʵ¡Ç½¤Ç¤¹¡£ Ãí°Õ¤·¤Æ»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =begin original As a small safety measure, the two handles, $h1 and $h2, have to share the same parent unless $allow_reparent is true. =end original ¾®¤µ¤Ê°ÂÁ´À­¤Î¼ÜÅ٤Ȥ·¤Æ¡¢Æó¤Ä¤Î¥Ï¥ó¥É¥ë $h1 ¤È $h2 ¤Ï¡¢ $allow_reparent ¤¬¿¿¤Ç¤Ê¤¤¸Â¤êƱ¤¸¿Æ¤ò¶¦Í­¤·¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ =begin original The swap_inner_handle() method was added in DBI 1.44. =end original swap_inner_handle() ¥á¥½¥Ã¥É¤Ï DBI 1.44 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =begin original Here's a quick kind of 'diagram' as a worked example to help think about what's happening: =end original °Ê²¼¤Ï¡¢²¿¤¬µ¯¤­¤Æ¤¤¤ë¤«¤Ë¤Ä¤¤¤Æ¹Í¤¨¤ë½õ¤±¤È¤Ê¤ëÆ°ºî¤¹¤ëÎã¤Î ¡Ö¥À¥¤¥¢¥°¥é¥à¡×¤Ç¤¹: Original state: dbh1o -> dbh1i sthAo -> sthAi(dbh1i) dbh2o -> dbh2i swap_inner_handle dbh1o with dbh2o: dbh2o -> dbh1i sthAo -> sthAi(dbh1i) dbh1o -> dbh2i create new sth from dbh1o: dbh2o -> dbh1i sthAo -> sthAi(dbh1i) dbh1o -> dbh2i sthBo -> sthBi(dbh2i) swap_inner_handle sthAo with sthBo: dbh2o -> dbh1i sthBo -> sthAi(dbh1i) dbh1o -> dbh2i sthAo -> sthBi(dbh2i) =head3 C $h->visit_child_handles( $coderef ); $h->visit_child_handles( $coderef, $info ); =begin original Where $coderef is a reference to a subroutine and $info is an arbitrary value which, if undefined, defaults to a reference to an empty hash. Returns $info. =end original $coderef ¤Ï¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¡¢$info ¤ÏǤ°Õ¤ÎÃͤǤ¢¤ê¡¢ ¤â¤·Ì¤ÄêµÁ¤Ê¤é¥Ç¥Õ¥©¥ë¥È¤Ï¤«¤é¥Ï¥Ã¥·¥å¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤È¤Ê¤ê¤Þ¤¹¡£ $info ¤òÊÖ¤·¤Þ¤¹¡£ =begin original For each child handle of $h, if any, $coderef is invoked as: =end original »Ò¥Ï¥ó¥É¥ë¤¬¤¢¤ì¤Ð¡¢³Æ¥Ï¥ó¥É¥ë $h Ëè¤Ë¡¢$coderef ¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ µ¯Æ°¤µ¤ì¤Þ¤¹: $coderef->($child_handle, $info); =begin original If the execution of $coderef returns a true value then C is called on that child handle and passed the returned value as $info. =end original $coderef ¤Î¼Â¹Ô¤Ë¤è¤Ã¤Æ¿¿¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤È¡¢L ¤¬ »Ò¥Ï¥ó¥É¥ë¤Ë¸Æ¤Ó½Ð¤µ¤ì¡¢ÊÖ¤µ¤ì¤¿Ãͤò $info ¤È¤·¤ÆÅϤ·¤Þ¤¹¡£ =begin original For example: =end original Î㤨¤Ð: # count database connections with names (DSN) matching a pattern my $connections = 0; $dbh->{Driver}->visit_child_handles(sub { my ($h, $info) = @_; ++$connections if $h->{Name} =~ /foo/; return 0; # don't visit kids }) =begin original See also L. =end original L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head1 ATTRIBUTES COMMON TO ALL HANDLES (Á´¤Æ¤Î¥Ï¥ó¥É¥ë¤Ë¶¦Ä̤ΰÀ­) =begin original These attributes are common to all types of DBI handles. =end original ¤³¤ì¤é¤Î°À­¤ÏDBI¤ÎÁ´¼ïÎà¤Î¥Ï¥ó¥É¥ë¤Ë¤Ä¤¤¤Æ¶¦Ä̤Ǥ¹¡£ =begin original Some attributes are inherited by child handles. That is, the value of an inherited attribute in a newly created statement handle is the same as the value in the parent database handle. Changes to attributes in the new statement handle do not affect the parent database handle and changes to the database handle do not affect existing statement handles, only future ones. =end original °À­¤Ë¤è¤Ã¤Æ¤Ï¡¢»Ò¶¡¤Ë·Ñ¾µ¤µ¤ì¤ë¤â¤Î¤â¤¢¤ê¤Þ¤¹¡£¤Ä¤Þ¤ê¿·¤·¤¯ºî¤é¤ì¤ë ʸ¥Ï¥ó¥É¥ë¤Ç¤Î·Ñ¾µ¤µ¤ì¤ë°À­¤ÎÃͤϡ¢¤½¤Î¿Æ¤È¤Ê¤ë ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ç¤ÎÃͤÈƱ¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£ ¿·¤·¤¤Ê¸¥Ï¥ó¥É¥ë¤Ç¤Î°À­¤òÊѹ¹¤·¤Æ¤â¿Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ë¤Ï ±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó¤·¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î°À­¤òÊѹ¹¤·¤Æ¤â¡¢ ´û¸¤Îʸ¥Ï¥ó¥É¥ë¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó¡£ ¿·¤·¤¯ºî¤é¤ì¤ë¤â¤Î¤À¤±¤Ç¤¹¡£ =begin original Attempting to set or get the value of an unknown attribute generates a warning, except for private driver specific attributes (which all have names starting with a lowercase letter). =end original ¥É¥é¥¤¥ÐÆÃÍ­¤Î¥×¥é¥¤¥Ù¡¼¥È¤Ê°À­(¤³¤ì¤é¤Î̾Á°¤Ï¾®Ê¸»ú¤Ç¤Ï¤¸¤Þ¤ê¤Þ¤¹)¤ò ½ü¤¤¤Æ¤Ï¡¢·è¤á¤é¤ì¤Æ¤¤¤Ê¤¤Â°À­¤òÀßÄꤢ¤ë¤¤¤Ï¼èÆÀ¤·¤è¤¦¤È¤¹¤ë¤È ·Ù¹ð¤¬È¯À¸¤·¤Þ¤¹¡£ =begin original Example: =end original Îã: $h->{AttributeName} = ...; # set/write ... = $h->{AttributeName}; # get/read =head3 C (boolean, inherited) =begin original The C attribute enables useful warnings for certain bad practices. It is enabled by default and should only be disabled in rare circumstances. Since warnings are generated using the Perl C function, they can be intercepted using the Perl C<$SIG{__WARN__}> hook. =end original C °À­¤Ï¤¢¤ë¼ï¤Î¤è¤¯¤Ê¤¤¼ÂÁ©¤ËÂФ¹¤ëÍ­¸ú¤Ê·Ù¹ð¤òÍ­¸ú¤Ë¤·¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤ÏÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï¥Ç¥Õ¥©¥ë¥È¤ÇÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢Æüì¤Ê¾õ¶·¤Ç¤Î¤ß̵¸ú¤Ë¤¹¤ë¤Ù¤­¤Ç¤¹¡£ ·Ù¹ð¤Ï Perl ¤Î C ´Ø¿ô¤ò»È¤Ã¤ÆÀ¸À®¤µ¤ì¤ë¤Î¤Ç¡¢Perl ¤Î C<$SIG{__WARN__}> ¥Õ¥Ã¥¯¤ò»È¤Ã¤Æ¡¢³ä¤ê¹þ¤à¤³¤È¤¬²Äǽ¤Ç¤¹¡£ =begin original The C attribute is not related to the C attribute. =end original C °À­¤Ï C °À­¤È¤Ï´Ø·¸¤¢¤ê¤Þ¤»¤ó¡£ =head3 C (boolean, read-only) =begin original The C attribute is true if the handle object is "active". This is rarely used in applications. The exact meaning of active is somewhat vague at the moment. For a database handle it typically means that the handle is connected to a database (C<$dbh-Edisconnect> sets C off). For a statement handle it typically means that the handle is a C ¤Ç¤¢¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ (¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤·¤Æ¤·¤Þ¤¦¤«¡¢ C<$sth-Efinish> ¤ò¼Â¹Ô¤¹¤ë¤È C ¤ò¥ª¥Õ¤ËÀßÄꤷ¤Þ¤¹)¡£ =head3 C (boolean) =begin original The C attribute is true if the handle object has been "executed". Currently only the $dbh do() method and the $sth execute(), execute_array(), and execute_for_fetch() methods set the C attribute. =end original C °À­¤Ï¡¢¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È¤¬¡Ö¼Â¹Ô¤µ¤ì¤¿¡×¾ì¹ç¤Ë¿¿¤Ë¤Ê¤ê¤Þ¤¹¡£ ¸½ºß¤Î¤È¤³¤í¡¢$dbh ¤Î do() ¥á¥½¥Ã¥É¤È¡¢$sth ¤Î execute(), execute_array(), execute_for_fetch() ¥á¥½¥Ã¥É¤¬ C °À­¤òÀßÄꤷ¤Þ¤¹¡£ =begin original When it's set on a handle it is also set on the parent handle at the same time. So calling execute() on a $sth also sets the C attribute on the parent $dbh. =end original ¥Ï¥ó¥É¥ë¤ËÀßÄꤹ¤ë¤È¡¢Æ±»þ¤Ë¿Æ¥Ï¥ó¥É¥ë¤Ë¤âÀßÄꤵ¤ì¤Þ¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢$sth¤Çexecute()¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¿Æ¤Î$dbh¤Ë¤âC°À­¤¬ÀßÄꤵ¤ì¤Þ¤¹¡£ (TBR) =begin original The C attribute for a database handle is cleared by the commit() and rollback() methods (even if they fail). The C attribute of a statement handle is not cleared by the DBI under any circumstances and so acts as a permanent record of whether the statement handle was ever used. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÎC°À­¤Ï¡¢(¼ºÇÔ¤·¤¿¾ì¹ç¤Ç¤â)commit()¤ª¤è¤Órollback()¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ¥¯¥ê¥¢¤µ¤ì¤Þ¤¹¡£ ʸ¥Ï¥ó¥É¥ë¤ÎC°À­¤Ï¡¢¤É¤Î¤è¤¦¤Ê¾õ¶·¤Ç¤âDBI¤Ë¤è¤Ã¤Æ¥¯¥ê¥¢¤µ¤ì¤Ê¤¤¤¿¤á¡¢Ê¸¥Ï¥ó¥É¥ë¤¬»ÈÍѤµ¤ì¤¿¤³¤È¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¼¨¤¹±Ê³Ū¤Ê¥ì¥³¡¼¥É¤È¤·¤Æµ¡Ç½¤·¤Þ¤¹¡£ (TBR) =begin original The C attribute was added in DBI 1.41. =end original C °À­¤Ï DBI 1.41 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (integer, read-only) =begin original For a driver handle, C is the number of currently existing database handles that were created from that driver handle. For a database handle, C is the number of currently existing statement handles that were created from that database handle. For a statement handle, the value is zero. =end original ¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢C ¤Ï¤½¤Î¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¤«¤éºî¤é¤ì¡¢¸½ºß ¸ºß¤·¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î¿ô¤Ë¤Ê¤ê¤Þ¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢C ¤Ï¤½¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤«¤éºî¤é¤ì¡¢ ¸½ºß¸ºß¤·¤Æ¤¤¤ëʸ¥Ï¥ó¥É¥ë¤Î¿ô¤Ë¤Ê¤ê¤Þ¤¹¡£ ʸ¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢ÃÍ¤Ï 0 ¤Ç¤¹¡£ =head3 C (integer, read-only) =begin original Like C, but only counting those that are C (as above). =end original C ¤ÈƱÍͤǤ¹¤¬¡¢C ¤Ê¤â¤Î¤À¤±¤ò¥«¥¦¥ó¥È¤·¤Þ¤¹(¾åµ­»²¾È)¡£ =head3 C (hash ref) =begin original For a database handle, C returns a reference to the cache (hash) of statement handles created by the L method. For a driver handle, returns a reference to the cache (hash) of database handles created by the L method. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢C ¤Ï L ¥á¥½¥Ã¥É¤Ë¤è¤êÀ¸À®¤µ¤ì¤¿Ê¸¥Ï¥ó¥É¥ë¤Î ¥­¥ã¥Ã¥·¥å(¥Ï¥Ã¥·¥å)¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢L ¥á¥½¥Ã¥É¤Ë¤è¤êºîÀ®¤µ¤ì¤¿ ʸ¥Ï¥ó¥É¥ë¤Î¥­¥ã¥Ã¥·¥å(¥Ï¥Ã¥·¥å)¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =head3 C (scalar, read-only) =begin original The C attribute identifies the type of a DBI handle. Returns "dr" for driver handles, "db" for database handles and "st" for statement handles. =end original C °À­¤Ï DBI ¥Ï¥ó¥É¥ë¤Î¼ïÎà¤ò¼±Ê̤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¤Î¾ì¹ç¤Ï "dr" ¤ò¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î¾ì¹ç¤Ï "db" ¤ò¡¢ ʸ¥Ï¥ó¥É¥ë¤Î¾ì¹ç¤Ï "st" ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C (array ref) =begin original The ChildHandles attribute contains a reference to an array of all the handles created by this handle which are still accessible. The contents of the array are weak-refs and will become undef when the handle goes out of scope. =end original ChildHandles °À­¤Ï¡¢¤³¤Î¥Ï¥ó¥É¥ë¤Ë¤è¤Ã¤Æºî¤é¤ì¤Æ¤Þ¤À¥¢¥¯¥»¥¹²Äǽ¤Ê Á´¤Æ¤Î¥Ï¥ó¥É¥ë¤ÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤ò´Þ¤ß¤Þ¤¹¡£ ÇÛÎó¤ÎÆâÍƤϼ夤»²¾È¤Ç¡¢¥Ï¥ó¥É¥ë¤¬¥¹¥³¡¼¥×³°¤Ë½Ð¤ë¤È undef ¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original C returns undef if your perl version does not support weak references (check the L module). The referenced array returned should be treated as read-only. =end original Perl¤Î¥Ð¡¼¥¸¥ç¥ó¤¬¼å¤¤»²¾È¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢C¤Ïundef¤òÊÖ¤·¤Þ¤¹(L¥â¥¸¥å¡¼¥ë¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤)¡£ ÊÖ¤µ¤ì¤¿»²¾ÈÇÛÎó¤ÏÆɤ߼è¤êÀìÍѤȤ·¤Æ°·¤ï¤ì¤Þ¤¹¡£ (TBR) =begin original For example, to enumerate all driver handles, database handles and statement handles: =end original Î㤨¤Ð¡¢Á´¤Æ¤Î¥É¥é¥¤¥Ð¥Ï¥ó¥É¥ë¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¡¢Ê¸¥Ï¥ó¥É¥ë¤ò ¿ô¤¨¾å¤²¤ë¤Ë¤Ï: sub show_child_handles { my ($h, $level) = @_; printf "%sh %s %s\n", $h->{Type}, "\t" x $level, $h; show_child_handles($_, $level + 1) for (grep { defined } @{$h->{ChildHandles}}); } my %drivers = DBI->installed_drivers(); show_child_handles($_, 0) for (values %drivers); =head3 C (boolean, inherited) =begin original The C attribute is used by emulation layers (such as Oraperl) to enable compatible behaviour in the underlying driver (e.g., DBD::Oracle) for this handle. Not normally set by application code. =end original C °À­¤Ï(Oraperl ¤Î¤è¤¦¤Ê)¥¨¥ß¥å¥ì¡¼¥·¥ç¥óÁؤǻȤï¤ì¡¢ ¤³¤Î¥Ï¥ó¥É¥ë¤Î¤¿¤á¤Ë¸µ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥É¥é¥¤¥Ð(Î㤨¤Ð DBD::Oracle)¤Ç ¸ß´¹À­¤Î¤¢¤ëÆ°¤­¤ò¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤·¤Þ¤¹¡£ ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤Ç¤ÏÄ̾ï»È¤ï¤ì¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original It also has the effect of disabling the 'quick FETCH' of attribute values from the handles attribute cache. So all attribute values are handled by the drivers own FETCH method. This makes them slightly slower but is useful for special-purpose drivers like DBD::Multiplex. =end original ¤Þ¤¿¡¢¥Ï¥ó¥É¥ë°À­¥­¥ã¥Ã¥·¥å¤«¤é¤Î°À­ÃͤΡ֥¯¥¤¥Ã¥¯FETCH¡×¤ò̵¸ú¤Ë¤¹¤ë¸ú²Ì¤â¤¢¤ê¤Þ¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢¤¹¤Ù¤Æ¤Î°À­Ãͤϥɥ饤¥ÐÆȼ«¤ÎFETCH¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ½èÍý¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢¤½¤ì¤é¤Ï¾¯¤·ÃÙ¤¯¤Ê¤ê¤Þ¤¹¤¬¡¢DBD::Multiplex¤Î¤è¤¦¤ÊÆÃÊ̤ÊÌÜŪ¤Î¥É¥é¥¤¥Ð¤Ë¤ÏÍ­ÍѤǤ¹¡£ (TBR) =head3 C (boolean) =begin original The default value, false, means a handle will be fully destroyed as normal when the last reference to it is removed, just as you'd expect. =end original ¥Ç¥Õ¥©¥ë¥ÈÃͤǤ¢¤ëµ¶¤Ï¡¢Í½ÁÛ¤·¤Æ¤¤¤ëÄ̤ꡢ¥Ï¥ó¥É¥ë¤Ø¤ÎºÇ¸å¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤¬ ºï½ü¤µ¤ì¤ë¤ÈÄ̾ïÄ̤괰Á´¤ËÇ˲õ¤µ¤ì¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ =begin original If set true then the handle will be treated by the DESTROY as if it was no longer Active, and so the I related effects of DESTROYing a handle will be skipped. =end original true¤ËÀßÄꤹ¤ë¤È¡¢¥Ï¥ó¥É¥ë¤ÏDESTROY¤Ë¤è¤Ã¤Æ¥¢¥¯¥Æ¥£¥Ö¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¤â¤Î¤È¤·¤Æ½èÍý¤µ¤ì¤ë¤¿¤á¡¢¥Ï¥ó¥É¥ë¤òDESTROYing¤¹¤ëI´ØÏ¢¤Î¸ú²Ì¤Ï¥¹¥­¥Ã¥×¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Think of the name as meaning 'treat the handle as not-Active in the DESTROY method'. =end original ̾Á°¤Ï¡Ö¥Ï¥ó¥É¥ë¤ò¡¢DESTROY ¥á¥½¥Ã¥ÉÆâ¤Ç¤ÏÈó¥¢¥¯¥Æ¥£¥Ö¤È¤·¤Æ°·¤¦¡×¤È¤¤¤¦ °ÕÌ£¤Ç¤¹¡£ =begin original For a database handle, this attribute does not disable an I call to the disconnect method, only the implicit call from DESTROY that happens if the handle is still marked as C. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ë¤È¤Ã¤Æ¤Ï¡¢¤³¤Î°À­¤Ï disconnect ¥á¥½¥Ã¥É¤Î I<ÌÀ¼¨Åª¤Ê> ¸Æ¤Ó½Ð¤·¤ò̵¸ú¤Ë¤»¤º¡¢¥Ï¥ó¥É¥ë¤Ë C ¤È¥Þ¡¼¥¯¤µ¤ì¤Æ¤¤¤ë ¤È¤­¤Ë DESTROY ¤«¤é°ÅÌۤθƤӽФ·¤À¤±¤ò̵¸ú¤Ë¤·¤Þ¤¹¡£ =begin original This attribute is specifically designed for use in Unix applications that "fork" child processes. Either the parent or the child process, but not both, should set C true on all their shared handles. (Note that some databases, including Oracle, don't support passing a database connection across a fork.) =end original ¤³¤Î°À­¤Ï¡¢ÆÃ¤Ë»Ò¥×¥í¥»¥¹¤ò "fork" ¤¹¤ë UNIX ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Î »ÈÍѤˤĤ¤¤ÆÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ ¿Æ¤È»Ò¤ÎξÊý¤Ç¤Ï¤Ê¤¯¤É¤Á¤é¤«ÊÒÊý¤À¤±¤¬¡¢¶¦Í­¤·¤Æ¤¤¤ë¥Ï¥ó¥É¥ë¤Î¤¹¤Ù¤Æ¤Ë C ¤òÀßÄꤹ¤ë¤Ù¤­¤Ç¤¹¡£ (Oracle ¤ò´Þ¤á¤Æ¡¢¤¤¤¯¤Ä¤«¤Î¥É¥é¥¤¥Ð¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤ò fork ¤ò¤Þ¤¿¤¬¤Ã¤Æ ÅϤ¹¤³¤È¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£) =begin original To help tracing applications using fork the process id is shown in the trace log whenever a DBI or handle trace() method is called. The process id also shown for I method call if the DBI trace level (not handle trace level) is set high enough to show the trace from the DBI's method dispatcher, e.g. >= 9. =end original fork¤ò»ÈÍѤ·¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥È¥ì¡¼¥¹¤ò»Ù±ç¤¹¤ë¤¿¤á¤Ë¡¢DBI¤Þ¤¿¤Ïhandle trace()¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢¥×¥í¥»¥¹ID¤¬¥È¥ì¡¼¥¹¥í¥°¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£ DBI¥È¥ì¡¼¥¹¥ì¥Ù¥ë(¥Ï¥ó¥É¥ë¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤Ç¤Ï¤Ê¤¤)¤¬DBI¤Î¥á¥½¥Ã¥É¥Ç¥£¥¹¥Ñ¥Ã¥Á¥ã¤«¤é¤Î¥È¥ì¡¼¥¹¤òɽ¼¨¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¹â¤µ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç(>=9¤Ê¤É)¡¢I¥á¥½¥Ã¥É¥³¡¼¥ë¤ËÂФ·¤Æ¤â¥×¥í¥»¥¹ID¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£ (TBR) =head3 C (boolean, inherited) =begin original The C attribute controls the printing of warnings recorded by the driver. When set to a true value the DBI will check method calls to see if a warning condition has been set. If so, the DBI will effectively do a C where C<$class> is the driver class and C<$method> is the name of the method which failed. E.g., =end original C °À­¤Ï¡¢¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æµ­Ï¿¤µ¤ì¤¿·Ù¹ð¤Îɽ¼¨¤òÀ©¸æ¤·¤Þ¤¹¡£ ¿¿¤ÎÃͤËÀßÄꤵ¤ì¤ë¤È¡¢ ·Ù¹ð¾ò·ï¤¬ÀßÄꤵ¤ì¤¿¤«¤É¤¦¤«¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢DBI ¤Ï»ö¼Â¾å C ¤ò ¼Â¹Ô¤·¤Þ¤¹; ¤³¤³¤Ç C<$class> ¤Ï¥É¥é¥¤¥Ð¥¯¥é¥¹¤Ç C<$method> ¤Ï¼ºÇÔ¤·¤¿ ¥á¥½¥Ã¥É¤Î̾Á°¤Ç¤¹¡£ Î㤨¤Ð: DBD::Oracle::db execute warning: ... warning text here ... =begin original By default, Cconnect> sets C "on" if $^W is true, i.e., perl is running with warnings enabled. =end original $^W ¤¬¿¿¤Ê¤é C °À­¤Î¥Ç¥Õ¥©¥ë¥È¤Ï¥ª¥ó¤Ç¤¹; ¤Ä¤Þ¤ê¡¢perl ¤Ï ·Ù¹ð¤òÍ­¸ú¤Ë¤·¤ÆÆ°ºî¤·¤Þ¤¹¡£ =begin original If desired, the warnings can be caught and processed using a C<$SIG{__WARN__}> handler or modules like CGI::Carp and CGI::ErrorWrap. =end original ¤â¤·Ë¾¤à¤Ê¤é¡¢C<$SIG{__WARN__}> ¥Ï¥ó¥É¥é¤Þ¤¿¤Ï CGI::Carp ¤ä CGI::ErrorWrap ¤Î¤è¤¦¤Ê¥â¥¸¥å¡¼¥ë¤ò»È¤Ã¤Æ¡¢·Ù¹ð¤òÊ᪤·¤Æ½èÍý¤Ç¤­¤Þ¤¹¡£ =begin original See also L for how warnings are recorded and L for how to influence it. =end original ·Ù¹ð¤¬¤É¤Î¤è¤¦¤Ëµ­Ï¿¤µ¤ì¤ë¤«¤Ë¤Ä¤¤¤Æ¤Ï L ¤â¡¢¤½¤ì¤¬¤É¤Î¤è¤¦¤Ë ±Æ¶Á¤òÍ¿¤¨¤ë¤«¤Ë¤Ä¤¤¤Æ¤Ï L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Fetching the full details of warnings can require an extra round-trip to the database server for some drivers. In which case the driver may opt to only fetch the full details of warnings if the C attribute is true. If C is false then these drivers should still indicate the fact that there were warnings by setting the warning string to, for example: "3 warnings". =end original °ìÉô¤Î¥É¥é¥¤¥Ð¤Ç¤Ï¡¢·Ù¹ð¤Î´°Á´¤Ê¾ÜºÙ¤ò¥Õ¥§¥Ã¥Á¤¹¤ë¤¿¤á¤Ë¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¡¼¤Ø¤Î;ʬ¤Ê¥é¥¦¥ó¥É¥È¥ê¥Ã¥×¤¬É¬Íפˤʤë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢¥É¥é¥¤¥Ð¤Ï¡¢C°À­¤¬TRUE¤Î¾ì¹ç¤Ë¤Î¤ß¡¢·Ù¹ð¤Î´°Á´¤Ê¾ÜºÙ¤ò¥Õ¥§¥Ã¥Á¤¹¤ë¤³¤È¤òÁªÂò¤Ç¤­¤Þ¤¹¡£ C¤¬FALSE¤Î¾ì¹ç¤Ç¤â¡¢¤³¤ì¤é¤Î¥É¥é¥¤¥Ð¤Ï¡¢·Ù¹ðʸ»úÎó¤ò¡Ö3 warnings¡×¤Ê¤É¤ËÀßÄꤹ¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢·Ù¹ð¤¬¤¢¤Ã¤¿¤³¤È¤ò¼¨¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head3 C (boolean, inherited) =begin original The C attribute can be used to force errors to generate warnings (using C) in addition to returning error codes in the normal way. When set "on", any method which results in an error occurring will cause the DBI to effectively do a C where C<$class> is the driver class and C<$method> is the name of the method which failed. E.g., =end original C °À­¤Ï¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤é¡¢Ä̾ï¤ÎÊýË¡¤Ç¥¨¥é¡¼¥³¡¼¥É¤ò ÊÖ¤¹¤³¤È¤Ë²Ã¤¨¤Æ¡¢(C ¤ò»È¤Ã¤Æ)·Ù¹ð¤òÀ¸À®¤¹¤ë¤è¤¦¤Ë¶¯À©¤·¤Þ¤¹¡£ "on"¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤È¤­¡¢¤Ê¤ó¤é¤«¤Î¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤Ë¤Ê¤ë¤È¡¢DBI ¤Ë »ö¼Â¾å C ¤ò¼Â¹Ô¤µ¤»¤Þ¤¹; C<$class> ¤Ë¤Ï¥É¥é¥¤¥Ð¥¯¥é¥¹¡¢C<$method> ¤Ë¤Ï¼ºÇÔ¤·¤¿¥á¥½¥Ã¥É¤¬Æþ¤ê¤Þ¤¹¡£ Î㤨¤Ð DBD::Oracle::db prepare failed: ... error text here ... =begin original By default, Cconnect> sets C "on". =end original ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢Cconnect> ¤Ï C ¤ò "on" ¤ËÀßÄꤷ¤Þ¤¹¡£ =begin original If desired, the warnings can be caught and processed using a C<$SIG{__WARN__}> handler or modules like CGI::Carp and CGI::ErrorWrap. =end original ¤â¤·Ë¾¤à¤Ê¤é¡¢C<$SIG{__WARN__}> ¥Ï¥ó¥É¥é¤Þ¤¿¤Ï CGI::Carp ¤ä CGI::ErrorWrap ¤Î¤è¤¦¤Ê¥â¥¸¥å¡¼¥ë¤ò»È¤Ã¤Æ¡¢·Ù¹ð¤òÊ᪤·¤Æ½èÍý¤Ç¤­¤Þ¤¹¡£ =head3 C (boolean, inherited) =begin original The C attribute can be used to force errors to raise exceptions rather than simply return error codes in the normal way. It is "off" by default. When set "on", any method which results in an error will cause the DBI to effectively do a C, where C<$class> is the driver class and C<$method> is the name of the method that failed. E.g., =end original C °À­¤Ï¥¨¥é¡¼È¯À¸»þ¤ËÄ̾ïÄ̤êñ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹¤Î¤Ç¤Ï¤Ê¤¯¡¢ Îã³°¤òȯÀ¸¤µ¤»¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ï"off"¤Ç¤¹¡£ "on" ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤È¤­¡¢¤Ê¤ó¤é¤«¤Î¥á¥½¥Ã¥É¤Ç¥¨¥é¡¼¤Ë¤Ê¤ë¤È¡¢DBI ¤Ë »ö¼Â¾å C ¤ò¼Â¹Ô¤µ¤»¤Þ¤¹; C<$class> ¤Ë¤Ï¥É¥é¥¤¥Ð¥¯¥é¥¹¡¢C<$method> ¤Ë¤Ï¼ºÇÔ¤·¤¿¥á¥½¥Ã¥É¤¬Æþ¤ê¤Þ¤¹¡£ Î㤨¤Ð DBD::Oracle::db prepare failed: ... error text here ... =begin original If you turn C on then you'd normally turn C off. If C is also on, then the C is done first (naturally). =end original C ¤ò¥ª¥ó¤Ë¤¹¤ë¤È¡¢ÉáÄÌ C ¤Ï¥ª¥Õ¤Ë¤·¤Þ¤¹¡£ C ¤â¥ª¥ó¤Ë¤¹¤ë¤È¡¢(¼«Á³¤Ê¤è¤¦¤Ë) C ¤¬¤Þ¤º ¼Â¹Ô¤µ¤ì¤Þ¤¹¡£ =begin original Typically C is used in conjunction with C to catch the exception that's been thrown and followed by an C block to handle the caught exception. For example: =end original Ä̾C¤Ï¡¢¥¹¥í¡¼¤µ¤ì¤¿Îã³°¤ò¥­¥ã¥Ã¥Á¤¹¤ë¤¿¤á¤ËC¤È¤È¤â¤Ë»ÈÍѤµ¤ì¡¢¤½¤Î¸å¤Ë¡¢¥­¥ã¥Ã¥Á¤µ¤ì¤¿Îã³°¤ò½èÍý¤¹¤ë¤¿¤á¤ÎC¥Ö¥í¥Ã¥¯¤¬Â³¤­¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) eval { ... $sth->execute(); ... }; if ($@) { # $sth->err and $DBI::err will be true if error was from DBI warn $@; # print the error ... # do whatever you need to deal with the error } =begin original In that eval block the $DBI::lasth variable can be useful for diagnosis and reporting if you can't be sure which handle triggered the error. For example, $DBI::lasth->{Type} and $DBI::lasth->{Statement}. =end original ¤³¤Îeval¥Ö¥í¥Ã¥¯¤Ç¤Ï¡¢$DBI::lasthÊÑ¿ô¤ò»ÈÍѤ¹¤ë¤È¡¢¥¨¥é¡¼¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥Ï¥ó¥É¥ë¤òÆÃÄê¤Ç¤­¤Ê¤¤¾ì¹ç¤Ë¡¢¿ÇÃǤä¥ì¥Ý¡¼¥ÈºîÀ®¤ËÌòΩ¤Á¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢$DBI::lasth->{Type}¤ä$DBI::lasth->{Statement}¤Ê¤É¤Ç¤¹¡£ (TBR) =begin original See also L. =end original L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original If you want to temporarily turn C off (inside a library function that is likely to fail, for example), the recommended way is like this: =end original °ì»þŪ¤Ë C ¤ò¥ª¥Õ¤ËÀÚ¤êÂؤ¨¤¿¤¤¤Î¤Ç¤¢¤ì¤Ð(Î㤨¤Ð¾ã³²¤¬ ȯÀ¸¤·¤ä¤¹¤¤¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ÎÆâÉô¤Ê¤É)¡¢°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤ò¤ª´«¤á¤·¤Þ¤¹: { local $h->{RaiseError}; # localize and turn off for this block ... } =begin original The original value will automatically and reliably be restored by Perl, regardless of how the block is exited. The same logic applies to other attributes, including C. =end original ¤½¤Î¥Ö¥í¥Ã¥¯¤«¤é¤É¤Î¤è¤¦¤ËÈ´¤±¤¿¤Î¤«¤Ï´Ø·¸¤Ê¤¯¡¢¸µ¤ÎÃͤϼ«Æ°Åª¤Ë¡¢¿®ÍêÀ­¤ò »ý¤Ã¤Æ Perl ¤Ë¤è¤êÊݸ¤µ¤ì¤Þ¤¹¡£ C ¤â´Þ¤á¤Æ¡¢Â¾¤Î°À­¤Ë¤Ä¤¤¤Æ¤âƱ¤¸¥í¥¸¥Ã¥¯¤¬Å¬ÍѤµ¤ì¤Þ¤¹¡£ =head3 C (code ref, inherited) =begin original The C attribute can be used to provide your own alternative behaviour in case of errors. If set to a reference to a subroutine then that subroutine is called when an error is detected (at the same point that C and C are handled). =end original C °À­¤Ï¡¢¥¨¥é¡¼»þ¤ËÊ̤ÎÆȼ«¤Î¿¶¤ëÉñ¤¤¤òÄ󶡤¹¤ë¤¿¤á¤Ë »È¤ï¤ì¤Þ¤¹¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÀßÄꤹ¤ë¤È¡¢ ¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤¿¤È¤­¤Ë (C ¤È C ¤¬ °·¤ï¤ì¤ë¤Î¤ÈƱ¤¸»þÅÀ¤Ç) ¤½¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ =begin original The subroutine is called with three parameters: the error message string that C and C would use, the DBI handle being used, and the first value being returned by the method that failed (typically undef). =end original ¤³¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢C¤ª¤è¤ÓC¤Ç»ÈÍѤµ¤ì¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸Ê¸»úÎó¡¢»ÈÍѤµ¤ì¤ëDBI¥Ï¥ó¥É¥ë¡¢¤ª¤è¤Ó¼ºÇÔ¤·¤¿¥á¥½¥Ã¥É¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ëºÇ½é¤ÎÃÍ(Ä̾ï¤Ïundef)¤Î3¤Ä¤Î¥Ñ¥é¥á¡¼¥¿¤ò»ØÄꤷ¤Æ¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If the subroutine returns a false value then the C and/or C attributes are checked and acted upon as normal. =end original ¥µ¥Ö¥ë¡¼¥Á¥ó¤¬µ¶¤ÎÃͤòÊÖ¤¹¤È¡¢C °À­¤ä C °À­¤¬ ¥Á¥§¥Ã¥¯¤µ¤ì¡¢Ä̾ïÄ̤êÆ°ºî¤·¤Þ¤¹¡£ =begin original For example, to C with a full stack trace for any error: =end original Î㤨¤Ð¡¢Á´¤Æ¤Î¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ´°Á´¤Ê¥¹¥¿¥Ã¥¯¥È¥ì¡¼¥¹¤È¶¦¤Ë C ¤µ¤»¤ë¤Ë¤Ï: use Carp; $h->{HandleError} = sub { confess(shift) }; =begin original Or to turn errors into exceptions: =end original ¤Þ¤¿¤Ï¥¨¥é¡¼¤òÎã³°¤ËÊÑ´¹¤¹¤ë¤Ë¤Ï: use Exception; # or your own favourite exception module $h->{HandleError} = sub { Exception->new('DBI')->raise($_[0]) }; =begin original It is possible to 'stack' multiple HandleError handlers by using closures: =end original ¥¯¥í¡¼¥¸¥ã¤ò»È¤¦¤³¤È¤ÇÊ£¿ô¤Î HandleError ¥Ï¥ó¥É¥é¤ò¡Ö¥¹¥¿¥Ã¥¯¡×¤µ¤»¤ë¤³¤È¤¬ ¤Ç¤­¤Þ¤¹: sub your_subroutine { my $previous_handler = $h->{HandleError}; $h->{HandleError} = sub { return 1 if $previous_handler and &$previous_handler(@_); ... your code here ... }; } =begin original Using a C inside a subroutine to store the previous C value is important. See L and L for more information about I. =end original ¥µ¥Ö¥ë¡¼¥Á¥óÆâ¤ÇC¤ò»ÈÍѤ·¤Æ¡¢Á°¤ÎCÃͤò³ÊǼ¤¹¤ë¤³¤È¤Ï½ÅÍפǤ¹¡£ I<¥¯¥í¡¼¥¸¥ã¡¼>¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ª¤è¤ÓL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original It is possible for C to alter the error message that will be used by C and C if it returns false. It can do that by altering the value of $_[0]. This example appends a stack trace to all errors and, unlike the previous example using Carp::confess, this will work C as well as C: =end original C¤¬false¤òÊÖ¤¹¾ì¹ç¤Ï¡¢C¤ª¤è¤ÓC¤Ç»ÈÍѤµ¤ì¤ë¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òC¤ÇÊѹ¹¤Ç¤­¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢$_[0]¤ÎÃͤòÊѹ¹¤¹¤ë¤³¤È¤Ç²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤ÎÎã¤Ç¤Ï¡¢¤¹¤Ù¤Æ¤Î¥¨¥é¡¼¤Ë¥¹¥¿¥Ã¥¯¥È¥ì¡¼¥¹¤òÄɲä·¤Þ¤¹¡£ Carp::anal¤ò»ÈÍѤ·¤¿Á°½Ò¤ÎÎã¤È¤Ï°Û¤Ê¤ê¡¢¤³¤ì¤ÏC¤ª¤è¤ÓC¤Ç¤âµ¡Ç½¤·¤Þ¤¹: (TBR) $h->{HandleError} = sub { $_[0]=Carp::longmess($_[0]); 0; }; =begin original It is also possible for C to hide an error, to a limited degree, by using L to reset $DBI::err and $DBI::errstr, and altering the return value of the failed method. For example: =end original C¤Ç¤Ï¡¢L¤ò»ÈÍѤ·¤Æ$DBI::err¤ª¤è¤Ó$DBI::errstr¤ò¥ê¥»¥Ã¥È¤·¡¢¼ºÇÔ¤·¤¿¥á¥½¥Ã¥É¤ÎÌá¤êÃͤòÊѹ¹¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢¸Â¤é¤ì¤¿ÄøÅ٤ǥ¨¥é¡¼¤òÈóɽ¼¨¤Ë¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $h->{HandleError} = sub { return 0 unless $_[0] =~ /^\S+ fetchrow_arrayref failed:/; return 0 unless $_[1]->err == 1234; # the error to 'hide' $h->set_err(undef,undef); # turn off the error $_[2] = [ ... ]; # supply alternative return value return 1; }; =begin original This only works for methods which return a single value and is hard to make reliable (avoiding infinite loops, for example) and so isn't recommended for general use! If you find a I use for it then please let me know. =end original ¤³¤ì¤Ï¡¢Ã±°ì¤ÎÃͤòÊÖ¤¹¥á¥½¥Ã¥É¤ËÂФ·¤Æ¤Î¤ßÆ°ºî¤·¡¢¿®ÍêÀ­¤ò³ÎÊݤ¹¤ë¤Î¤¬Æñ¤·¤¤(Î㤨¤Ð¡¢Ìµ¸Â¥ë¡¼¥×¤ò²óÈò¤¹¤ë)¤¿¤á¡¢°ìÈÌŪ¤Ê»ÈÍѤˤϿ侩¤µ¤ì¤Þ¤»¤ó!¤â¤·¡¢I¤Î»È¤¤Êý¤ò¸«¤Ä¤±¤¿¤é¡¢¶µ¤¨¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head3 C (code ref, inherited) =begin original The C attribute can be used to intercept the setting of handle C, C, and C values. If set to a reference to a subroutine then that subroutine is called whenever set_err() is called, typically by the driver or a subclass. =end original C °À­¤Ï¡¢C, C, C ¤ÎÃͤò°·¤¦ÀßÄê¤Ë ³ä¤ê¹þ¤à¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÀßÄꤹ¤ë¤È¡¢ (ŵ·¿Åª¤Ë¤Ï¥É¥é¥¤¥Ð¤ä¥µ¥Ö¥¯¥é¥¹¤«¤é) set_err() ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤­¤Ë¤³¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ =begin original The subroutine is called with five arguments, the first five that were passed to set_err(): the handle, the C, C, and C values being set, and the method name. These can be altered by changing the values in the @_ array. The return value affects set_err() behaviour, see L for details. =end original ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢set_err()¤ËÅϤµ¤ì¤¿ºÇ½é¤Î5¤Ä¤Î°ú¿ô(¥Ï¥ó¥É¥ë¡¢ÀßÄꤵ¤ì¤¿C¡¢C¡¢¤ª¤è¤ÓCÃÍ¡¢¤ª¤è¤Ó¥á¥½¥Ã¥É̾)¤ò»ÈÍѤ·¤Æ¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤é¤Ï@_array¤ÎÃͤòÊѹ¹¤¹¤ë¤³¤È¤ÇÊѹ¹¤Ç¤­¤Þ¤¹¡£ Ìá¤êÃͤÏset_err()¤ÎÆ°ºî¤Ë±Æ¶Á¤·¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤ÏL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original It is possible to 'stack' multiple HandleSetErr handlers by using closures. See L for an example. =end original ¥¯¥í¡¼¥¸¥ã¤ò»È¤¦¤³¤È¤ÇÊ£¿ô¤Î HandleSetErr ¥Ï¥ó¥É¥é¤ò ¡Ö¥¹¥¿¥Ã¥¯¡×¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹: Îã¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C and C subroutines differ in subtle but significant ways. HandleError is only invoked at the point where the DBI is about to return to the application with C set true. It's not invoked by the failure of a method that's been called by another DBI method. HandleSetErr, on the other hand, is called whenever set_err() is called with a defined C value, even if false. So it's not just for errors, despite the name, but also warn and info states. The set_err() method, and thus HandleSetErr, may be called multiple times within a method and is usually invoked from deep within driver code. =end original C¤ÈC¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢Èù̯¤Ç¤¹¤¬½ÅÍפÊÅÀ¤Ç°Û¤Ê¤ê¤Þ¤¹¡£ HandleError¤Ï¡¢C¤¬true¤ËÀßÄꤵ¤ì¤¿¾õÂÖ¤ÇDBI¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÌá¤í¤¦¤È¤¹¤ë»þÅÀ¤Ç¤Î¤ß¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ Ê̤ÎDBI¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ¸Æ¤Ó½Ð¤µ¤ì¤¿¥á¥½¥Ã¥É¤Î¼ºÇԤˤè¤Ã¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£ °ìÊý¡¢HandleSetErr¤Ï¡¢ÄêµÁ¤µ¤ì¤¿CÃͤÇset_err()¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢false¤Ç¤¢¤Ã¤Æ¤â¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢Ì¾Á°¤Ë¤«¤«¤ï¤é¤º¥¨¥é¡¼¤ËÂФ·¤Æ¤À¤±¤Ç¤Ê¤¯¡¢·Ù¹ð¾õÂÖ¤ä¾ðÊó¾õÂÖ¤ËÂФ·¤Æ¤â¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ set_err()¥á¥½¥Ã¥É¡¢¤·¤¿¤¬¤Ã¤ÆHandleSetErr¤Ï¡¢¥á¥½¥Ã¥ÉÆâ¤ÇÊ£¿ô²ó¸Æ¤Ó½Ð¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢Ä̾ï¤Ï¥É¥é¥¤¥Ð¥³¡¼¥É¤Î±ü¿¼¤¯¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original In theory a driver can use the return value from HandleSetErr via set_err() to decide whether to continue or not. If set_err() returns an empty list, indicating that the HandleSetErr code has 'handled' the 'error', the driver could then continue instead of failing (if that's a reasonable thing to do). This isn't excepted to be common and any such cases should be clearly marked in the driver documentation and discussed on the dbi-dev mailing list. =end original ÍýÏÀŪ¤Ë¤Ï¡¢¥É¥é¥¤¥Ð¤Ïset_err()¤ò²ð¤·¤ÆHandleSetErr¤«¤é¤ÎÌá¤êÃͤò»ÈÍѤ·¤Æ¡¢Â³¹Ô¤¹¤ë¤«¤É¤¦¤«¤ò·èÄê¤Ç¤­¤Þ¤¹¡£ set_err()¤¬¶õ¤Î¥ê¥¹¥È¤òÊÖ¤·¡¢HandleSetErr¥³¡¼¥É¤¬¡Ö¥¨¥é¡¼¡×¤ò¡Ö½èÍý¤·¤¿¡×¤³¤È¤ò¼¨¤·¤¿¾ì¹ç¡¢¥É¥é¥¤¥Ð¤Ï¼ºÇÔ¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯Â³¹Ô¤Ç¤­¤Þ¤¹(¤½¤ì¤¬¹çÍýŪ¤Ê¤³¤È¤Ç¤¢¤ë¾ì¹ç)¡£ ¤³¤ì¤Ï°ìÈÌŪ¤Ç¤¢¤ë¤³¤È¤ò½ü³°¤¹¤ë¤â¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ï¥É¥é¥¤¥Ð¤Îʸ½ñ¤ÇÌÀ³Î¤Ë¥Þ¡¼¥¯¤µ¤ì¡¢dbi-dev¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤ÇµÄÏÀ¤µ¤ì¤ë¤Ù¤­¤Ç¤¹¡£ (TBR) =begin original The C attribute was added in DBI 1.41. =end original C °À­¤Ï DBI 1.41 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (unsigned integer) =begin original The C attribute is incremented whenever the set_err() method records an error. It isn't incremented by warnings or information states. It is not reset by the DBI at any time. =end original C °À­¤Ï¡¢set_err() ¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤òµ­Ï¿¤¹¤ëËè¤Ë ¥¤¥ó¥¯¥ê¥á¥ó¥È¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï·Ù¹ð¤ä¾ðÊóɽ¼¨¤Ç¤Ï¥¤¥ó¥¯¥ê¥á¥ó¥È¤µ¤ì¤Þ¤»¤ó¡£ ¤³¤ì¤Ï DBI ¤Ë¤è¤Ã¤Æ¥ê¥»¥Ã¥È¤µ¤ì¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original The C attribute was added in DBI 1.41. Older drivers may not have been updated to use set_err() to record errors and so this attribute may not be incremented when using them. =end original C °À­¤Ï DBI 1.41 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ ¤è¤ê¸Å¤¤¥É¥é¥¤¥Ð¤Ï¥¨¥é¡¼¤òµ­Ï¿¤¹¤ë¤¿¤á¤Ë set_err() ¤ò»È¤¦¤È¤­¤Ë ¹¹¿·¤µ¤ì¤Ê¤¤¤Î¤Ç¡¢¤³¤Î°À­¤Ï¤³¤ì¤é¤ò»È¤Ã¤¿¤È¤­¤Ë ¥¤¥ó¥¯¥ê¥á¥ó¥È¤µ¤ì¤Ê¤¤¤«¤âÃΤì¤Þ¤»¤ó¡£ =head3 C (boolean, inherited) =begin original The C attribute can be used to cause the relevant Statement text to be appended to the error messages generated by the C, C, and C attributes. Only applies to errors on statement handles plus the prepare(), do(), and the various C database handle methods. (The exact format of the appended text is subject to change.) =end original C °À­¤Ï¡¢ C, C, C °À­¤Ë¤è¤Ã¤Æ À¸À®¤µ¤ì¤¿¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ËÄɲ䵤ì¤ë¡¢´ØÏ¢¤¹¤ë Statement ¤Î¥Æ¥­¥¹¥È¤ò Äɲ乤뤿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ʸ¥Ï¥ó¥É¥ë¤Î¥¨¥é¡¼¤Ë²Ã¤¨¤Æ¡¢prepare(), do() ¤ª¤è¤ÓÍÍ¡¹¤Ê C ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¥á¥½¥Ã¥É¤Î¥¨¥é¡¼¤Ë¤Î¤ßŬÍѤµ¤ì¤Þ¤¹¡£ (Äɲ䵤ì¤ë¥Æ¥­¥¹¥È¤ÎÀµ³Î¤Ê·Á¼°¤ÏÊѹ¹¤µ¤ì¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£) =begin original If C<$h-E{ParamValues}> returns a hash reference of parameter (placeholder) values then those are formatted and appended to the end of the Statement text in the error message. =end original C<$h-E{ParamValues}> ¤¬¥Ñ¥é¥á¡¼¥¿(¥×¥ì¡¼¥¹¥Û¥ë¥À)¤ÎÃͤΠ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤¹¾ì¹ç¡¢¤³¤ì¤é¤Ï¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤Æ ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Î Statement ¤Î¥Æ¥­¥¹¥È¤ÎËöÈø¤ËÄɲ䵤ì¤Þ¤¹¡£ =head3 C (integer, inherited) =begin original The C attribute can be used as an alternative to the L method to set the DBI trace level and trace flags for a specific handle. See L for more details. =end original C °À­¤Ï¡¢DBI ¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤ÈÆÃÄê¤Î¥Ï¥ó¥É¥ë¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤ò ÀßÄꤹ¤ë¤¿¤á¤Î L ¥á¥½¥Ã¥É¤ÎÂå¤ï¤ê¤È¤·¤Æ»È¤¨¤Þ¤¹¡£ ¤µ¤é¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C attribute is especially useful combined with C to alter the trace settings for just a single block of code. =end original C °À­¤Ï¡¢ÆÃÄê¤Î°ì¤Ä¤Î¥Ö¥í¥Ã¥¯¤Î¥³¡¼¥É¤Ç¤À¤±¥È¥ì¡¼¥¹ÀßÄê¤ò Êѹ¹¤¹¤ë¤¿¤á¤Ë C ¤òÁȤ߹ç¤ï¤»¤ë¤ÈÆäËÊØÍø¤Ç¤¹¡£ =head3 C (string, inherited) =begin original The C attribute is used to specify whether the fetchrow_hashref() method should perform case conversion on the field names used for the hash keys. For historical reasons it defaults to 'C' but it is recommended to set it to 'C' (convert to lower case) or 'C' (convert to upper case) according to your preference. It can only be set for driver and database handles. For statement handles the value is frozen when prepare() is called. =end original C°À­¤Ï¡¢fetchrow_uc()¥á¥½¥Ã¥É¤¬¥Ï¥Ã¥·¥å¥­¡¼¤Ë»ÈÍѤµ¤ì¤ë¥Õ¥£¡¼¥ë¥É̾¤ËÂФ·¤ÆÂçʸ»ú¤È¾®Ê¸»ú¤ÎÊÑ´¹¤ò¼Â¹Ô¤¹¤ë¤«¤É¤¦¤«¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ Îò»ËŪ¤ÊÍýͳ¤Ë¤è¤ê¡¢¥Ç¥Õ¥©¥ë¥È¤Ï'C'¤Ç¤¹¤¬¡¢¹¥¤ß¤Ë±þ¤¸¤Æ'C'(¾®Ê¸»ú¤ËÊÑ´¹)¤Þ¤¿¤Ï'C'(Âçʸ»ú¤ËÊÑ´¹)¤ËÀßÄꤹ¤ë¤³¤È¤ò¤ªÁ¦¤á¤·¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢¥É¥é¥¤¥Ð¤ª¤è¤Ó¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¤Î¤ßÀßÄê¤Ç¤­¤Þ¤¹¡£ ¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢prepare()¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤ÈÃͤ¬Åà·ë¤µ¤ì¤Þ¤¹¡£ hashref (TBR) =head3 C (boolean, inherited) =begin original The C attribute can be used to control the trimming of trailing space characters from fixed width character (CHAR) fields. No other field types are affected, even where field values have trailing spaces. =end original C °À­¤Ï¸ÇÄêĹʸ»úÎó(CHAR)¥Õ¥£¡¼¥ë¥É¤«¤éËöÈø¤Î¶õÇò¤ò ¼è¤ê½ü¤¯¤³¤È¤òÀ©¸æ¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¾¤Î¥Õ¥£¡¼¥ë¥É¥¿¥¤¥×¤Ë¤Ï¡¢Î㤨ËöÈø¤Ë¶õÇò¤¬¤Ä¤¤¤Æ¤¤¤Æ¤â¡¢±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó¡£ =begin original The default is false (although it is possible that the default may change). Applications that need specific behaviour should set the attribute as needed. =end original ¥Ç¥Õ¥©¥ë¥È¤Ïµ¶¤Ç¤¹¡£ (¤·¤«¤·¥Ç¥Õ¥©¥ë¥È¤¬Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹)¡£ ÆÃÄê¤ÎÆ°¤­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¤³¤Î°À­¤òɬÍפÊÃͤËÀßÄꤷ¤Þ¤¹¡£ =begin original Drivers are not required to support this attribute, but any driver which does not support it must arrange to return C as the attribute value. =end original ¥É¥é¥¤¥Ð¤Ï¤³¤Î°À­¤ò¥µ¥Ý¡¼¥È¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ ¤·¤«¤·¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥É¥é¥¤¥Ð¤Ï¤³¤Î°À­¤ÎÃͤȤ·¤Æ C ¤ò ÊÖ¤¹¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =head3 C (unsigned integer, inherited) =begin original The C attribute may be used to control the maximum length of 'long' type fields (LONG, BLOB, CLOB, MEMO, etc.) which the driver will read from the database automatically when it fetches each row of data. =end original C °À­¤Ï¡¢¥Ç¡¼¥¿¹Ô¤ò¼è¤ê½Ð¤¹ºÝ¤Ë¡¢¥É¥é¥¤¥Ð¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é ¼«Æ°Åª¤ËÆɤߤ³¤à¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É(LONG, BLOB, CLOB, MEMO ¤Ê¤É)¤Î ºÇÂçŤòÀ©¸æ¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ =begin original The C attribute only relates to fetching and reading long values; it is not involved in inserting or updating them. =end original C °À­¤Ï¡ÖŤ¤¡×Ãͤμè¤ê½Ð¤·¤ÈÆɤߤ³¤ß¤Ë¤À¤±´ØÏ¢¤·¤Þ¤¹; ÁÞÆþ¤ä¹¹¿·¤Î¤È¤­¤Ë¤Ï´Ø·¸¤·¤Þ¤»¤ó¡£ =begin original A value of 0 means not to automatically fetch any long data. Drivers may return undef or an empty string for long fields when C is 0. =end original Ãͤ¬ 0 ¤Ï¡¢¡ÖŤ¤¡×¥Ç¡¼¥¿¤Ï¼«Æ°Åª¤Ë¼è¤ê½Ð¤µ¤ì¤Ê¤¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ C ¤¬ 0 ¤Î¤È¤­¡¢¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤ÎÃÍ¤Ï undef ¤Þ¤¿¤Ï ¶õʸ»úÎó¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original The default is typically 0 (zero) or 80 bytes but may vary between drivers. Applications fetching long fields should set this value to slightly larger than the longest long field value to be fetched. =end original ¥Ç¥Õ¥©¥ë¥È¤ÏÄ̾ï 0 ¤Þ¤¿¤Ï 80 ¥Ð¥¤¥È¤Ç¤¹¤¬¡¢¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ°ã¤¦¤«¤â¤·¤ì¤Þ¤»¤ó¡£ ¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤ò¼è¤ê½Ð¤¹¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¼è¤ê½Ð¤µ¤ì¤ë ¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤ÎºÇÂçŤè¤ê¤â¤Á¤ç¤Ã¤È¤À¤±Â礭¤¤Ãͤò¡¢ ¤³¤ÎÃͤËÀßÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original Some databases return some long types encoded as pairs of hex digits. For these types, C relates to the underlying data length and not the doubled-up length of the encoded string. =end original ¤¢¤ë¼ï¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¡ÖŤ¤¡×¥¿¥¤¥×¤ò 16 ¿Ê¤Î¥Ú¥¢¤Ç¥¨¥ó¥³¡¼¥É¤·¤ÆÊÖ¤¹ ¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤é¤Î¥¿¥¤¥×¤Ë¤Ä¤¤¤Æ¤Ï¡¢C ¤Ï¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿Ê¸»úÎó¤Î 2 Çܤˤʤä¿Ä¹¤µ¤Ç¤Ï¤Ê¤¯¡¢´ð¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿Ä¹¤Ë´Ø·¸¤·¤Þ¤¹¡£ =begin original Changing the value of C for a statement handle after it has been C'd will typically have no effect, so it's common to set C on the C<$dbh> before calling C. =end original ´û¤Ë C ¤µ¤ì¤¿¸å¤Ë¡¢Ê¸¥Ï¥ó¥É¥ë¤Î C ¤ò Êѹ¹¤·¤Æ¤â¡¢Ä̾²¿¤â±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó; ¤½¤Î¤¿¤áÉáÄÌ¡¢C ¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë¡¢C<$dbh> ¤ËÂФ·¤Æ C ¤ò ÀßÄꤷ¤Þ¤¹¡£ =begin original For most drivers the value used here has a direct effect on the memory used by the statement handle while it's active, so don't be too generous. If you can't be sure what value to use you could execute an extra select statement to determine the longest value. For example: =end original ¤Û¤È¤ó¤É¤Î¥É¥é¥¤¥Ð¤Ç¤Ï¤³¤³¤Ë»È¤ï¤ì¤ëÃͤ¬Í­¸ú¤Êʸ¥Ï¥ó¥É¥ë¤Ë¤è¤Ã¤Æ »È¤ï¤ì¤ë¥á¥â¥ê¤ËÂФ·¤ÆľÀÜŪ¤Ê±Æ¶Á¤òÍ¿¤¨¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤½¤Î¤¿¤á¡¢¤¢¤Þ¤êµ¤Á°¤è¤¯¤Ê¤é¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤ÎÃͤλȤ¤Êý¤¬¤Ï¤Ã¤­¤ê¤È¤ï¤«¤é¤Ê¤¤¤Ê¤é¡¢°ìÈÖŤ¤Ãͤò·èÄꤹ¤ë¤¿¤á¤Ë ÄɲäΠselect ʸ¤ò¼Â¹Ô¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð: $dbh->{LongReadLen} = $dbh->selectrow_array(qq{ SELECT MAX(OCTET_LENGTH(long_column_name)) FROM table WHERE ... }); $sth = $dbh->prepare(qq{ SELECT long_column_name, ... FROM table WHERE ... }); =begin original You may need to take extra care if the table can be modified between the first select and the second being executed. You may also need to use a different function if OCTET_LENGTH() does not work for long types in your database. For example, for Sybase use DATALENGTH() and for Oracle use LENGTHB(). =end original ºÇ½é¤ÎÁªÂò¤«¤é2ÈÖÌܤÎÁªÂò¤¬¼Â¹Ô¤µ¤ì¤ë¤Þ¤Ç¤Î´Ö¤Ëɽ¤¬Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¾ì¹ç¤Ï¡¢ÆäËÃí°Õ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤Þ¤¿¡¢OCTET_LENGTH()¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹¤Îlong·¿¤ËÂФ·¤Æµ¡Ç½¤·¤Ê¤¤¾ì¹ç¤Ï¡¢Ê̤δؿô¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢Sybase¤Î¾ì¹ç¤ÏDATALENGTH()¤ò»ÈÍѤ·¡¢Oracle¤Î¾ì¹ç¤ÏLENGTHB()¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) =begin original See also L for information on truncation of long types. =end original Ť¤·¿¤ÎÀÚ¤êµÍ¤á¤Ë´Ø¤¹¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C (boolean, inherited) =begin original The C attribute may be used to control the effect of fetching a long field value which has been truncated (typically because it's longer than the value of the C attribute). =end original C °À­¤Ï¡¢(Ä̾ï¤Ï C °À­¤è¤ê¤âŤ¤¤¿¤á¤Ë) ÀÚ¤ê¼Î¤Æ¤é¤ì¤ë¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤Î¼è¤ê½Ð¤·¤Î±Æ¶Á¤òÀ©¸æ¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ =begin original By default, C is false and so fetching a long value that needs to be truncated will cause the fetch to fail. (Applications should always be sure to check for errors after a fetch loop in case an error, such as a divide by zero or long field truncation, caused the fetch to terminate prematurely.) =end original ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï C ¤Ïµ¶¤Ç¤¹; ¤½¤Î¤¿¤áÀÚ¤ê¼Î¤Æ¤é¤ì¤ëɬÍפ¬¤¢¤ë ¡ÖŤ¤¡×Ãͤò¼è¤ê½Ð¤¹¤È¼è¤ê½Ð¤·¼ºÇԤȤʤê¤Þ¤¹¡£ (¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¥¨¥é¡¼¤Î¾ì¹ç¡¢¼è¤ê½Ð¤·¥ë¡¼¥×¤Î¸å¤Ç¡¢¥¨¥é¡¼¤ò¾ï¤Ë³Î¼Â¤Ë ¥Á¥§¥Ã¥¯¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ 0 ½ü»»¡¢¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤ÎÀÚ¤ê¼Î¤Æ¤Ê¤É¤Ë¤è¤Ã¤Æ¼è¤ê½Ð¤·¤¬Á᤯ ½ª¤ï¤Ã¤Æ¤·¤Þ¤¦¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£) =begin original If a fetch fails due to a long field truncation when C is false, many drivers will allow you to continue fetching further rows. =end original C ¤¬µ¶¤Î¤È¤­¡¢¡ÖŤ¤¡×¥Õ¥£¡¼¥ë¥É¤Ë¤è¤ê¼è¤ê½Ð¤·¤¬¼ºÇÔ¤·¤Æ¤â¡¢ ¿¤¯¤Î¥É¥é¥¤¥Ð¤Ç¤ÏÀè¤Î¹Ô¤ò¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original See also L. =end original L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C (boolean, inherited) =begin original If the C attribute is set to a true value I Perl is running in taint mode (e.g., started with the C<-T> option), then all the arguments to most DBI method calls are checked for being tainted. I =end original C°À­¤¬¿¿¤ÎÃÍI<¤ËÀßÄꤵ¤ì¡¢Perl¤¬±øÀ÷¥â¡¼¥É¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¾ì¹ç(¤¿¤È¤¨¤Ð¡¢C<-T>¥ª¥×¥·¥ç¥ó¤Ç³«»Ï¤µ¤ì¤¿¾ì¹ç)¡¢¤Û¤È¤ó¤É¤ÎDBI¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤Î¤¹¤Ù¤Æ¤Î°ú¿ô¤¬±øÀ÷¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤¬¥Á¥§¥Ã¥¯¤µ¤ì¤Þ¤¹¡£ I<¤³¤ì¤ÏÊѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ > (TBR) =begin original The attribute defaults to off, even if Perl is in taint mode. See L for more about taint mode. If Perl is not running in taint mode, this attribute has no effect. =end original Perl ¤¬±øÀ÷¥â¡¼¥É¤Ç¤¢¤Ã¤Æ¤â¡¢¤³¤Î°À­¤Î¥Ç¥Õ¥©¥ë¥È¤Ï¥ª¥Õ¤Ç¤¹¡£ ±øÀ÷¥â¡¼¥É¤Ë¤Ä¤¤¤Æ¤Î¤µ¤é¤Ê¤ë¾ðÊó¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ Perl ¤¬±øÀ÷¥â¡¼¥É¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤³¤ì¤Ï²¿¤â¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡£ =begin original When fetching data that you trust you can turn off the TaintIn attribute, for that statement handle, for the duration of the fetch loop. =end original ¿®Íê¤Ç¤­¤ë¥Ç¡¼¥¿¤ò¥Õ¥§¥Ã¥Á¤¹¤ë¤È¤­¤Ë¤Ï¡¢¤½¤Î¥Õ¥§¥Ã¥Á¥ë¡¼¥×¤Î´Ö¡¢ ¤½¤Îʸ¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¡¢TaintIn °À­¤ò¥ª¥Õ¤Ë¤Ç¤­¤Þ¤¹¡£ =begin original The C attribute was added in DBI 1.31. =end original C °À­¤Ï DBI 1.31 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (boolean, inherited) =begin original If the C attribute is set to a true value I Perl is running in taint mode (e.g., started with the C<-T> option), then most data fetched from the database is considered tainted. I =end original C °À­¤Ë¿¿¤ÎÃͤ¬ÀßÄꤵ¤ì¡¢I<¤«¤Ä> Perl ¤¬±øÀ÷(taint)¥â¡¼¥É (Î㤨¤Ð C<-T> ¥ª¥×¥·¥ç¥ó¤Ç³«»Ï¤µ¤ì¤Æ)¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é ¼è¤ê½Ð¤µ¤ì¤ë¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤Ï±øÀ÷¤µ¤ì¤Æ¤¤¤ë¤È¥Á¥§¥Ã¥¯¤µ¤ì¤Þ¤¹¡£ I<¤³¤ì¤ÏÊѹ¹¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£> =begin original The attribute defaults to off, even if Perl is in taint mode. See L for more about taint mode. If Perl is not running in taint mode, this attribute has no effect. =end original Perl ¤¬±øÀ÷¥â¡¼¥É¤Ç¤¢¤Ã¤Æ¤â¡¢¤³¤Î°À­¤Î¥Ç¥Õ¥©¥ë¥È¤Ï¥ª¥Õ¤Ç¤¹¡£ ±øÀ÷¥â¡¼¥É¤Ë¤Ä¤¤¤Æ¤Î¤µ¤é¤Ê¤ë¾ðÊó¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ Perl ¤¬±øÀ÷¥â¡¼¥É¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤³¤ì¤Ï²¿¤â¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡£ =begin original When fetching data that you trust you can turn off the TaintOut attribute, for that statement handle, for the duration of the fetch loop. =end original ¿®Íê¤Ç¤­¤ë¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤¹¤È¤­¡¢Ê¸¥Ï¥ó¥É¥ë¤Ë¤Ä¤¤¤Æ¡¢¼è¤ê½Ð¤· ¥ë¡¼¥×¤Î´Ö¤Ï C °À­¤ò¥ª¥Õ¤ËÀÚ¤êÂؤ¨¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£ =begin original Currently only fetched data is tainted. It is possible that the results of other DBI method calls, and the value of fetched attributes, may also be tainted in future versions. That change may well break your applications unless you take great care now. If you use DBI Taint mode, please report your experience and any suggestions for changes. =end original ¸½ºß¤Ï¼è¤ê½Ð¤µ¤ì¤¿¥Ç¡¼¥¿¤À¤±¤¬±øÀ÷¤µ¤ì¤Æ¤¤¤ë¤È¤·¤Æ¤¤¤Þ¤¹¡£ ¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¾¤Î DBI ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤Î·ë²Ì¤½¤·¤Æ¼è¤ê½Ð¤µ¤ì¤¿Â°À­¤Î ÃͤâƱÍͤ˱øÀ÷¤µ¤ì¤Æ¤¤¤ë¤È¤¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ º£¤Î¤¦¤Á¤ËºÙ¿´¤ÎÃí°Õ¤òʧ¤ï¤Ê¤¤¸Â¤ê¡¢¤½¤ÎÊѹ¹¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò ²õ¤·¤«¤Í¤Þ¤»¤ó¡£ ¤â¤· DBI ¤ò Taint ¥â¡¼¥É¤Ç»È¤¦¤Î¤Ç¤¢¤ì¤Ð¡¢Êѹ¹¤Î¤¿¤á¤Ë¤¢¤Ê¤¿¤Î·Ð¸³¤ÈÄó°Æ¤ò Êó¹ð¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C attribute was added in DBI 1.31. =end original C °À­¤Ï DBI 1.31 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (boolean, inherited) =begin original The C attribute is a shortcut for L and L (it is also present for backwards compatibility). =end original C °À­¤Ï L ¤È L ¤Ø¤Î¥·¥ç¡¼¥È¥«¥Ã¥È¤Ç¤¹ (¤³¤ì¤Ï¤Þ¤¿¸åÊý¸ß´¹À­¤Î¤¿¤á¤Ë¤â¸ºß¤·¤Æ¤¤¤Þ¤¹)¡£ =begin original Setting this attribute sets both L and L, and retrieving it returns a true value if and only if L and L are both set to true values. =end original ¤³¤Î°À­¤òÀßÄꤹ¤ë¤È¡¢L¤ÈL¤ÎξÊý¤¬ÀßÄꤵ¤ì¤Þ¤¹¡£ ¤³¤Î°À­¤ò¼èÆÀ¤¹¤ë¤È¡¢L¤ÈL¤ÎξÊý¤¬trueÃͤËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ßtrueÃͤ¬Ìᤵ¤ì¤Þ¤¹¡£ (TBR) =head3 C (inherited) =begin original The C attribute enables the collection and reporting of method call timing statistics. See the L module documentation for I more detail. =end original C °À­¤Ï¡¢¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¥¿¥¤¥ß¥ó¥°Åý·×¤Î¼ý½¸¤ÈÊó¹ð¤ò Í­¸ú¤Ë¤·¤Þ¤¹¡£ I<Èó¾ï¤Ë> ºÙ¤«¤Ê¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¥â¥¸¥å¡¼¥ë¤Îʸ½ñ¤ò »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The C attribute was added in DBI 1.24. =end original C °À­¤Ï DBI 1.24 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (boolean, inherited) =begin original An application can set the C attribute of a handle to a true value to indicate that it will not be attempting to make any changes using that handle or any children of it. =end original ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¥Ï¥ó¥É¥ë¤ÎC°À­¤òtrueÃͤËÀßÄꤷ¤Æ¡¢¤½¤Î¥Ï¥ó¥É¥ë¤Þ¤¿¤Ï¤½¤Î»Ò¤ò»ÈÍѤ·¤ÆÊѹ¹¤ò»î¤ß¤Ê¤¤¤³¤È¤ò¼¨¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original Note that the exact definition of 'read only' is rather fuzzy. For more details see the documentation for the driver you're using. =end original ¡ÖÆɤ߹þ¤ßÀìÍѡפÎÀµ³Î¤ÊÄêµÁ¤Ï¤ä¤ä¤¢¤¤¤Þ¤¤¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤µ¤é¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï»È¤Ã¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤Îʸ½ñ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original If the driver can make the handle truly read-only then it should (unless doing so would have unpleasant side effect, like changing the consistency level from per-statement to per-session). Otherwise the attribute is simply advisory. =end original ¥É¥é¥¤¥Ð¤¬¥Ï¥ó¥É¥ë¤òËÜÅö¤ËÆɤ߼è¤êÀìÍѤˤǤ­¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢¤½¤¦¤¹¤Ù¤­¤Ç¤¹(¤¿¤À¤·¡¢À°¹çÀ­¥ì¥Ù¥ë¤òʸñ°Ì¤«¤é¥»¥Ã¥·¥ç¥óñ°Ì¤ËÊѹ¹¤¹¤ë¤Ê¤É¡¢ÉÔ²÷¤ÊÉûºîÍѤ¬È¯À¸¤¹¤ë¾ì¹ç¤Ï½ü¤­¤Þ¤¹)¡£ ¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢¤³¤Î°À­¤Ïñ¤Ê¤ë¥¢¥É¥Ð¥¤¥¹¤Ç¤¹¡£ (TBR) =begin original A driver can set the C attribute itself to indicate that the data it is connected to cannot be changed for some reason. =end original ¥É¥é¥¤¥Ð¤Ï¡¢²¿¤é¤«¤ÎÍýͳ¤ÇÊѹ¹¤Ç¤­¤Ê¤¤¤â¤Î¤ËÀܳ¤·¤Æ¤¤¤ë¥Ç¡¼¥¿¤Ç¤¢¤ë¤³¤È¤ò ¼¨¤¹¤¿¤á¤Ë¼«¤é¤Î C °À­¤òÀßÄê¤Ç¤­¤Þ¤¹¡£ =begin original Library modules and proxy drivers can use the attribute to influence their behavior. For example, the DBD::Gofer driver considers the C attribute when making a decision about whether to retry an operation that failed. =end original ¥é¥¤¥Ö¥é¥ê¥â¥¸¥å¡¼¥ë¤ª¤è¤Ó¥×¥í¥­¥·¥É¥é¥¤¥Ð¤Ï¡¢¤³¤Î°À­¤ò»ÈÍѤ·¤ÆÆ°ºî¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢DBD::Gofer¥É¥é¥¤¥Ð¤Ï¡¢¼ºÇÔ¤·¤¿Áàºî¤òºÆ»î¹Ô¤¹¤ë¤«¤É¤¦¤«¤ò·èÄꤹ¤ë¤È¤­¤Ë¡¢C°À­¤ò¹Íθ¤·¤Þ¤¹¡£ (TBR) =begin original The attribute should be set to 1 or 0 (or undef). Other values are reserved. =end original °À­¤Ï 1 ¤Þ¤¿¤Ï 0 (¤Þ¤¿¤Ï undef)¤ËÀßÄꤵ¤ì¤ë¤Ù¤­¤Ç¤¹¡£ ¤½¤Î¾¤ÎÃͤÏͽÌ󤵤ì¤Æ¤¤¤Þ¤¹¡£ =head3 C (hash ref) =begin original The DBI callback mechanism lets you intercept, and optionally replace, any method call on a DBI handle. At the extreme, it lets you become a puppet master, deceiving the application in any way you want. =end original DBI¥³¡¼¥ë¥Ð¥Ã¥¯¥á¥«¥Ë¥º¥à¤ò»ÈÍѤ¹¤ë¤È¡¢DBI¥Ï¥ó¥É¥ë¾å¤ÎǤ°Õ¤Î¥á¥½¥Ã¥É¥³¡¼¥ë¤ò¥¤¥ó¥¿¡¼¥»¥×¥È¤·¡¢¥ª¥×¥·¥ç¥ó¤ÇÃÖ¤­´¹¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¶Ëü¤Ê¾ì¹ç¤Ë¤Ï¡¢¤½¤ì¤Ï¤¢¤Ê¤¿¤¬Áà¤ê¿Í·Á¤Î¥Þ¥¹¥¿¡¼¤Ë¤Ê¤ê¡¢¤¢¤Ê¤¿¤¬Ë¾¤àÊýË¡¤Ç¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òµ½¤¯¤³¤È¤ò²Äǽ¤Ë¤·¤Þ¤¹¡£ (TBR) =begin original The C attribute is a hash reference where the keys are DBI method names and the values are code references. For each key naming a method, the DBI will execute the associated code reference before executing the method. =end original C°À­¤Ï¥Ï¥Ã¥·¥å»²¾È¤Ç¡¢¥­¡¼¤ÏDBI¥á¥½¥Ã¥É̾¡¢Ãͤϥ³¡¼¥É»²¾È¤Ç¤¹¡£ ¥á¥½¥Ã¥É¤ò»ØÄꤹ¤ë³Æ¥­¡¼¤ËÂФ·¤Æ¡¢DBI¤Ï¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥³¡¼¥É»²¾È¤ò¼Â¹Ô¤·¤Þ¤¹¡£ (TBR) =begin original The arguments to the code reference will be the same as to the method, including the invocant (a database handle or statement handle). For example, say that to callback to some code on a call to C: =end original ¥³¡¼¥É»²¾È¤Î°ú¿ô¤Ï¡¢invocant(¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Þ¤¿¤Ï¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë)¤ò´Þ¤á¤Æ¡¢¥á¥½¥Ã¥É¤Î°ú¿ô¤ÈƱ¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢C¤Î¸Æ¤Ó½Ð¤·¤Ç¥³¡¼¥É¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£ (TBR) $dbh->{Callbacks} = { prepare => sub { my ($dbh, $query, $attrs) = @_; print "Preparing q{$query}\n" }, }; =begin original The callback would then be executed when you called the C method: =end original C ¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤¿¤È¤­¤Ë¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹: $dbh->prepare('SELECT 1'); =begin original And the output of course would be: =end original ¤½¤·¤Æ½ÐÎϤϤâ¤Á¤í¤ó°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: Preparing q{SELECT 1} =begin original Because callbacks are executed I the methods they're associated with, you can modify the arguments before they're passed on to the method call. For example, to make sure that all calls to C are immediately prepared by L, add a callback that makes sure that the C attribute is always set: =end original ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥á¥½¥Ã¥É¤Î<Á°>¤Ë¼Â¹Ô¤µ¤ì¤ë¤¿¤á¡¢¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ËÅϤµ¤ì¤ëÁ°¤Ë°ú¿ô¤òÊѹ¹¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð¡¢C¤Ø¤Î¤¹¤Ù¤Æ¤Î¸Æ¤Ó½Ð¤·¤¬L¤Ë¤è¤Ã¤Æ¨ºÂ¤Ë½àÈ÷¤µ¤ì¤ë¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢C°À­¤¬¾ï¤ËÀßÄꤵ¤ì¤ë¤è¤¦¤Ë¤¹¤ë¥³¡¼¥ë¥Ð¥Ã¥¯¤òÄɲä·¤Þ¤¹¡£ (TBR) my $dbh = DBI->connect($dsn, $username, $auth, { Callbacks => { prepare => sub { $_[2] ||= {}; $_[2]->{pg_prepare_now} = 1; return; # must return nothing }, } }); =begin original Note that we are editing the contents of C<@_> directly. In this case we've created the attributes hash if it's not passed to the C call. =end original C<@_> ¤ÎÆâÍƤòľÀÜÊÔ½¸¤·¤Æ¤¤¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤Î¾ì¹ç¡¢¤³¤ì¤¬ C ¸Æ¤Ó½Ð¤·¤ËÅϤµ¤ì¤Ê¤¤¤Ê¤é°À­¥Ï¥Ã¥·¥å¤ò ºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£ =begin original You can also prevent the associated method from ever executing. While a callback executes, C<$_> holds the method name. (This allows multiple callbacks to share the same code reference and still know what method was called.) To prevent the method from executing, simply C. For example, if you wanted to disable calls to C, you could do this: =end original ´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î¼Â¹ÔÃæ¡¢C<$_>¤Ï¥á¥½¥Ã¥É̾¤òÊÝ»ý¤·¤Þ¤¹¡£ (¤³¤ì¤Ë¤è¤ê¡¢Ê£¿ô¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤¬Æ±¤¸¥³¡¼¥É»²¾È¤ò¶¦Í­¤·¡¢¤É¤Î¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤«¤òÃΤ뤳¤È¤¬¤Ç¤­¤Þ¤¹¡£ )¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢Ã±½ã¤ËC¤ò»ÈÍѤ·¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢C¤Î¸Æ¤Ó½Ð¤·¤ò̵¸ú¤Ë¤¹¤ë¾ì¹ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹: (TBR) $dbh->{Callbacks} = { ping => sub { # tell dispatch to not call the method: undef $_; # return this value instead: return "42 bells"; } }; =begin original As with other attributes, Callbacks can be specified on a handle or via the attributes to C. Callbacks can also be applied to a statement methods on a statement handle. For example: =end original ¾¤Î°À­¤ÈƱÍͤˡ¢¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¥Ï¥ó¥É¥ë¾å¤Ç¡¢¤Þ¤¿¤ÏC¤Î°À­¤ò²ð¤·¤Æ»ØÄê¤Ç¤­¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¡¢Ê¸¥Ï¥ó¥É¥ë¾å¤Îʸ¥á¥½¥Ã¥É¤Ë¤âŬÍѤǤ­¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $sth->{Callbacks} = { execute => sub { print "Executing ", shift->{Statement}, "\n"; } }; =begin original The C attribute of a database handle isn't copied to any statement handles it creates. So setting callbacks for a statement handle requires you to set the C attribute on the statement handle yourself, as in the example above, or use the special C key described below. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÎC°À­¤Ï¡¢ºîÀ®¤µ¤ì¤¿Ê¸¥Ï¥ó¥É¥ë¤Ë¤Ï¥³¥Ô¡¼¤µ¤ì¤Þ¤»¤ó¡£ ¤½¤Î¤¿¤á¡¢Ê¸¥Ï¥ó¥É¥ë¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤òÀßÄꤹ¤ë¤Ë¤Ï¡¢Á°½Ò¤ÎÎã¤Î¤è¤¦¤Ëʸ¥Ï¥ó¥É¥ë¤ËC°À­¤òÀßÄꤹ¤ë¤«¡¢¼¡¤ËÀâÌÀ¤¹¤ëÆüì¤ÊC¥­¡¼¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original B =end original B =begin original In addition to DBI handle method names, the C hash reference supports three additional keys. =end original DBI ¥Ï¥ó¥É¥ë¥á¥½¥Ã¥É̾¤Ë²Ã¤¨¤Æ¡¢C ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤Ï »°¤Ä¤ÎÄɲäΥ­¡¼¤ËÂбþ¤·¤Æ¤¤¤Þ¤¹¡£ =begin original The first is the C key. When a statement handle is created from a database handle the C key of the database handle's C attribute, if any, becomes the new C attribute of the statement handle. This allows you to define callbacks for all statement handles created from a database handle. For example, if you wanted to count how many times C was called in your application, you could write: =end original 1¤ÄÌܤÏC¥­¡¼¤Ç¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤«¤éʸ¥Ï¥ó¥É¥ë¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÎC°À­¤ÎC¥­¡¼(¸ºß¤¹¤ë¾ì¹ç)¤¬¡¢Ê¸¥Ï¥ó¥É¥ë¤Î¿·¤·¤¤C°À­¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤«¤éºîÀ®¤µ¤ì¤¿¤¹¤Ù¤Æ¤Îʸ¥Ï¥ó¥É¥ë¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤òÄêµÁ¤Ç¤­¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇC¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿²ó¿ô¤ò¥«¥¦¥ó¥È¤¹¤ë¾ì¹ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ëµ­½Ò¤Ç¤­¤Þ¤¹¡£ (TBR) my $exec_count = 0; my $dbh = DBI->connect( $dsn, $username, $auth, { Callbacks => { ChildCallbacks => { execute => sub { $exec_count++; return; } } } }); END { print "The execute method was called $exec_count times\n"; } =begin original The other two special keys are C and C. These keys define callbacks that are called when C is called, but allow different behaviors depending on whether a new handle is created or a handle is returned. The callback is invoked with these arguments: C<$dbh, $dsn, $user, $auth, $attr>. =end original ¾¤Î2¤Ä¤ÎÆÃÊ̤ʥ­¡¼¤Ï¡¢C¤ª¤è¤ÓC¤Ç¤¹¡£ ¤³¤ì¤é¤Î¥­¡¼¤Ï¡¢C¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤­¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥³¡¼¥ë¥Ð¥Ã¥¯¤òÄêµÁ¤·¤Þ¤¹¤¬¡¢¿·¤·¤¤¥Ï¥ó¥É¥ë¤¬ºîÀ®¤µ¤ì¤ë¤«¡¢¥Ï¥ó¥É¥ë¤¬ÊÖ¤µ¤ì¤ë¤«¤Ë¤è¤Ã¤Æ°Û¤Ê¤ëÆ°ºî¤¬µö²Ä¤µ¤ì¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¡¢¼¡¤Î°ú¿ô¤Ç¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹:C<$dbh, $dsn, $user, $auth, $attr>¡£ (TBR) =begin original For example, some applications uses C to connect with C enabled and then disable C temporarily for transactions. If C is called during a transaction, perhaps in a utility method, then it might select the same cached handle and then force C on, forcing a commit of the transaction. See the L documentation for one way to deal with that. Here we'll describe an alternative approach using a callback. =end original ¤¿¤È¤¨¤Ð¡¢°ìÉô¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢C¤ò»ÈÍѤ·¤ÆC¤òÍ­¸ú¤Ë¤·¤ÆÀܳ¤·¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ËÂФ·¤Æ°ì»þŪ¤ËC¤ò̵¸ú¤Ë¤·¤Þ¤¹¡£ ¥È¥é¥ó¥¶¥¯¥·¥ç¥óÃæ¤Ë¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥á¥½¥Ã¥É¤Ê¤É¤ÇC¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿Æ±¤¸¥Ï¥ó¥É¥ë¤¬ÁªÂò¤µ¤ì¡¢C¤¬¶¯À©Åª¤Ë¥ª¥ó¤Ë¤Ê¤ê¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¶¯À©Åª¤Ë¥³¥ß¥Ã¥È¤µ¤ì¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤ËÂн褹¤ë1¤Ä¤ÎÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤Îʸ½ñ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤³¤Ç¤Ï¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤ò»ÈÍѤ¹¤ëÊ̤Υ¢¥×¥í¡¼¥Á¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£ (TBR) =begin original Because the C callbacks are invoked before connect_cached() has applied the connect attributes you can use a callback to edit the attributes that will be applied. To prevent a cached handle from having its transactions committed before it's returned, you can eliminate the C attribute in a C callback, like so: =end original C¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï¡¢connect_cached()¤¬Àܳ°À­¤òŬÍѤ¹¤ëÁ°¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¤¿¤á¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤ò»ÈÍѤ·¤Æ¡¢Å¬ÍѤµ¤ì¤ë°À­¤òÊÔ½¸¤Ç¤­¤Þ¤¹¡£ ¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿¥Ï¥ó¥É¥ë¤¬Ìᤵ¤ì¤ëÁ°¤Ë¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¥³¥ß¥Ã¥È¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤ËC¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎC°À­¤òºï½ü¤·¤Þ¤¹¡£ (TBR) my $cb = { Žâ€˜connect_cached.reusedŽâ€™ => sub { delete $_[4]->{AutoCommit} }, }; sub dbh { my $self = shift; DBI->connect_cached( $dsn, $username, $auth, { PrintError => 0, RaiseError => 1, AutoCommit => 1, Callbacks => $cb, }); } =begin original The upshot is that new database handles are created with C enabled, while cached database handles are left in whatever transaction state they happened to be in when retrieved from the cache. =end original ¤½¤Î·ë²Ì¡¢¿·¤·¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÏC¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤Þ¤¹¤¬¡¢¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ï¡¢¥­¥ã¥Ã¥·¥å¤«¤é¼èÆÀ¤µ¤ì¤¿¤È¤­¤Ë¤¿¤Þ¤¿¤Þ¸ºß¤·¤Æ¤¤¤¿¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¾õÂ֤Τޤޤˤʤê¤Þ¤¹¡£ (TBR) =begin original A more common application for callbacks is setting connection state only when a new connection is made (by connect() or connect_cached()). Adding a callback to the connected method makes this easy. This method is a no-op by default (unless you subclass the DBI and change it). The DBI calls it to indicate that a new connection has been made and the connection attributes have all been set. You can give it a bit of added functionality by applying a callback to it. For example, to make sure that MySQL understands your application's ANSI-compliant SQL, set it up like so: =end original ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î¤è¤ê°ìÈÌŪ¤ÊÍÑÅӤϡ¢(connect()¤Þ¤¿¤Ïconnect_cached()¤Ë¤è¤Ã¤Æ)¿·¤·¤¤Àܳ¤¬ºîÀ®¤µ¤ì¤¿¤È¤­¤Ë¤Î¤ßÀܳ¾õÂÖ¤òÀßÄꤹ¤ë¤³¤È¤Ç¤¹¡£ Àܳ¤µ¤ì¤¿¥á¥½¥Ã¥É¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤òÄɲ乤ë¤È¡¢¤³¤ì¤¬´Êñ¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤Î¥á¥½¥Ã¥É¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤Ïno-op¤Ç¤¹(DBI¤ò¥µ¥Ö¥¯¥é¥¹²½¤·¤ÆÊѹ¹¤·¤Ê¤¤¸Â¤ê)¡£ DBI¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢¿·¤·¤¤Àܳ¤¬ºîÀ®¤µ¤ì¡¢Àܳ°À­¤¬¤¹¤Ù¤ÆÀßÄꤵ¤ì¤¿¤³¤È¤ò¼¨¤·¤Þ¤¹¡£ ¥³¡¼¥ë¥Ð¥Ã¥¯¤òŬÍѤ¹¤ë¤³¤È¤Ç¡¢¾¯¤·µ¡Ç½¤òÄɲäǤ­¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢MySQL¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎANSI½àµò¤ÎSQL¤òǧ¼±¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤ËÀßÄꤷ¤Þ¤¹: (TBR) my $dbh = DBI->connect($dsn, $username, $auth, { Callbacks => { connected => sub { shift->do(q{ SET SESSION sql_mode='ansi,strict_trans_tables,no_auto_value_on_zero'; }); return; }, } }); =begin original One significant limitation with callbacks is that there can only be one per method per handle. This means it's easy for one use of callbacks to interfere with, or typically simply overwrite, another use of callbacks. For this reason modules using callbacks should document the fact clearly so application authors can tell if use of callbacks by the module will clash with use of callbacks by the application. =end original ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î½ÅÍפÊÀ©¸Â¤Î1¤Ä¤Ï¡¢¥Ï¥ó¥É¥ë¤´¤È¤Ë¥á¥½¥Ã¥É¤´¤È¤Ë1¤Ä¤·¤«Â¸ºß¤Ç¤­¤Ê¤¤¤³¤È¤Ç¤¹¡£ ¤³¤ì¤Ï¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤Î¤¢¤ë»ÈÍѤ¬¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎÊ̤λÈÍѤȴ³¾Ä¤·¤¿¤ê¡¢Ä̾ï¤Ïñ¤Ë¾å½ñ¤­¤·¤¿¤ê¤¹¤ë¤³¤È¤¬ÍưפǤ¢¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ ¤³¤Î¤¿¤á¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤ò»ÈÍѤ¹¤ë¥â¥¸¥å¡¼¥ë¤Ï¡¢¥â¥¸¥å¡¼¥ë¤Ë¤è¤ë¥³¡¼¥ë¥Ð¥Ã¥¯¤Î»ÈÍѤ¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤ë¥³¡¼¥ë¥Ð¥Ã¥¯¤Î»ÈÍѤȶ¥¹ç¤¹¤ë¤«¤É¤¦¤«¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥óºîÀ®¼Ô¤¬È½ÃǤǤ­¤ë¤è¤¦¤Ë¡¢¤½¤Î»ö¼Â¤òÌÀ³Î¤Ëʸ½ñ²½¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original You might be able to work around this issue by taking a copy of the original callback and calling it within your own. For example: =end original ¸µ¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤Î¥³¥Ô¡¼¤ò¼è¤Ã¤Æ¡¢¤½¤Á¤é¤ò¸Æ¤Ö¤³¤È¤Ç¤³¤ÎÌäÂê¤ò ²óÈò¤Ç¤­¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ Î㤨¤Ð: my $prev_cb = $h->{Callbacks}{method_name}; $h->{Callbacks}{method_name} = sub { if ($prev_cb) { my @result = $prev_cb->(@_); return @result if not $_; # $prev_cb vetoed call } ... your callback logic here ... }; =head3 C =begin original The DBI provides a way to store extra information in a DBI handle as "private" attributes. The DBI will allow you to store and retrieve any attribute which has a name starting with "C". =end original DBI ¤Ï¡Ö¥×¥é¥¤¥Ù¡¼¥È¡×°À­¤È¤·¤Æ¡¢DBI ¥Ï¥ó¥É¥ë¤Ç¤ÎÆÃÊ̤ʾðÊó¤ò³ÊǼ¤¹¤ë ÊýË¡¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£ DBI ¤Ç¤Ï "C" ¤Ç»Ï¤Þ¤ë̾Á°¤Î°À­¤ò³ÊǼ¡¢»²¾È¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original It is I recommended that you use just I private attribute (e.g., use a hash ref) I give it a long and unambiguous name that includes the module or application name that the attribute relates to (e.g., "C"). =end original ¤¿¤À¤·¥×¥é¥¤¥Ù¡¼¥È°À­¤Ï(Î㤨¤Ð¥Ï¥Ã¥·¥å¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤ò»È¤¦¤Ê¤É¤Ë¤è¤ê) I<°ì¤Ä> ¤À¤±¤È¤·¡¢I<¤«¤Ä> ¤½¤Î°À­¤Ë´ØÏ¢¤¹¤ë¥â¥¸¥å¡¼¥ë¤Þ¤¿¤Ï ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó̾¤¬Æþ¤Ã¤¿Ä¹¤¯¤Æ¾¤Ë¤Ï¤Ê¤¤¤è¤¦¤Ê̾Á°¤Ë¤¹¤ë¤³¤È¤ò I<¶¯¤¯> ¤ª´«¤á¤·¤Þ¤¹(Î㤨¤Ð "C")¡£ =begin original Because of the way the Perl tie mechanism works you cannot reliably use the C<||=> operator directly to initialise the attribute, like this: =end original Perl ¤Î tie µ¡¹½¤ÎÆ°ºî¼êË¡¤Ë¤è¤ê¡¢°Ê²¼¤Î¤è¤¦¤Ë¡¢Â°À­¤ò½é´ü²½¤¹¤ë¤¿¤á¤Ë ¿®Íê¤Ç¤­¤ë·Á¤ÇC<||=> ±é»»»Ò¤òľÀܻȤ¦¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£ my $foo = $dbh->{private_yourmodname_foo} ||= { ... }; # WRONG =begin original you should use a two step approach like this: =end original °Ê²¼¤Î¤è¤¦¤ËÆóÃʳ¬¤Î¼êË¡¤ò»È¤¦¤Ù¤­¤Ç¤¹: my $foo = $dbh->{private_yourmodname_foo}; $foo ||= $dbh->{private_yourmodname_foo} = { ... }; =begin original This attribute is primarily of interest to people sub-classing DBI, or for applications to piggy-back extra information onto DBI handles. =end original ¤³¤Î°À­¤Ï´ðËÜŪ¤Ë DBI ¤ò¥µ¥Ö¥¯¥é¥¹²½¤¹¤ë¿Í¡¹¤ä¡¢DBI ¥Ï¥ó¥É¥ë¤Ë ¤½¤Î¾¤Î¾ðÊó¤òÄɲ乤륢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬´Ø¿´¤ò»ý¤Ä¤â¤Î¤Ç¤¹¡£ =head1 DBI DATABASE HANDLE OBJECTS (DBI ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È) =begin original This section covers the methods and attributes associated with database handles. =end original ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Ï¥ó¥É¥ë¤Ë´ØÏ¢¤¹¤ë¥á¥½¥Ã¥É¤È°À­¤Ë¤Ä¤¤¤Æ ¥«¥Ð¡¼¤·¤Þ¤¹¡£ =head2 Database Handle Methods (¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¥á¥½¥Ã¥É) =begin original The following methods are specified for DBI database handles: =end original °Ê²¼¤Î¥á¥½¥Ã¥É¤¬DBI¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Ï¥ó¥É¥ë¤Ë»ØÄꤵ¤ì¤Æ¤¤¤Þ¤¹: =head3 C $new_dbh = $dbh->clone(); $new_dbh = $dbh->clone(\%attr); =begin original The C method duplicates the $dbh connection by connecting with the same parameters ($dsn, $user, $password) as originally used. =end original C ¥á¥½¥Ã¥É¤Ï¡¢$dbh Àܳ¤ò¡¢Æ±¤¸¥Ñ¥é¥á¡¼¥¿ ($dsn, $user, $password) ¤Ç Àܳ¤¹¤ë¤³¤È¤ÇÊ£À½¤·¤Þ¤¹¡£ =begin original The attributes for the cloned connect are the same as those used for the original connect, with some other attributes merged over them depending on the \%attr parameter. =end original Ê£À½¤µ¤ì¤¿Àܳ¤Î°À­¤Ï¸µ¤ÎÀܳ¤Î¤â¤Î¤ÈƱ¤¸¤â¤Î¤Ë¡¢\%attr °ú¿ô¤Ë¤è¤ë¤â¤Î¤¬ ¥Þ¡¼¥¸¤µ¤ì¤¿¤â¤Î¤Ç¤¹¡£ =begin original If \%attr is given then the attributes it contains are merged into the original attributes and override any with the same names. Effectively the same as doing: =end original \%attr¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤½¤ì¤Ë´Þ¤Þ¤ì¤ë°À­¤Ï¸µ¤Î°À­¤Ë¥Þ¡¼¥¸¤µ¤ì¡¢Æ±¤¸Ì¾Á°¤Î°À­¤Ï¾å½ñ¤­¤µ¤ì¤Þ¤¹¡£ ¼¡¤ÎÁàºî¤È¼Â¼ÁŪ¤ËƱ¤¸¤Ç¤¹¡£ (TBR) %attribues_used = ( %original_attributes, %attr ); =begin original If \%attr is not given then it defaults to a hash containing all the attributes in the attribute cache of $dbh excluding any non-code references, plus the main boolean attributes (RaiseError, PrintError, AutoCommit, etc.). This behaviour is subject to change. =end original \%attr¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢$dbh¤Î°À­¥­¥ã¥Ã¥·¥åÆâ¤Î¤¹¤Ù¤Æ¤Î°À­(¥³¡¼¥É»²¾È°Ê³°¤ò½ü¤¯)¤Ë²Ã¤¨¤Æ¡¢¼çÍפʥ֡¼¥ë°À­(RaiseError¡¢PrintError¡¢AutoCommit¤Ê¤É)¤ò´Þ¤à¥Ï¥Ã¥·¥å¤¬»ÈÍѤµ¤ì¤Þ¤¹¡£ ¤³¤ÎÆ°ºî¤ÏÊѹ¹¤µ¤ì¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The clone method can be used even if the database handle is disconnected. =end original clone ¥á¥½¥Ã¥É¤ÏÎ㤨¤Ð¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÎÀܳ¤¬ÀÚ¤ì¤Æ¤¤¤Æ¤â»È¤¨¤Þ¤¹¡£ =begin original The C method was added in DBI 1.33. It is very new and likely to change. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.33 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ ¤³¤ì¤Ï¤È¤Æ¤â¿·¤·¤¯¡¢Êѹ¹¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =head3 C @ary = $dbh->data_sources(); @ary = $dbh->data_sources(\%attr); =begin original Returns a list of data sources (databases) available via the $dbh driver's data_sources() method, plus any extra data sources that the driver can discover via the connected $dbh. Typically the extra data sources are other databases managed by the same server process that the $dbh is connected to. =end original $dbh¥É¥é¥¤¥Ð¤Îdata_sources()¥á¥½¥Ã¥É¤Ç»ÈÍѲÄǽ¤Ê¥Ç¡¼¥¿¥½¡¼¥¹(¥Ç¡¼¥¿¥Ù¡¼¥¹)¤Î¥ê¥¹¥È¤È¡¢Àܳ¤µ¤ì¤¿$dbh¤ò²ð¤·¤Æ¥É¥é¥¤¥Ð¤¬¸¡½Ð¤Ç¤­¤ëÄɲäΥǡ¼¥¿¥½¡¼¥¹¤òÊÖ¤·¤Þ¤¹¡£ Ä̾ÄɲäΥǡ¼¥¿¥½¡¼¥¹¤Ï¡¢$dbh¤¬Àܳ¤µ¤ì¤Æ¤¤¤ë¤Î¤ÈƱ¤¸¥µ¡¼¥Ð¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¾¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤¹¡£ (TBR) =begin original Data sources are returned in a form suitable for passing to the L method (that is, they will include the "C" prefix). =end original ¥Ç¡¼¥¿¥½¡¼¥¹¤Ï L ¥á¥½¥Ã¥É¤ËÅϤ¹¤Î¤ËŬ¤·¤¿¤Ê·Á¼°¤ÇÊÖ¤µ¤ì¤Þ¤¹ (¤Ä¤Þ¤êÀÜƬ¼­ "C" ¤¬Æþ¤ê¤Þ¤¹¡£) =begin original The data_sources() method, for a $dbh, was added in DBI 1.38. =end original $dbh ¤Î¤¿¤á¤Î data_sources() ¥á¥½¥Ã¥É¤Ï DBI 1.38 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $rows = $dbh->do($statement) or die $dbh->errstr; $rows = $dbh->do($statement, \%attr) or die $dbh->errstr; $rows = $dbh->do($statement, \%attr, @bind_values) or die ... =begin original Prepare and execute a single statement. Returns the number of rows affected or C on error. A return value of C<-1> means the number of rows is not known, not applicable, or not available. =end original °ì¤Ä¤Îʸ¤ò prepare ¤·¡¢execute ¤·¤Þ¤¹¡£ ±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤Î¿ô¤ò¡¢¤Þ¤¿¥¨¥é¡¼¤Ç¤¢¤ì¤Ð C ¤òÊÖ¤·¤Þ¤¹¡£ C<-1> ¤Ï¹Ô¤Î¿ô¤¬Ê¬¤«¤é¤Ê¤¤¤«»ÈÍѤǤ­¤Ê¤¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ =begin original This method is typically most useful for I-C statements because it does not return a statement handle (so you can't fetch any data). =end original ¤³¤Î¥á¥½¥Ã¥É¤Ïŵ·¿Åª¤Ë¤Ï¡¢(¥É¥é¥¤¥Ð¤ÎÀ©¸Â¤Ë¤è¤ê)Á°¤â¤Ã¤Æ prepare ¤µ¤ì¤ë¤³¤È¤¬ ¤Ê¤«¤Ã¤¿¤ê¡¢·«¤êÊÖ¤·¼Â¹Ô¤·¤Ê¤¤ C ʸ¤Ç¤Ï»È¤¦¤Ù¤­¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original The default C method is logically similar to: =end original ¥Ç¥Õ¥©¥ë¥È¤Îdo¥á¥½¥Ã¥É¤Ï¡¢ÏÀÍýŪ¤Ë¤Ï°Ê²¼¤Î¤â¤Î¤ÈƱÍͤǤ¹: sub do { my($dbh, $statement, $attr, @bind_values) = @_; my $sth = $dbh->prepare($statement, $attr) or return undef; $sth->execute(@bind_values) or return undef; my $rows = $sth->rows; ($rows == 0) ? "0E0" : $rows; # always return true if no error } =begin original For example: =end original Î㤨¤Ð: my $rows_deleted = $dbh->do(q{ DELETE FROM table WHERE status = ? }, undef, 'DONE') or die $dbh->errstr; =begin original Using placeholders and C<@bind_values> with the C method can be useful because it avoids the need to correctly quote any variables in the C<$statement>. But if you'll be executing the statement many times then it's more efficient to C it once and call C many times instead. =end original ¥×¥ì¡¼¥¹¥Û¥ë¥À¤È¥Ð¥¤¥ó¥ÉÊÑ¿ô(C<@bind_values>) ¤ò C ¥á¥½¥Ã¥É¤Ç»È¤¦¤È¡¢ C<$statement> ¤ÎÃæ¤ÎÊÑ¿ô¤òÀµ¤·¤¯¥¯¥©¡¼¥È¤·¤Ê¤¯¤Æ¤â¤è¤¯¤Ê¤ë¤¿¤á¤Ë¤È¤Æ¤â ÊØÍø¤Ç¤¹¡£ ¤·¤«¤·¤â¤·Ê¸¤ò²¿ÅÙ¤â¼Â¹Ô¤¹¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢Âå¤ï¤ê¤Ë °ìÅÙ C ¤·¡¢²¿ÅÙ¤â C ¤¹¤ë¤Û¤¦¤¬¤è¤ê¸úΨŪ¤Ç¤¹¡£ =begin original The C style quoting used in this example avoids clashing with quotes that may be used in the SQL statement. Use the double-quote-like C operator if you want to interpolate variables into the string. See L for more details. =end original ¤³¤ÎÎã¤Ç»È¤ï¤ì¤Æ¤¤¤ë C ·Á¼°¤Î¥¯¥©¡¼¥È¤Ï¡¢Ê¸¤Ç »È¤ï¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¥¯¥©¡¼¥È¤ÎÂбþ¤ò²õ¤µ¤ì¤Ê¤¤¤è¤¦¤Ë»È¤ï¤ì¤Æ¤¤¤Þ¤¹¡£ ʸ»úÎó¤ËÆþ¤Ã¤Æ¤¤¤ëÊÑ¿ô¤ò²ò¼á¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢¥À¥Ö¥ë¥¯¥©¡¼¥ÈÉ÷ C ±é»»»Ò¤ò»È¤¤¤Þ¤¹¡£ ¾ÜºÙ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C $rv = $dbh->last_insert_id($catalog, $schema, $table, $field); $rv = $dbh->last_insert_id($catalog, $schema, $table, $field, \%attr); =begin original Returns a value 'identifying' the row just inserted, if possible. Typically this would be a value assigned by the database server to a column with an I or I type. Returns undef if the driver does not support the method or can't determine the value. =end original ²Äǽ¤Ç¤¢¤ì¤Ð¡¢ÁÞÆþ¤µ¤ì¤¿¹Ô¤ò'¼±Ê̤¹¤ë'ÃͤòÊÖ¤·¤Þ¤¹¡£ Ä̾¤³¤ì¤ÏI¤Þ¤¿¤ÏI¥¿¥¤¥×¤ÎÎó¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤Ë¤è¤Ã¤Æ³ä¤êÅö¤Æ¤é¤ì¤¿ÃͤǤ¹¡£ ¥É¥é¥¤¥Ð¤¬¥á¥½¥Ã¥É¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¤Þ¤¿¤ÏÃͤòȽÊ̤Ǥ­¤Ê¤¤¾ì¹ç¤Ï¡¢undef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original The $catalog, $schema, $table, and $field parameters may be required for some drivers (see below). If you don't know the parameter values and your driver does not need them, then use C for each. =end original °ìÉô¤Î¥É¥é¥¤¥Ð¤Ç¤Ï¡¢$catalog¡¢$schema¡¢$table¡¢¤ª¤è¤Ó$field¥Ñ¥é¥á¡¼¥¿¤¬É¬Íפˤʤë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹(°Ê²¼¤ò»²¾È)¡£ ¥Ñ¥é¥á¡¼¥¿¤ÎÃͤ¬¤ï¤«¤é¤º¡¢¥É¥é¥¤¥Ð¤¬¤½¤ì¤é¤òɬÍפȤ·¤Ê¤¤¾ì¹ç¤Ï¡¢¤½¤ì¤¾¤ì¤ËC¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) =begin original There are several caveats to be aware of with this method if you want to use it for portable applications: =end original ¤³¤Î¥á¥½¥Ã¥É¤ò°Ü¿¢À­¤Î¤¢¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë»È¤¤¤¿¤¤¤Ê¤é¡¢Ãí°Õ¤¹¤ë¤Ù¤­ ¤¤¤¯¤Ä¤«¤Î·Ù¹ð¤¬¤¢¤ê¤Þ¤¹: =begin original B<*> For some drivers the value may only available immediately after the insert statement has executed (e.g., mysql, Informix). =end original B<*> ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï(mysql, Informix ¤Ê¤É)¡¢Ãͤ¬ insert ʸ¤¬¼Â¹Ô¤µ¤ì¤¿ ľ¸å¤Ç¤Î¤ßÍøÍѲÄǽ¤Ç¤¢¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ =begin original B<*> For some drivers the $catalog, $schema, $table, and $field parameters are required, for others they are ignored (e.g., mysql). =end original B<*> ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï (mysql ¤Ê¤É)¡¢$catalog, $schema, $table, $field ¥Ñ¥é¥á¡¼¥¿¤¬É¬ÍפǤ¢¤Ã¤¿¤ê¡¢Ìµ»ë¤µ¤ì¤¿¤ê¤·¤Þ¤¹¡£ =begin original B<*> Drivers may return an indeterminate value if no insert has been performed yet. =end original B<*> insert ʸ¤¬¤Þ¤À¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¥É¥é¥¤¥Ð¤ÏÉÔÄê¤ÊÃͤò ÊÖ¤¹¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original B<*> For some drivers the value may only be available if placeholders have I been used (e.g., Sybase, MS SQL). In this case the value returned would be from the last non-placeholder insert statement. =end original B<*>°ìÉô¤Î¥É¥é¥¤¥Ð(Sybase¡¢MS SQL¤Ê¤É)¤Ç¤Ï¡¢¥×¥ì¡¼¥¹¥Û¥ë¥ÀI¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ßÃͤ¬»ÈÍѲÄǽ¤Ç¤¹¡£ ¤³¤Î¾ì¹ç¡¢ÊÖ¤µ¤ì¤ëÃͤϡ¢ºÇ¸å¤ÎÈó¥×¥ì¡¼¥¹¥Û¥ë¥ÀÁÞÆþ¥¹¥Æ¡¼¥È¥á¥ó¥È¤«¤é¤ÎÃͤˤʤê¤Þ¤¹¡£ (TBR) =begin original B<*> Some drivers may need driver-specific hints about how to get the value. For example, being told the name of the database 'sequence' object that holds the value. Any such hints are passed as driver-specific attributes in the \%attr parameter. =end original B<*>¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢ÃͤμèÆÀÊýË¡¤Ë´Ø¤¹¤ë¥É¥é¥¤¥Ð¸ÇÍ­¤Î¥Ò¥ó¥È¤¬É¬Íפʾì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢ÃͤòÊÝ»ý¤¹¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤Îsequence¥ª¥Ö¥¸¥§¥¯¥È¤Î̾Á°¤¬ÄÌÃΤµ¤ì¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ê¥Ò¥ó¥È¤Ï¡¢\%attr¥Ñ¥é¥á¡¼¥¿¤Ë¥É¥é¥¤¥Ð¸ÇÍ­¤Î°À­¤È¤·¤ÆÅϤµ¤ì¤Þ¤¹¡£ (TBR) =begin original B<*> If the underlying database offers nothing better, then some drivers may attempt to implement this method by executing "C"¤ò¼Â¹Ô¤·¤Æ¤³¤Î¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤è¤¦¤È¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ê¥¢¥×¥í¡¼¥Á¤ò»ÈÍѤ¹¤ë¥É¥é¥¤¥Ð¤Ï¡¢C¤¬true¤Î¾ì¹ç¤Ë·Ù¹ð¤òȯ¹Ô¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢°ìÈÌŪ¤Ë°ÂÁ´¤Ç¤Ï¤Ê¤¤¤¿¤á¤Ç¤¹¡£ ÊÌ¤Î¥×¥í¥»¥¹¤¬ÁÞÆþ¤ÈÁªÂò¤Î´Ö¤Ë¥Æ¡¼¥Ö¥ë¤òÊѹ¹¤·¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ò¥í¥Ã¥¯¤·¤¿¾ì¹ç¤Ê¤É¡¢°ÂÁ´¤Ç¤¢¤ë¤³¤È¤¬¤ï¤«¤Ã¤Æ¤¤¤ë¾õ¶·¤Ç¤Ï¡¢\%attr¤ËC=>0¤òÅϤ¹¤³¤È¤Ë¤è¤Ã¤Æ·Ù¹ð¤òÍ޻ߤǤ­¤Þ¤¹¡£ (TBR) =begin original B<*> If no insert has been performed yet, or the last insert failed, then the value is implementation defined. =end original B<*> ¤Þ¤À insert ʸ¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¤ê¡¢ºÇ¸å¤Î insert ʸ¤¬ ¼ºÇÔ¤·¤Æ¤¤¤¿¤ê¤·¤¿¾ì¹ç¡¢ÃͤϼÂÁõ°Í¸¤Ç¤¹¡£ =begin original Given all the caveats above, it's clear that this method must be used with care. =end original ¾å½ÒÁ´¤Æ¤ÎÃí°ÕÅÀ¤«¤é¡¢¤³¤Î¥á¥½¥Ã¥É¤ÏÃí°Õ¤·¤Æ»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤Ï ÌÀ¤é¤«¤Ç¤¹¡£ =begin original The C method was added in DBI 1.38. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.38 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C @row_ary = $dbh->selectrow_array($statement); @row_ary = $dbh->selectrow_array($statement, \%attr); @row_ary = $dbh->selectrow_array($statement, \%attr, @bind_values); =begin original This utility method combines L, L and L into a single call. If called in a list context, it returns the first row of data from the statement. The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¡¼¥á¥½¥Ã¥É¤Ï¡¢L, L, L ¤ò°ì²ó¤Ë¤Þ¤È¤á¤Æ¤ª¤³¤Ê¤¤¤Þ¤¹¡£ ¥ê¥¹¥È¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ð¤ì¤ì¤Ð¡¢¤½¤Îʸ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë ºÇ½é¤Î¹Ô¤òÊÖ¤·¤Þ¤¹¡£ C<$statement> ¥Ñ¥é¥á¡¼¥¿¤Ï¤¹¤Ç¤Ë C ¤µ¤ì¤Æ¤¤¤ë ʸ¥Ï¥ó¥É¥ë¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢C ¤ÏÈô¤Ð¤µ¤ì¤Þ¤¹¡£ =begin original If any method fails, and L is not set, C will return an empty list. =end original ¤¤¤º¤ì¤«¤Î¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤È¤Ê¤ê¡¢L ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢ C ¤Ï¶õ¤Î¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£ =begin original If called in a scalar context for a statement handle that has more than one column, it is undefined whether the driver will return the value of the first column or the last. So don't do that. Also, in a scalar context, an C is returned if there are no more rows or if an error occurred. That C can't be distinguished from an C returned because the first field value was NULL. For these reasons you should exercise some caution if you use C in a scalar context, or just don't do that. =end original Ê£¿ôÎó¤Î¤¢¤ëʸ¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¥¹¥«¥é¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤¹¤È¡¢ ¥É¥é¥¤¥Ð¤¬ºÇ½é¤ÎÎó¤òÊÖ¤¹¤«ºÇ¸å¤ÎÎó¤òÊÖ¤¹¤«¤Ï̤ÄêµÁ¤Ç¤¹¡£ ½¾¤Ã¤Æ¡¢¤ä¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£ ¤Þ¤¿¡¢¥¹¥«¥é¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢ ¤â¤¦¹Ô¤¬¤Ê¤¤¤«¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤Ê¤é¤Ð¡¢C ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¤³¤Î C ¤ÏºÇ½é¤Ë¥Õ¥£¡¼¥ë¥É¤ÎÃͤ¬ NULL ¤Ç¤¢¤Ã¤¿¤¿¤á¤ËÊÖ¤µ¤ì¤¿ C ¤È¶èÊ̤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£ ¤³¤ì¤é¤ÎÍýͳ¤Ë¤è¤Ã¤Æ¡¢C ¤ò¥¹¥«¥é¥³¥ó¥Æ¥­¥¹¥È¤Ç ¸Æ¤Ó½Ð¤¹¤È¤­¤Ë¤ÏÃí°Õ¤¹¤ë¤«¡¢Ã±¤Ë»È¤ï¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $ary_ref = $dbh->selectrow_arrayref($statement); $ary_ref = $dbh->selectrow_arrayref($statement, \%attr); $ary_ref = $dbh->selectrow_arrayref($statement, \%attr, @bind_values); =begin original This utility method combines L, L and L into a single call. It returns the first row of data from the statement. The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥á¥½¥Ã¥É¤Ï¡¢L¡¢L¡¢¤ª¤è¤ÓL¤ò1²ó¤Î¸Æ¤Ó½Ð¤·¤Ë·ë¹ç¤·¤Þ¤¹¡£ ¥¹¥Æ¡¼¥È¥á¥ó¥È¤«¤é¥Ç¡¼¥¿¤ÎºÇ½é¤Î¹Ô¤òÊÖ¤·¤Þ¤¹¡£ C<$statement>¥Ñ¥é¥á¡¼¥¿¤Ë¤Ï¡¢°ÊÁ°¤Ë½àÈ÷¤µ¤ì¤¿¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢C¤Ï¥¹¥­¥Ã¥×¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If any method fails, and L is not set, C will return undef. =end original ¤¤¤º¤ì¤«¤Î¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤Æ¡¢L ¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ C ¤Ï undef ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C $hash_ref = $dbh->selectrow_hashref($statement); $hash_ref = $dbh->selectrow_hashref($statement, \%attr); $hash_ref = $dbh->selectrow_hashref($statement, \%attr, @bind_values); =begin original This utility method combines L, L and L into a single call. It returns the first row of data from the statement. The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥á¥½¥Ã¥É¤Ï¡¢L¡¢L¡¢¤ª¤è¤ÓL¤ò1²ó¤Î¸Æ¤Ó½Ð¤·¤Ë·ë¹ç¤·¤Þ¤¹¡£ ¥¹¥Æ¡¼¥È¥á¥ó¥È¤«¤é¥Ç¡¼¥¿¤ÎºÇ½é¤Î¹Ô¤òÊÖ¤·¤Þ¤¹¡£ C<$statement>¥Ñ¥é¥á¡¼¥¿¤Ë¤Ï¡¢°ÊÁ°¤Ë½àÈ÷¤µ¤ì¤¿¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢C¤Ï¥¹¥­¥Ã¥×¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If any method fails, and L is not set, C will return undef. =end original ¤¤¤º¤ì¤«¤Î¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤Æ¡¢L ¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ C ¤Ï undef ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C $ary_ref = $dbh->selectall_arrayref($statement); $ary_ref = $dbh->selectall_arrayref($statement, \%attr); $ary_ref = $dbh->selectall_arrayref($statement, \%attr, @bind_values); =begin original This utility method combines L, L and L into a single call. It returns a reference to an array containing a reference to an array (or hash, see below) for each row of data fetched. =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥á¥½¥Ã¥É¤Ï¡¢L, L, L ¤ò°ì²ó¤Ë¤Þ¤È¤á¤Æ¤ª¤³¤Ê¤¤¤Þ¤¹¡£ ¼è¤ê½Ð¤µ¤ì¤¿¥Ç¡¼¥¿¤Î³Æ¹Ô¤ÎÇÛÎó(¤Þ¤¿¤Ï¥Ï¥Ã¥·¥å; ¸å½Ò)¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤¬Æþ¤Ã¤¿ ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. This is recommended if the statement is going to be executed many times. =end original C<$statement> ¥Ñ¥é¥á¡¼¥¿¤ò´û¤Ë prepare ¤µ¤ì¤Æ¤¤¤ëʸ¥Ï¥ó¥É¥ë¤Ë ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹; ¤½¤Î¾ì¹ç¡¢C ¤ÏÈô¤Ð¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï²¿²ó¤âʸ¤¬¼Â¹Ô¤¹¤ëͽÄê¤Ç¤¢¤ì¤Ð¤ª´«¤á¤Ç¤¹¡£ =begin original If L is not set and any method except C fails then C will return C; if C fails then it will return with whatever data has been fetched thus far. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the data is complete or was truncated due to an error. =end original L¤¬ÀßÄꤵ¤ì¤Æ¤ª¤é¤º¡¢C°Ê³°¤Î¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢C¤ÏC¤òÊÖ¤·¤Þ¤¹¡£ C¤¬¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¡¢¤³¤ì¤Þ¤Ç¤Ë¥Õ¥§¥Ã¥Á¤µ¤ì¤¿¥Ç¡¼¥¿¤òÊÖ¤·¤Þ¤¹¡£ ¸å¤ÇC<$sth-Eerr>¤ò¥Á¥§¥Ã¥¯¤·¤Æ(¤Þ¤¿¤ÏC°À­¤ò»ÈÍѤ·¤Æ)¡¢¥Ç¡¼¥¿¤¬´°Á´¤Ç¤¢¤ë¤«¡¢¥¨¥é¡¼¤Î¤¿¤á¤ËÀÚ¤ê¼Î¤Æ¤é¤ì¤¿¤«¤ò¸¡½Ð¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The L method called by C supports a $max_rows parameter. You can specify a value for $max_rows by including a 'C' attribute in \%attr. In which case finish() is called for you after fetchall_arrayref() returns. =end original C¤Ë¤è¤Ã¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ëL¥á¥½¥Ã¥É¤Ï¡¢$max_rows¥Ñ¥é¥á¡¼¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ \%attr¤Ë'C'°À­¤ò´Þ¤á¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢$max_rows¤ÎÃͤò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢fetchall_arrayref()¤¬ÊÖ¤µ¤ì¤¿¸å¤Ëfinish()¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original The L method called by C also supports a $slice parameter. You can specify a value for $slice by including a 'C' or 'C' attribute in \%attr. The only difference between the two is that if C is not defined and C is an array ref, then the array is assumed to contain column index values (which count from 1), rather than perl array index values. In which case the array is copied and each value decremented before passing to C. =end original C¤Ë¤è¤Ã¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ëL¥á¥½¥Ã¥É¤â¡¢$slice¥Ñ¥é¥á¡¼¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£ \%attr¤Ë'C'¤Þ¤¿¤Ï'C'°À­¤ò´Þ¤á¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢$slice¤ÎÃͤò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¤³¤Î2¤Ä¤ÎÍ£°ì¤Î°ã¤¤¤Ï¡¢C¤¬ÄêµÁ¤µ¤ì¤Æ¤ª¤é¤º¡¢C¤¬ÇÛÎ󻲾ȤǤ¢¤ë¾ì¹ç¡¢ÇÛÎó¤Ë¤ÏperlÇÛÎ󥤥ó¥Ç¥Ã¥¯¥¹ÃͤǤϤʤ¯¡¢(1¤«¤é¥«¥¦¥ó¥È¤µ¤ì¤ë)Î󥤥ó¥Ç¥Ã¥¯¥¹Ãͤ¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤È¸«¤Ê¤µ¤ì¤ë¤³¤È¤Ç¤¹¡£ ¤³¤Î¾ì¹ç¡¢ÇÛÎó¤Ï¥³¥Ô¡¼¤µ¤ì¡¢³ÆÃͤÏC¤ËÅϤµ¤ì¤ëÁ°¤Ë¥Ç¥¯¥ê¥á¥ó¥È¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original You may often want to fetch an array of rows where each row is stored as a hash. That can be done simple using: =end original ³Æ¹Ô¤ò¥Ï¥Ã¥·¥å¤È¤·¤ÆÊݴɤ·¤Æ¤¤¤ë¹Ô¤ÎÇÛÎó¤ò¥Õ¥§¥Ã¥Á¤·¤¿¤¤¤³¤È¤¬Â¿¤¤¤Ç¤·¤ç¤¦¡£ ñ½ã¤Ë°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¤Ç¤­¤Þ¤¹: my $emps = $dbh->selectall_arrayref( "SELECT ename FROM emp ORDER BY ename", { Slice => {} } ); foreach my $emp ( @$emps ) { print "Employee: $emp->{ename}\n"; } =begin original Or, to fetch into an array instead of an array ref: =end original ¤Þ¤¿¤Ï¡¢¥Õ¥§¥Ã¥ÁÆâÍƤòÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤Ï¤Ê¤¯ÇÛÎó¤ËÆþ¤ì¤ë¤Ë¤Ï: @result = @{ $dbh->selectall_arrayref($sql, { Slice => {} }) }; =begin original See L method for more details. =end original ¹¹¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¥á¥½¥Ã¥É¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $hash_ref = $dbh->selectall_hashref($statement, $key_field); $hash_ref = $dbh->selectall_hashref($statement, $key_field, \%attr); $hash_ref = $dbh->selectall_hashref($statement, $key_field, \%attr, @bind_values); =begin original This utility method combines L, L and L into a single call. It returns a reference to a hash containing one entry, at most, for each row, as returned by fetchall_hashref(). =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥á¥½¥Ã¥É¤Ï¡¢L¡¢L¡¢¤ª¤è¤ÓL¤ò1²ó¤Î¸Æ¤Ó½Ð¤·¤Ë·ë¹ç¤·¤Þ¤¹¡£ fetchall_hashref()¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¤è¤¦¤Ë¡¢³Æ¹Ô¤ËÂФ·¤ÆºÇÂç1¤Ä¤Î¥¨¥ó¥È¥ê¤ò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. This is recommended if the statement is going to be executed many times. =end original C<$statement> ¥Ñ¥é¥á¡¼¥¿¤ò´û¤Ë prepare ¤µ¤ì¤Æ¤¤¤ëʸ¥Ï¥ó¥É¥ë¤Ë ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹; ¤½¤Î¾ì¹ç¡¢C ¤ÏÈô¤Ð¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï²¿²ó¤âʸ¤¬¼Â¹Ô¤¹¤ëͽÄê¤Ç¤¢¤ì¤Ð¤ª´«¤á¤Ç¤¹¡£ =begin original The C<$key_field> parameter defines which column, or columns, are used as keys in the returned hash. It can either be the name of a single field, or a reference to an array containing multiple field names. Using multiple names yields a tree of nested hashes. =end original C<$key_field>¥Ñ¥é¥á¡¼¥¿¤Ï¡¢ÊÖ¤µ¤ì¤ë¥Ï¥Ã¥·¥å¤Ç¥­¡¼¤È¤·¤Æ»ÈÍѤµ¤ì¤ëÎó¤òÄêµÁ¤·¤Þ¤¹¡£ ñ°ì¤Î¥Õ¥£¡¼¥ë¥É¤Î̾Á°¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥£¡¼¥ë¥É̾¤ò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ Ê£¿ô¤Î̾Á°¤ò»ÈÍѤ¹¤ë¤È¡¢¥Í¥¹¥È¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤Î¥Ä¥ê¡¼¤¬À¸À®¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If a row has the same key as an earlier row then it replaces the earlier row. =end original ¹Ô¤¬°ÊÁ°¤Î¹Ô¤ÈƱ¤¸¥­¡¼¤Î¾ì¹ç¡¢°ÊÁ°¤Î¹Ô¤ÏÃÖ¤­´¹¤¨¤é¤ì¤Þ¤¹¡£ =begin original If any method except C fails, and L is not set, C will return C. If C fails and L is not set, then it will return with whatever data it has fetched thus far. $DBI::err should be checked to catch that. =end original C °Ê³°¤Î¤¤¤º¤ì¤«¤Î¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤È¤Ê¤ê¡¢ L ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢C ¤Ï C¤òÊÖ¤·¤Þ¤¹¡£ ¤â¤· C ¤¬¼ºÇÔ¤·¡¢L ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢ ¤½¤ì¤Þ¤Ç¤Ë¼è¤ê½Ð¤·¤¿¥Ç¡¼¥¿¤ò¤Ê¤ë¤Ù¤¯Â¿¤¯ÊÖ¤·¤Þ¤¹¡£ ¤½¤ì¤òÊá¤é¤¨¤ë¤¿¤á¤Ë $DBI::err ¤ò¥Á¥§¥Ã¥¯¤¹¤Ù¤­¤Ç¤¹¡£ =begin original See fetchall_hashref() for more details. =end original ¤µ¤é¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï fetchall_hashref() ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $ary_ref = $dbh->selectcol_arrayref($statement); $ary_ref = $dbh->selectcol_arrayref($statement, \%attr); $ary_ref = $dbh->selectcol_arrayref($statement, \%attr, @bind_values); =begin original This utility method combines L, L, and fetching one column from all the rows, into a single call. It returns a reference to an array containing the values of the first column from each row. =end original ¤³¤Î¥æ¡¼¥Æ¥£¥ê¥Æ¥£¡¼¥á¥½¥Ã¥É¤Ï¡¢°ì²ó¤Ë L, L ¤ò ¤Þ¤È¤á¤Æ¤ª¤³¤Ê¤¤¡¢¤¹¤Ù¤Æ¤Î¹Ô¤«¤é°ì¤Ä¤Î¥«¥é¥à¤«¤é¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£ ³Æ¹Ô¤«¤é¤ÎºÇ½é¤Î¥«¥é¥à¤ÎÃͤ¬Æþ¤Ã¤¿ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original The C<$statement> parameter can be a previously prepared statement handle, in which case the C is skipped. This is recommended if the statement is going to be executed many times. =end original C<$statement> ¥Ñ¥é¥á¡¼¥¿¤ò´û¤Ë prepare ¤µ¤ì¤Æ¤¤¤ëʸ¥Ï¥ó¥É¥ë¤Ë ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹; ¤½¤Î¾ì¹ç¡¢C ¤ÏÈô¤Ð¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï²¿²ó¤âʸ¤¬¼Â¹Ô¤¹¤ëͽÄê¤Ç¤¢¤ì¤Ð¤ª´«¤á¤Ç¤¹¡£ =begin original If any method except C fails, and L is not set, C will return C. If C fails and L is not set, then it will return with whatever data it has fetched thus far. $DBI::err should be checked to catch that. =end original C °Ê³°¤Î¤¤¤º¤ì¤«¤Î¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤È¤Ê¤ê¡¢L ¤¬ ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢C ¤Ï C ¤òÊÖ¤·¤Þ¤¹¡£ ¤â¤· C ¤¬¼ºÇÔ¤·¡¢C ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤½¤ì¤Þ¤Ç¤Ë ¼è¤ê½Ð¤·¤¿¥Ç¡¼¥¿¤ò¤Ê¤ë¤Ù¤¯Â¿¤¯ÊÖ¤·¤Þ¤¹¡£ ¤½¤ì¤òÊá¤é¤¨¤ë¤¿¤á¤Ë $DBI::err ¤ò¥Á¥§¥Ã¥¯¤¹¤Ù¤­¤Ç¤¹¡£ =begin original The C method defaults to pushing a single column value (the first) from each row into the result array. However, it can also push another column, or even multiple columns per row, into the result array. This behaviour can be specified via a 'C' attribute which must be a ref to an array containing the column number or numbers to use. For example: =end original C¥á¥½¥Ã¥É¤Î¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢³Æ¹Ô¤Îñ°ì¤ÎÎóÃÍ(ºÇ½é)¤¬·ë²ÌÇÛÎó¤Ë¥×¥Ã¥·¥å¤µ¤ì¤Þ¤¹¡£ ¤¿¤À¤·¡¢Ê̤ÎÎ󡢤ޤ¿¤Ï¹Ô¤´¤È¤ËÊ£¿ô¤ÎÎó¤ò·ë²ÌÇÛÎó¤Ë¥×¥Ã¥·¥å¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¤³¤ÎÆ°ºî¤Ï¡¢'C'°À­¤ò²ð¤·¤Æ»ØÄê¤Ç¤­¤Þ¤¹¡£ ¤³¤Î°À­¤Ï¡¢»ÈÍѤ¹¤ëÎóÈÖ¹æ¤ò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) # get array of id and name pairs: my $ary_ref = $dbh->selectcol_arrayref("select id, name from table", { Columns=>[1,2] }); my %hash = @$ary_ref; # build hash from key-value pairs so $hash{$id} => name =begin original You can specify a maximum number of rows to fetch by including a 'C' attribute in \%attr. =end original ºÇÂç¥Õ¥§¥Ã¥Á¹Ô¿ô¤Ï \%attr ¤Î 'C' °À­¤Ç»ØÄê¤Ç¤­¤Þ¤¹¡£ =head3 C $sth = $dbh->prepare($statement) or die $dbh->errstr; $sth = $dbh->prepare($statement, \%attr) or die $dbh->errstr; =begin original Prepares a statement for later execution by the database engine and returns a reference to a statement handle object. =end original °ì¤Ä¤Îʸ¤ò¸å¤Ç¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ë¤è¤Ã¤Æ¼Â¹Ô¤Ç¤­¤ë¤è¤¦¤Ë½àÈ÷¤·¡¢ ʸ¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original The returned statement handle can be used to get attributes of the statement and invoke the L method. See L. =end original ÊÖ¤µ¤ì¤ëʸ¥Ï¥ó¥É¥ë¤Ïʸ¤Î°À­¤ò¼èÆÀ¤·¤¿¤ê¡¢ L ¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·¤Ë»È¤ï¤ì¤Þ¤¹¡£ L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original Drivers for engines without the concept of preparing a statement will typically just store the statement in the returned handle and process it when C<$sth-Eexecute> is called. Such drivers are unlikely to give much useful information about the statement, such as C<$sth-E{NUM_OF_FIELDS}>, until after C<$sth-Eexecute> has been called. Portable applications should take this into account. =end original ½àÈ÷¤µ¤ì¤¿Ê¸¤È¤¤¤¦¹Í¤¨¤¬Ìµ¤¤¥É¥é¥¤¥Ð¤Ç¤Ï¡¢Ä̾ÊÖ¤µ¤ì¤ë ¥Ï¥ó¥É¥ë¤Ëʸ¤òÊݸ¤·¡¢C<$sth-Eexecute> ¤¬¸Æ¤Ð¤ì¤¿¤é¤½¤ì¤ò ½èÍý¤·¤Þ¤¹¡£ ¤½¤Î¤è¤¦¤Ê¥É¥é¥¤¥Ð¤Ï C<$sth-E{NUM_OF_FIELDS}> ¤Î¤è¤¦¤Ê ʸ¤Ë¤Ä¤¤¤ÆÍ­¸ú¤Ê¾ðÊó¤ò C<$sth-Eexecute> ¤¬¸Æ¤Ð¤ì¤ë¤Þ¤Ç¤Ï¡¢ ¼èÆÀ¤Ç¤­¤ë¤³¤È¤Ï¤Þ¤º¤¢¤ê¤Þ¤»¤ó¡£ °Ü¿¢²Äǽ¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ÎÅÀ¤òÃí°Õ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ =begin original In general, DBI drivers do not parse the contents of the statement (other than simply counting any L). The statement is passed directly to the database engine, sometimes known as pass-thru mode. This has advantages and disadvantages. On the plus side, you can access all the functionality of the engine being used. On the downside, you're limited if you're using a simple engine, and you need to take extra care if writing applications intended to be portable between engines. =end original Ä̾DBI¥É¥é¥¤¥Ð¤Ïʸ¤ò²òÀϤ·¤Þ¤»¤ó (¤½¤¦¤Ç¤Ê¤±¤ì¤Ðñ½ã¤Ë¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò¿ô¤¨¤Þ¤¹)¡£ ʸ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥¨¥ó¥¸¥ó¤ËľÀÜÅϤµ¤ì¤Þ¤¹¡¢¤¤¤ï¤æ¤ë¥Ñ¥¹¥¹¥ë¡¼ ¥â¡¼¥É¤Ç¤¹¡£ ¤³¤ì¤ÏĹ½ê¤Ç¤âû½ê¤Ç¤â¤¢¤ê¤Þ¤¹¡£ ¤è¤¯¸À¤¨¤Ð¡¢»È¤ï¤ì¤Æ¤¤¤ë¥¨¥ó¥¸¥ó¤Î¤¹¤Ù¤Æ¤Îµ¡Ç½¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ °­¤¯¸À¤¨¤Ð¡¢´Êñ¤Ê¥¨¥ó¥¸¥ó¤ò»È¤Ã¤Æ¤¤¤ì¤ÐÀ©¸Â¤µ¤ì¤Þ¤¹¤·¡¢¥¨¥ó¥¸¥ó¤ò¤Þ¤¿¤¬¤Ã¤Æ °Ü¿¢²Äǽ¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½ñ¤³¤¦¤È¤¹¤ì¤Ð¡¢Èó¾ï¤ËÃí°Õ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ =begin original Portable applications should not assume that a new statement can be prepared and/or executed while still fetching results from a previous statement. =end original °Ü¿¢²Äǽ¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¤Þ¤ÀÁ°¤Îʸ¤«¤é·ë²Ì¤ò ¼è¤ê½Ð¤·¤Æ¤¤¤ë´Ö¤Ë¡¢¿·¤·¤¤Ê¸¤¬ prepare ¤Ç¤­¡¢¤½¤·¤Æ/¤¢¤ë¤¤¤Ï ¼Â¹Ô¤Ç¤­¤ë¤ÈÁÛÄꤹ¤ë¤Ù¤­¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ =begin original Some command-line SQL tools use statement terminators, like a semicolon, to indicate the end of a statement. Such terminators should not normally be used with the DBI. =end original ¤¤¤¯¤Ä¤«¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó·¿ SQL ¥Ä¡¼¥ë¤Ï¡¢¥»¥ß¥³¥í¥ó¤Ê¤É¤Î¥¹¥Æ¡¼¥¿¥¹¤Î½ª¤ï¤ê¤ò ¼¨¤¹¤¿¤á¤Ë¡¢Ê¸ËöÈøʸ»ú(statement terminator)¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ Ä̾綠¤¦¤·¤¿ËöÈøʸ»ú¤ò DBI ¤Ç»È¤ï¤ì¤Þ¤»¤ó¡£ =head3 C $sth = $dbh->prepare_cached($statement) $sth = $dbh->prepare_cached($statement, \%attr) $sth = $dbh->prepare_cached($statement, \%attr, $if_active) =begin original Like L except that the statement handle returned will be stored in a hash associated with the C<$dbh>. If another call is made to C with the same C<$statement> and C<%attr> parameter values, then the corresponding cached C<$sth> will be returned without contacting the database server. =end original C<$dbh> ¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Ï¥Ã¥·¥å¤ËÊݸ¤µ¤ì¤ë¤³¤È¤ò½ü¤¤¤Æ L ¤È ƱÍͤǤ¹¡£ ¤â¤·Æ±¤¸ C<$statement> ¤È C<%attr> ¥Ñ¥é¥á¡¼¥¿¤ÎÃͤǤǤ⤦°ìÅÙ C ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤Ë ¥³¥ó¥¿¥¯¥È¤¹¤ë¤³¤È¤Ê¤¯¡¢Âбþ¤¹¤ë C<$sth> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original The C<$if_active> parameter lets you adjust the behaviour if an already cached statement handle is still Active. There are several alternatives: =end original C<$if_active>¥Ñ¥é¥á¡¼¥¿¤ò»ÈÍѤ¹¤ë¤È¡¢¤¹¤Ç¤Ë¥­¥ã¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤ë¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤¬¤Þ¤À¥¢¥¯¥Æ¥£¥Ö¤Ç¤¢¤ë¾ì¹ç¤ÎÆ°ºî¤òÄ´À°¤Ç¤­¤Þ¤¹¡£ ¤¤¤¯¤Ä¤«¤ÎÁªÂò»è¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =over 4 =item B<0>: A warning will be generated, and finish() will be called on the statement handle before it is returned. This is the default behaviour if $if_active is not passed. =item B<1>: finish() will be called on the statement handle, but the warning is suppressed. =item B<2>: Disables any checking. =item B<3>: The existing active statement handle will be removed from the cache and a new statement handle prepared and cached in its place. This is the safest option because it doesn't affect the state of the old handle, it just removes it from the cache. [Added in DBI 1.40] =back =begin original Here are some examples of C: =end original °Ê²¼¤Ï C ¤ÎÎã¤Ç¤¹: sub insert_hash { my ($table, $field_values) = @_; # sort to keep field order, and thus sql, stable for prepare_cached my @fields = sort keys %$field_values; my @values = @{$field_values}{@fields}; my $sql = sprintf "insert into %s (%s) values (%s)", $table, join(",", @fields), join(",", ("?")x@fields); my $sth = $dbh->prepare_cached($sql); return $sth->execute(@values); } sub search_hash { my ($table, $field_values) = @_; # sort to keep field order, and thus sql, stable for prepare_cached my @fields = sort keys %$field_values; my @values = @{$field_values}{@fields}; my $qualifier = ""; $qualifier = "where ".join(" and ", map { "$_=?" } @fields) if @fields; $sth = $dbh->prepare_cached("SELECT * FROM $table $qualifier"); return $dbh->selectall_arrayref($sth, {}, @values); } =begin original I This caching can be useful in some applications, but it can also cause problems and should be used with care. Here is a contrived case where caching would cause a significant problem: =end original I¤³¤Î¥­¥ã¥Ã¥·¥å¤Ï¡¢°ìÉô¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤ÏÊØÍø¤Ç¤¹¤¬¡¢ÌäÂê¤ò°ú¤­µ¯¤³¤¹²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢Ãí°Õ¤·¤Æ»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¥­¥ã¥Ã¥·¥å¤¬½ÅÂç¤ÊÌäÂê¤ò°ú¤­µ¯¤³¤¹¾ì¹ç¤ò¹Í¤¨¤Æ¤ß¤Þ¤·¤ç¤¦¡£ (TBR) my $sth = $dbh->prepare_cached('SELECT * FROM foo WHERE bar=?'); $sth->execute(...); while (my $data = $sth->fetchrow_hashref) { # later, in some other code called within the loop... my $sth2 = $dbh->prepare_cached('SELECT * FROM foo WHERE bar=?'); $sth2->execute(...); while (my $data2 = $sth2->fetchrow_arrayref) { do_stuff(...); } } =begin original In this example, since both handles are preparing the exact same statement, C<$sth2> will not be its own statement handle, but a duplicate of C<$sth> returned from the cache. The results will certainly not be what you expect. Typically the inner fetch loop will work normally, fetching all the records and terminating when there are no more, but now that $sth is the same as $sth2 the outer fetch loop will also terminate. =end original ¤³¤ÎÎã¤Ç¤Ï¡¢Î¾Êý¤Î¥Ï¥ó¥É¥ë¤¬¤Þ¤Ã¤¿¤¯Æ±¤¸¥¹¥Æ¡¼¥È¥á¥ó¥È¤ò½àÈ÷¤·¤Æ¤¤¤ë¤¿¤á¡¢C<$sth2>¤Ï¤½¤ì¼«ÂΤΥ¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Ç¤Ï¤Ê¤¯¡¢¥­¥ã¥Ã¥·¥å¤«¤éÊÖ¤µ¤ì¤¿C<$sth>¤ÎÊ£À½¤Ë¤Ê¤ê¤Þ¤¹¡£ ·ë²Ì¤Ï´üÂÔ¤·¤¿¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ Ä̾Æ⦤Υե§¥Ã¥Á¥ë¡¼¥×¤ÏÀµ¾ï¤ËÆ°ºî¤·¡¢¤¹¤Ù¤Æ¤Î¥ì¥³¡¼¥É¤ò¥Õ¥§¥Ã¥Á¤·¡¢¤½¤ì°Ê¾å¥ì¥³¡¼¥É¤¬¤Ê¤¤¤È¤­¤Ë½ªÎ»¤·¤Þ¤¹¤¬¡¢$sth¤¬$sth2¤ÈƱ¤¸¤Ë¤Ê¤Ã¤¿¤Î¤Ç¡¢³°Â¦¤Î¥Õ¥§¥Ã¥Á¥ë¡¼¥×¤â½ªÎ»¤·¤Þ¤¹¡£ (TBR) =begin original You'll know if you run into this problem because prepare_cached() will generate a warning by default (when $if_active is false). =end original prepare_cached()¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç($if_active¤¬false¤Î¾ì¹ç)·Ù¹ð¤òÀ¸À®¤¹¤ë¤Î¤Ç¡¢¤³¤ÎÌäÂ꤬ȯÀ¸¤·¤¿¾ì¹ç¤Ï¤¹¤°¤Ë¤ï¤«¤ê¤Þ¤¹¡£ (TBR) =begin original The cache used by prepare_cached() is keyed by both the statement and any attributes so you can also avoid this issue by doing something like: =end original prepare_cached()¤Ç»ÈÍѤµ¤ì¤ë¥­¥ã¥Ã¥·¥å¤Ï¡¢Ê¸¤È°À­¤ÎξÊý¤Ë¤è¤Ã¤Æ¥­¡¼ÀßÄꤵ¤ì¤ë¤¿¤á¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Æ¤³¤ÎÌäÂê¤ò²óÈò¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ (TBR) $sth = $dbh->prepare_cached("...", { dbi_dummy => __FILE__.__LINE__ }); =begin original which will ensure that prepare_cached only returns statements cached by that line of code in that source file. =end original ¤³¤ì¤Ë¤è¤ê¡¢prepare_cached¤Ï¡¢¤½¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ëÆâ¤Î¤½¤Î¥³¡¼¥É¹Ô¤Ë¤è¤Ã¤Æ¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î¤ß¤òÊÖ¤¹¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original If you'd like the cache to managed intelligently, you can tie the hashref returned by C to an appropriate caching module, such as L: =end original ¥­¥ã¥Ã¥·¥å¤ò¥¤¥ó¥Æ¥ê¥¸¥§¥ó¥È¤Ë´ÉÍý¤·¤¿¤¤¾ì¹ç¤Ï¡¢C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ëhashref¤ò¡¢L¤Î¤è¤¦¤ÊŬÀڤʥ­¥ã¥Ã¥·¥å¥â¥¸¥å¡¼¥ë¤Ë·ë¤ÓÉÕ¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) my $cache; tie %$cache, 'Tie::Cache::LRU', 500; $dbh->{CachedKids} = $cache; =head3 C $rc = $dbh->commit or die $dbh->errstr; =begin original Commit (make permanent) the most recent series of database changes if the database supports transactions and AutoCommit is off. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Æ AutoCommit ¤¬¥ª¥Õ¤Ç¤¢¤ì¤Ð¡¢ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂФ¹¤ëľ¶á¤Î°ìÏ¢¤ÎÊѹ¹¤ò¥³¥ß¥Ã¥È(±Ê³²½)¤·¤Þ¤¹¡£ =begin original If C is on, then calling C will issue a "commit ineffective with AutoCommit" warning. =end original C ¤¬¥ª¥ó¤Ç¤¢¤ì¤Ð¡¢C ¤Ï "commit ineffective with AutoCommit" ¤È¤¤¤¦·Ù¹ð¤òµ¯¤³¤·¤Þ¤¹¡£ =begin original See also L in the L section below. =end original ¸å½Ò¤¹¤ë L ¾Ï¤Î L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $rc = $dbh->rollback or die $dbh->errstr; =begin original Rollback (undo) the most recent series of uncommitted database changes if the database supports transactions and AutoCommit is off. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Æ¡¢AutoCommit ¤¬¥ª¥Õ¤Ç¤¢¤ì¤Ð¡¢ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂФ¹¤ëľ¶á¤Î°ìÏ¢¤ÎÊѹ¹¤ò¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤Þ¤¹(¸µ¤ËÌᤷ¤Þ¤¹)¡£ =begin original If C is on, then calling C will issue a "rollback ineffective with AutoCommit" warning. =end original C ¤¬¥ª¥ó¤Ç¤¢¤ì¤Ð¡¢C ¤Ï "rollback ineffective with AutoCommit" ¤È¤¤¤¦·Ù¹ð¤òµ¯¤³¤·¤Þ¤¹¡£ =begin original See also L in the L section below. =end original ¸å½Ò¤¹¤ë L ¾Ï¤Î L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $rc = $dbh->begin_work or die $dbh->errstr; =begin original Enable transactions (by turning C off) until the next call to C or C. After the next C or C, C will automatically be turned on again. =end original ¼¡¤ËC¤Þ¤¿¤ÏC¤ò¸Æ¤Ó½Ð¤¹¤Þ¤Ç¡¢(C¤ò¥ª¥Õ¤Ë¤·¤Æ)¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÍ­¸ú¤Ë¤·¤Þ¤¹¡£ ¼¡¤ÎC¤Þ¤¿¤ÏC¤Î¸å¡¢C¤Ï¼«Æ°Åª¤ËºÆ¤Ó¥ª¥ó¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original If C is already off when C is called then it does nothing except return an error. If the driver does not support transactions then when C attempts to set C off the driver will trigger a fatal error. =end original C¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤­¤ËC¤¬¤¹¤Ç¤Ë¥ª¥Õ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¥¨¥é¡¼¤òÊÖ¤¹°Ê³°¤Ï²¿¤â¤·¤Þ¤»¤ó¡£ ¥É¥é¥¤¥Ð¤¬¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢C¤¬C¤ò¥ª¥Õ¤ËÀßÄꤷ¤è¤¦¤È¤¹¤ë¤È¡¢¥É¥é¥¤¥Ð¤ÏÃ×̿Ū¤Ê¥¨¥é¡¼¤ò¥È¥ê¥¬¤·¤Þ¤¹¡£ (TBR) =begin original See also L in the L section below. =end original ¸å½Ò¤¹¤ë L ¾Ï¤Î L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $rc = $dbh->disconnect or warn $dbh->errstr; =begin original Disconnects the database from the database handle. C is typically only used before exiting the program. The handle is of little use after disconnecting. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤éÀÚÃǤ·¤Þ¤¹¡£ C ¤ÏÉáÄÌ¥×¥í¥°¥é¥à¤ò½ªÎ»¤¹¤ë¤È¤­¤Ë¤À¤±»È¤¤¤Þ¤¹¡£ ÀÚÃǤ·¤¿¸å¡¢¥Ï¥ó¥É¥ë¤Û¤È¤ó¤ÉÌò¤ËΩ¤Á¤Þ¤»¤ó¡£ =begin original The transaction behaviour of the C method is, sadly, undefined. Some database systems (such as Oracle and Ingres) will automatically commit any outstanding changes, but others (such as Informix) will rollback any outstanding changes. Applications not using C should explicitly call C or C before calling C. =end original »ÄÇ°¤Ê¤¬¤é C ¥á¥½¥Ã¥É¤Ë¤è¤ê¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¤É¤¦¤Ê¤ë¤«¤Ï ·è¤Þ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£ ¤¢¤ë¼ï¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥·¥¹¥Æ¥à(Oracle¡¢Ingress¤Ê¤É)¤Ï¼«Æ°Åª¤ËÊѹ¹¤ò ¥³¥ß¥Ã¥È¤·¤Þ¤¹¤¬¡¢(Infromix¤Ê¤É)Êѹ¹¤ò¥í¡¼¥ë¥Ð¥Ã¥¯¤¹¤ë¤â¤Î¤â¤¢¤ê¤Þ¤¹¡£ C ¤ò»È¤ï¤Ê¤¤¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï C ¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë¡¢ ÌÀ³Î¤Ë C ¤Þ¤¿¤Ï C ¤ò¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¹¡£ =begin original The database is automatically disconnected by the C method if still connected when there are no longer any references to the handle. The C method for each driver should implicitly call C to undo any uncommitted changes. This is vital behaviour to ensure that incomplete transactions don't get committed simply because Perl calls C on every object before exiting. Also, do not rely on the order of object destruction during "global destruction", as it is undefined. =end original ¤Þ¤ÀÀܳ¤·¤Æ¤¤¤Æ¡¢¥Ï¥ó¥É¥ë¤Ø¤Î»²¾È¤¬¤Þ¤Ã¤¿¤¯¤Ê¤¯¤Ê¤Ã¤¿¾ì¹ç¡¢ C ¥á¥½¥Ã¥É¤Ë¤è¤ê¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¼«Æ°Åª¤ËÀÚÃǤµ¤ì¤Þ¤¹¡£ ³Æ¥É¥é¥¤¥Ð¤Ø¤Î C ¥á¥½¥Ã¥É¤Ï¥³¥ß¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤Êѹ¹¤ò¸µ¤ËÌ᤹¤¿¤á¡¢ °ÅÌۤΤ¦¤Á¤Ë C ¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ ¤³¤ì¤Ï½ªÎ»¤¹¤ëÁ°¤Ë Perl ¤¬Ã±¤Ë³Æ¥ª¥Ö¥¸¥§¥¯¥È¤Ë C ¤ò ¸Æ¤Ó½Ð¤¹¤³¤È¤Ë¤è¤Ã¤Æ¡¢ÉÔ´°Á´¤Ê¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬¥³¥ß¥Ã¥È¤µ¤ì¤Ê¤¤¤È¤¤¤¦¤³¤È¤ò Êݾڤ¹¤ë¤¿¤á¤Ë¤­¤ï¤á¤Æ½ÅÍפǤ¹¡£ ƱÍͤˡ֥°¥í¡¼¥Ð¥ë¤ÊÇ˲õ¡×¤Ç¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇ˲õ¤Î½ç½ø¤Ï¿®Íê¤Ç¤­¤Þ¤»¤ó; ¤³¤ì¤Ï̤ÄêµÁ¤Ç¤¹¡£ =begin original Generally, if you want your changes to be committed or rolled back when you disconnect, then you should explicitly call L or L before disconnecting. =end original °ìÈÌŪ¤Ë¡¢ÀÚÃǤ¹¤ëÁ°¤ËÊѹ¹¤ò¥³¥ß¥Ã¥È¤Þ¤¿¤Ï¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤¿¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢ ÀÚÃǤ¹¤ëÁ°¤ËÌÀ¼¨Åª¤Ë L ¤Þ¤¿¤Ï L ¤ò¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¹¡£ =begin original If you disconnect from a database while you still have active statement handles (e.g., SELECT statement handles that may have more data to fetch), you will get a warning. The warning may indicate that a fetch loop terminated early, perhaps due to an uncaught error. To avoid the warning call the C method on the active handles. =end original Active ¤Êʸ¥Ï¥ó¥É¥ë(¤Ä¤Þ¤ê¡¢¤Þ¤À¥Õ¥§¥Ã¥Á¤¹¤ë¥Ç¡¼¥¿¤¬¤¢¤ë SELECT ʸ ¥Ï¥ó¥É¥ë)¤¬¤¢¤ë¤Î¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤éÀÚÃǤ¹¤ë¤È·Ù¹ð¤ò¼õ¤±¤Þ¤¹¡£ ·Ù¹ð¤Ï¥Õ¥§¥Ã¥Á¥ë¡¼¥×¤¬Á᤯½ª¤ï¤Ã¤Æ¤·¤Þ¤Ã¤¿¤³¤È¤ò¼¨¤·¤Æ¤¤¤Æ¡¢¤ª¤½¤é¤¯¤Ï Ê᪤·¤Æ¤¤¤Ê¤¤¥¨¥é¡¼¤Ë¤è¤ë¤â¤Î¤Ç¤¹¡£ ·Ù¹ð¤òÈò¤±¤ë¤Ë¤Ï¡¢¥¢¥¯¥Æ¥£¥Ö¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ C ¥á¥½¥Ã¥É¤ò ¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ =head3 C $rc = $dbh->ping; =begin original Attempts to determine, in a reasonably efficient way, if the database server is still running and the connection to it is still working. Individual drivers should implement this function in the most suitable manner for their database engine. =end original ¹çÍýŪ¤Ç¸úΨŪ¤ÊÊýË¡¤Ç¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¡¼¤¬²ÔÆ°¤·¤Æ¤¤¤ë¤«¡¢Àܳ¤¬ Æ°¤¤¤Æ¤¤¤ë¤«¤òȽÄꤷ¤è¤¦¤È¤·¤Þ¤¹¡£³Æ¥É¥é¥¤¥Ð¤Ï¤³¤Î´Ø¿ô¤ò¤½¤ì¤¾¤ì¤Î ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËºÇ¤âŬÀÚ¤ÊÊýË¡¤Ç¼ÂÁõ¤¹¤ë¤Ù¤­¤Ç¤¹¡£ =begin original The current I implementation always returns true without actually doing anything. Actually, it returns "C<0 but true>" which is true but zero. That way you can tell if the return value is genuine or just the default. Drivers should override this method with one that does the right thing for their type of database. =end original ¸½ºß¤Î I<¥Ç¥Õ¥©¥ë¥È¤Î> ¼ÂÁõ¤Ï¡¢¼ÂºÝ¤Ë¤Ï²¿¤â¤»¤º¾ï¤Ë¿¿¤òÊÖ¤·¤Þ¤¹¡£ ¼ÂºÝ¤Ë¤Ï¡¢¤½¤ì¤Ï¡ÖC<0 ¤À¤¬¿¿>¡×¤òÊÖ¤·¤Þ¤¹; ¤³¤ì¤Ï¿¿¤Ç¤¹¤¬ 0 ¤Ç¤¹¡£ ¤³¤ì¤Ë¤è¤êÊÖ¤µ¤ì¤¿Ãͤ¬ËÜʪ¤Ê¤Î¤«Ã±¤Ê¤ë¥Ç¥Õ¥©¥ë¥È¤Ê¤Î¤«¤¬¤ï¤«¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¿¥¤¥×¤Ë¤¢¤Ã¤¿¤â¤Î¤Ç¤³¤Î¥á¥½¥Ã¥É¤ò ¾å½ñ¤­¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original Few applications would have direct use for this method. See the specialized Apache::DBI module for one example usage. =end original ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤³¤Î¥á¥½¥Ã¥É¤ò»È¤¦¤³¤È¤Ï¤¢¤Þ¤ê¤Ê¤¤¤Ç¤·¤ç¤¦¡£ »ÈÍÑÎã¤È¤·¤Æ¤ÏÀìÌçŪ¤Ê Apache::DBI ¥â¥¸¥å¡¼¥ë¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C $value = $dbh->get_info( $info_type ); =begin original Returns information about the implementation, i.e. driver and data source capabilities, restrictions etc. It returns C for unknown or unimplemented information types. For example: =end original ¼ÂÁõ¤Ë´Ø¤¹¤ë¾ðÊó(¥É¥é¥¤¥Ð¤ª¤è¤Ó¥Ç¡¼¥¿¥½¡¼¥¹¤Îµ¡Ç½¡¢À©¸Â¤Ê¤É)¤òÌᤷ¤Þ¤¹¡£ ÉÔÌÀ¤Þ¤¿¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ðÊ󥿥¤¥×¤Î¾ì¹ç¤Ï¡¢C¤òÌᤷ¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $database_version = $dbh->get_info( 18 ); # SQL_DBMS_VER $max_select_tables = $dbh->get_info( 106 ); # SQL_MAXIMUM_TABLES_IN_SELECT =begin original See L for more detailed information about the information types and their meanings and possible return values. =end original ¾ðÊ󷿤Ȥ½¤Î°ÕÌ£¤ª¤è¤Ó¤¢¤êÆÀ¤ëÊÖ¤êÃͤ˴ؤ¹¤ë¤µ¤é¤Ë¾Ü¤·¤¤¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The DBI::Const::GetInfoType module exports a %GetInfoType hash that can be used to map info type names to numbers. For example: =end original DBI::Const::GetInfoType ¥â¥¸¥å¡¼¥ë¤Ï¡¢·¿Ì¾¤ò¿ôÃͤ˥ޥåԥ󥰤¹¤ë¤¿¤á¤Ë »È¤¨¤ë %GetInfoType ¥Ï¥Ã¥·¥å¤ò¥¨¥¯¥¹¥Ý¡¼¥È¤·¤Þ¤¹¡£ Î㤨¤Ð: $database_version = $dbh->get_info( $GetInfoType{SQL_DBMS_VER} ); =begin original The names are a merging of the ANSI and ODBC standards (which differ in some cases). See L for more details. =end original ̾Á°¤Ï ANSI ¤È ODBC ¤Îɸ½à (°ìÉô¤Ç°Û¤Ê¤ê¤Þ¤¹) ¤ò¥Þ¡¼¥¸¤·¤¿¤â¤Î¤Ç¤¹¡£ ¤µ¤é¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Because some DBI methods make use of get_info(), drivers are strongly encouraged to support I the following very minimal set of information types to ensure the DBI itself works properly: =end original DBI¥á¥½¥Ã¥É¤ÎÃæ¤Ë¤Ïget_info()¤òÍøÍѤ¹¤ë¤â¤Î¤¬¤¢¤ë¤Î¤Ç¡¢DBI¼«ÂΤ¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤è¤¦¤Ë¡¢¥É¥é¥¤¥Ð¤Ï<¾¯¤Ê¤¯¤È¤â>°Ê²¼¤ÎºÇ¾®¸Â¤Î¾ðÊ󥿥¤¥×¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤³¤È¤ò¶¯¤¯¿ä¾©¤·¤Þ¤¹¡£ (TBR) Type Name Example A Example B ---- -------------------------- ------------ ---------------- 17 SQL_DBMS_NAME 'ACCESS' 'Oracle' 18 SQL_DBMS_VER '03.50.0000' '08.01.0721 ...' 29 SQL_IDENTIFIER_QUOTE_CHAR '`' '"' 41 SQL_CATALOG_NAME_SEPARATOR '.' '@' 114 SQL_CATALOG_LOCATION 1 2 =head3 C $sth = $dbh->table_info( $catalog, $schema, $table, $type ); $sth = $dbh->table_info( $catalog, $schema, $table, $type, \%attr ); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Returns an active statement handle that can be used to fetch information about tables and views that exist in the database. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¸ºß¤¹¤ë¥Æ¡¼¥Ö¥ë¤ä¥Ó¥å¡¼¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤ë Active ¤Êʸ¡¦¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ =begin original The arguments $catalog, $schema and $table may accept search patterns according to the database/driver, for example: $table = '%FOO%'; Remember that the underscore character ('C<_>') is a search pattern that means match any character, so 'FOO_%' is the same as 'FOO%' and 'FOO_BAR%' will match names like 'FOO1BAR'. =end original °ú¿ô $catalog, $schema, $table ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¿¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¸¡º÷ ¥Ñ¥¿¡¼¥ó¤ò¼õ¤±¼è¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ Î㤨¤Ð: $table = '%FOO%'; ²¼Àþʸ»ú ('C<_>') ¤ÏǤ°Õ¤Îʸ»ú¤ò°ÕÌ£¤¹¤ë¸¡º÷¥Ñ¥¿¡¼¥ó¤ò°ÕÌ£¤¹¤ë¤Î¤Ç¡¢ 'FOO_%' ¤Ï 'FOO%' ¤ÈƱ¤¸¤Ç¡¢'FOO_BAR%' ¤Ï 'FOO1BAR' ¤Î¤è¤¦¤Ê̾Á°¤Ë ¥Þ¥Ã¥Á¥ó¥°¤¹¤ë¤È¤¤¤¦¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The value of $type is a comma-separated list of one or more types of tables to be returned in the result set. Each value may optionally be quoted, e.g.: =end original $type ¤ÎÃͤϷë²Ì¥»¥Ã¥È¤ÇÊÖ¤µ¤ì¤ë¡¼¥Ö¥ë¤Î°ì¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Ç¡¼¥¿·¿¤Î¥«¥ó¥Þ ¶èÀÚ¤ê¤Î¥ê¥¹¥È¤Ç¤¹¡£ ¤½¤ì¤¾¤ì¤ÎÃͤϥª¥×¥·¥ç¥ó¤Ç¥¯¥©¡¼¥È¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó; Î㤨¤Ð: $type = "TABLE"; $type = "'TABLE','VIEW'"; =begin original In addition the following special cases may also be supported by some drivers: =end original ¤µ¤é¤Ë¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï°Ê²¼¤ÎÆüì¤Ê¥±¡¼¥¹¤â¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =over 4 =item * If the value of $catalog is '%' and $schema and $table name are empty strings, the result set contains a list of catalog names. For example: $sth = $dbh->table_info('%', '', ''); =item * If the value of $schema is '%' and $catalog and $table are empty strings, the result set contains a list of schema names. =item * If the value of $type is '%' and $catalog, $schema, and $table are all empty strings, the result set contains a list of table types. =back =begin original If your driver doesn't support one or more of the selection filter parameters then you may get back more than you asked for and can do the filtering yourself. =end original ¤ª»È¤¤¤Î¥É¥é¥¤¥Ð¤¬1¤Ä¤Þ¤¿¤ÏÊ£¿ô¤ÎÁªÂò¥Õ¥£¥ë¥¿¥Ñ¥é¥á¡¼¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢Í׵ᤷ¤¿¤è¤ê¤â¿¤¯¤Î¥Ñ¥é¥á¡¼¥¿¤¬ÊÖ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢¼«Ê¬¤Ç¥Õ¥£¥ë¥¿¥ê¥ó¥°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original This method can be expensive, and can return a large amount of data. (For example, small Oracle installation returns over 2000 rows.) So it's a good idea to use the filters to limit the data as much as possible. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï¥³¥¹¥È¤¬¤«¤«¤ê¡¢ÂçÎ̤Υǡ¼¥¿¤òÌ᤹²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹(¤¿¤È¤¨¤Ð¡¢¾®µ¬ÌϤÊOracle¥¤¥ó¥¹¥È¡¼¥ë¤Ç¤Ï¡¢2000¹Ô¤òĶ¤¨¤ë¹Ô¤¬Ìᤵ¤ì¤Þ¤¹)¡£ ¤½¤Î¤¿¤á¡¢¥Õ¥£¥ë¥¿¤ò»ÈÍѤ·¤Æ¥Ç¡¼¥¿¤ò²Äǽ¤Ê¸Â¤êÀ©¸Â¤¹¤ë¤³¤È¤ò¤ªÁ¦¤á¤·¤Þ¤¹¡£ (TBR) =begin original The statement handle returned has at least the following fields in the order show below. Other fields, after these, may also be present. =end original ÊÖ¤µ¤ì¤¿¹Ô¥Ï¥ó¥É¥ë¤Ï¾¯¤Ê¤¯¤È¤â¸å½Ò¤¹¤ë½ç½ø¤Ç°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤ò»ý¤Á¤Þ¤¹¡£ ¤³¤ì¤é¤Î¸å¤Ë¡¢Â¾¤Î¥Õ¥£¡¼¥ë¥É¤â¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original B: Table catalog identifier. This field is NULL (C) if not applicable to the data source, which is usually the case. This field is empty if not applicable to the table. =end original B: ¥Æ¡¼¥Ö¥ë¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤è¤¯¤¢¤ë¤³¤È¤Ç¤¹¤¬¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The name of the schema containing the TABLE_NAME value. This field is NULL (C) if not applicable to data source, and empty if not applicable to the table. =end original B: TABLE_NAMEÃͤ¬Æþ¤Ã¤Æ¤¤¤ë¥¹¥­¡¼¥Þ¤Î̾Á°¤Ç¤¹¡£ ¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: Name of the table (or view, synonym, etc). =end original B: ¥Æ¡¼¥Ö¥ë(¤Þ¤¿¤Ï¥Ó¥å¡¼¡¢¥·¥Î¥Ë¥à¤Ê¤É)¤Î̾Á°¡£ =begin original B: One of the following: "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM" or a type identifier that is specific to the data source. =end original B: TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM" ¤Þ¤¿¤Ï ¤½¤Î¥Ç¡¼¥¿¥½¡¼¥¹Æȼ«¤Î·¿¼±Ê̻ҤΤ¤¤º¤ì¤«¡£ =begin original B: A description of the table. May be NULL (C). =end original B: ¥Æ¡¼¥Ö¥ë¤ÎÀâÌÀ¡£NULL(C)¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original Note that C might not return records for all tables. Applications can use any valid table regardless of whether it's returned by C. =end original C ¤¬¤¹¤Ù¤Æ¤Î¥Æ¡¼¥Ö¥ë¤Ë¤Ä¤¤¤Æ¥ì¥³¡¼¥É¤òÊÖ¤µ¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¤³¤È¤Ë Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ C ¤Ë¤è¤êÊÖ¤µ¤ì¤¿¤«¤É¤¦¤«¤Ë´Ø·¸Ìµ¤¯¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤¹¤Ù¤Æ¤Î ŬÀµ¤Ê¥Æ¡¼¥Ö¥ë¤ò°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original See also L, L and L. =end original L, L, L ¤â »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $sth = $dbh->column_info( $catalog, $schema, $table, $column ); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Returns an active statement handle that can be used to fetch information about columns in specified tables. =end original »ØÄꤵ¤ì¤¿É½¤Î¹Ô¤Ë¤Ä¤¤¤Æ¾ðÊó¤òÆÀ¤ë¤¿¤á¤Ë»È¤¨¤ëÍ­¸ú¤Êʸ¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ =begin original The arguments $schema, $table and $column may accept search patterns according to the database/driver, for example: $table = '%FOO%'; =end original °ú¿ô $schema, $table, $column ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹/¥É¥é¥¤¥Ð¤Ë¤è¤ë¸¡º÷¥Ñ¥¿¡¼¥ó¤ò ¼õ¤±ÉÕ¤±¤Þ¤¹; Î㤨¤Ð: $table = '%FOO%'; =begin original Note: The support for the selection criteria is driver specific. If the driver doesn't support one or more of them then you may get back more than you asked for and can do the filtering yourself. =end original Ãí°Õ:ÁªÂò´ð½à¤Î¥µ¥Ý¡¼¥È¤Ï¥É¥é¥¤¥Ð¸ÇÍ­¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤¬1¤Ä°Ê¾å¤ÎÁªÂò´ð½à¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢Í׵ᤷ¤¿¤è¤ê¤â¿¤¯¤ÎÁªÂò´ð½à¤¬ÊÖ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢¼«Ê¬¤Ç¥Õ¥£¥ë¥¿¥ê¥ó¥°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original Note: If your driver does not support column_info an undef is returned. This is distinct from asking for something which does not exist in a driver which supports column_info as a valid statement handle to an empty result-set will be returned in this case. =end original Ãí°Õ:¥É¥é¥¤¥Ð¤¬column_info¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢undef¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢column_info¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥É¥é¥¤¥Ð¤Ë¸ºß¤·¤Ê¤¤¤â¤Î¤òÍ׵᤹¤ë¤³¤È¤È¤Ï°Û¤Ê¤ê¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢¶õ¤Î·ë²Ì¥»¥Ã¥È¤Ø¤ÎÍ­¸ú¤Ê¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If the arguments don't match any tables then you'll still get a statement handle, it'll just return no rows. =end original °ú¿ô¤¬¤É¤Îɽ¤Ë¤â¥Þ¥Ã¥Á¥ó¥°¤·¤Ê¤¤¾ì¹ç¡¢Ã±¤Ë²¿¤Î¹Ô¤âÊÖ¤µ¤Ê¤¤ ʸ¥Ï¥ó¥É¥ë¤¬ÆÀ¤é¤ì¤Þ¤¹¡£ =begin original The statement handle returned has at least the following fields in the order shown below. Other fields, after these, may also be present. =end original ÊÖ¤µ¤ì¤¿¹Ô¥Ï¥ó¥É¥ë¤Ï¾¯¤Ê¤¯¤È¤â¸å½Ò¤¹¤ë½ç½ø¤Ç°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤ò»ý¤Á¤Þ¤¹¡£ ¤³¤ì¤é¤Î¸å¤Ë¡¢Â¾¤Î¥Õ¥£¡¼¥ë¥É¤â¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original B: The catalog identifier. This field is NULL (C) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table. =end original B: ¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤è¤¯¤¢¤ë¤³¤È¤Ç¤¹¤¬¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The schema identifier. This field is NULL (C) if not applicable to the data source, and empty if not applicable to the table. =end original B: ¥¹¥­¡¼¥Þ¼±Ê̻ҡ£ ¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The table identifier. Note: A driver may provide column metadata not only for base tables, but also for derived objects like SYNONYMS etc. =end original B:ɽ¤Î¼±Ê̻ҡ£ Ãí°Õ:¥É¥é¥¤¥Ð¤Ï¡¢¼Âɽ¤ÎÎó¥á¥¿¥Ç¡¼¥¿¤Î¤ß¤Ç¤Ê¤¯¡¢SYNONYMS¤Ê¤É¤ÎƳ½Ð¥ª¥Ö¥¸¥§¥¯¥È¤ÎÎó¥á¥¿¥Ç¡¼¥¿¤âÄ󶡤Ǥ­¤Þ¤¹¡£ (TBR) =begin original B: The column identifier. =end original B: Îó¼±Ê̻ҡ£ =begin original B: The concise data type code. =end original B: ´Ê·é¤Ê¥Ç¡¼¥¿·¿¥³¡¼¥É¡£ =begin original B: A data source dependent data type name. =end original B: ¥Ç¡¼¥¿¥½¡¼¥¹°Í¸¤Î¥Ç¡¼¥¿·¿Ì¾¡£ =begin original B: The column size. This is the maximum length in characters for character data types, the number of digits or bits for numeric data types or the length in the representation of temporal types. See the relevant specifications for detailed information. =end original B:Îó¤Î¥µ¥¤¥º¡£ ¤³¤ì¤Ï¡¢Ê¸»ú¥Ç¡¼¥¿·¿¤Î¾ì¹ç¤ÏºÇÂçʸ»ú¿ô¡¢¿ôÃͥǡ¼¥¿·¿¤Î¾ì¹ç¤Ï·å¿ô¤Þ¤¿¤Ï¥Ó¥Ã¥È¿ô¡¢°ì»þ¥Ç¡¼¥¿·¿¤Î¾ì¹ç¤ÏŤµ¤Ç¤¹¡£ ¾ÜºÙ¤Ï¡¢´ØÏ¢¤¹¤ë»ÅÍͤò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original B: The length in bytes of transferred data. =end original B: žÁ÷¤µ¤ì¤¿¥Ç¡¼¥¿¤Î¥Ð¥¤¥È¿ô¡£ =begin original B: The total number of significant digits to the right of the decimal point. =end original B: ¾®¿ôÅÀ¤Î±¦Â¦¤ÎÍ­¸ú·å¿ô¡£ =begin original B: The radix for numeric precision. The value is 10 or 2 for numeric data types and NULL (C) if not applicable. =end original B:¿ôÃÍÀºÅ٤δð¿ô¡£ ¿ôÃͥǡ¼¥¿·¿¤Î¾ì¹ç¡¢ÃͤÏ10¤Þ¤¿¤Ï2¤Ç¤¹¡£ ³ºÅö¤·¤Ê¤¤¾ì¹ç¤Ï¡¢NULL(C)¤Ç¤¹¡£ (TBR) =begin original B: Indicates if a column can accept NULLs. The following values are defined: =end original B: Îó¤¬ NULL ¤ò¼õ¤±ÉÕ¤±¤ë¤«¤ò¼¨¤¹¡£ °Ê²¼¤ÎÃͤ¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹: SQL_NO_NULLS 0 SQL_NULLABLE 1 SQL_NULLABLE_UNKNOWN 2 =begin original B: A description of the column. =end original B: Îó¤ÎÀâÌÀ¡£ =begin original B: The default value of the column, in a format that can be used directly in an SQL statement. =end original B: SQL ¤ËľÀܻȤ¨¤ë·Á¤Ç¤Î¡¢Îó¤Î¥Ç¥Õ¥©¥ë¥ÈÃÍ¡£ =begin original Note that this may be an expression and not simply the text used for the default value in the original CREATE TABLE statement. For example, given: =end original ¤³¤ì¤Ï¼°¤Ë¤Ê¤Ã¤Æ¡¢¸µ¤Î CREATE TABLE ʸ¤Î¥Ç¥Õ¥©¥ë¥È¤È¤·¤Æ»È¤ï¤ì¤¿Ã±½ã¤Ê ¥Æ¥­¥¹¥È¤Ç¤Ï¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ Î㤨¤Ð¡¢°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤È: col1 char(30) default current_user -- a 'function' col2 char(30) default 'string' -- a string literal =begin original where "current_user" is the name of a function, the corresponding C values would be: =end original ¤³¤³¤Ç "current_user" ¤¬´Ø¿ô̾¤È¤¹¤ë¤È¡¢Âбþ¤¹¤ë C ¤ÎÃÍ¤Ï °Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: Database col1 col2 -------- ---- ---- Oracle: current_user 'string' Postgres: "current_user"() 'string'::text MS SQL: (user_name()) ('string') =begin original B: The SQL data type. =end original B: SQL ¥Ç¡¼¥¿·¿¡£ =begin original B: The subtype code for datetime and interval data types. =end original B: ÆüÉÕ»þ¹ï¤ÈÆâÉô¥Ç¡¼¥¿·¿¤Î¤¿¤á¤Î¥µ¥Ö·¿¥³¡¼¥É¡£ =begin original B: The maximum length in bytes of a character or binary data type column. =end original B: ʸ»ú¤ä¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿·¿Îó¤ÎºÇÂç¥Ð¥¤¥ÈĹ¡£ =begin original B: The column sequence number (starting with 1). =end original B: Îó¥·¡¼¥±¥ó¥¹ÈÖ¹æ (1 ¤«¤é³«»Ï)¡£ =begin original B: Indicates if the column can accept NULLs. Possible values are: 'NO', 'YES' and ''. =end original B: Îó¤¬ NULL ¤ò¼õ¤±ÉÕ¤±¤ë¤«¤ò¼¨¤¹¡£ ¼è¤êÆÀ¤ëÃͤÏ: 'NO', 'YES', ''. =begin original SQL/CLI defines the following additional columns: =end original SQL/CLI ¤Ï°Ê²¼¤ÎÄɲäÎÎó¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹: CHAR_SET_CAT CHAR_SET_SCHEM CHAR_SET_NAME COLLATION_CAT COLLATION_SCHEM COLLATION_NAME UDT_CAT UDT_SCHEM UDT_NAME DOMAIN_CAT DOMAIN_SCHEM DOMAIN_NAME SCOPE_CAT SCOPE_SCHEM SCOPE_NAME MAX_CARDINALITY DTD_IDENTIFIER IS_SELF_REF =begin original Drivers capable of supplying any of those values should do so in the corresponding column and supply undef values for the others. =end original ¤³¤ì¤é¤ÎÃͤΤ¤¤º¤ì¤«¤òÄ󶡤Ǥ­¤ë¥É¥é¥¤¥Ð¤Ï¡¢Âбþ¤¹¤ëÎó¤ÇÄ󶡤·¡¢Â¾¤ÎÃͤˤÏundefÃͤòÄ󶡤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original Drivers wishing to provide extra database/driver specific information should do so in extra columns beyond all those listed above, and use lowercase field names with the driver-specific prefix (i.e., 'ora_...'). Applications accessing such fields should do so by name and not by column number. =end original ÄɲäΥǡ¼¥¿¥Ù¡¼¥¹/¥É¥é¥¤¥Ð¸ÇÍ­¤Î¾ðÊó¤òÄ󶡤·¤¿¤¤¥É¥é¥¤¥Ð¤Ï¡¢¾åµ­¤Î¤¹¤Ù¤Æ¤ÎÎó¤Ë²Ã¤¨¤ÆÄɲäÎÎó¤òÄ󶡤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤Þ¤¿¡¢¥É¥é¥¤¥Ð¸ÇÍ­¤ÎÀÜƬ¼­('ora_...')¤òÉÕ¤±¤¿¾®Ê¸»ú¤Î¥Õ¥£¡¼¥ë¥É̾¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ê¥Õ¥£¡¼¥ë¥É¤Ë¥¢¥¯¥»¥¹¤¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢ÎóÈÖ¹æ¤Ç¤Ï¤Ê¤¯Ì¾Á°¤ÇÄ󶡤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The result set is ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION. =end original ·ë²Ì¥»¥Ã¥È¤Ï TABLE_CAT, TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION ¤Ç ¥½¡¼¥È¤µ¤ì¤Þ¤¹¡£ =begin original Note: There is some overlap with statement handle attributes (in perl) and SQLDescribeCol (in ODBC). However, SQLColumns provides more metadata. =end original Ãí°Õ: (perl ¤Ç¤Î)ʸ¥Ï¥ó¥É¥ë°À­¤È (ODBC ¤Ç¤Î) SQLDescribeCol ¤Ë¤Ï ½ÅÊ£¤¬¤¢¤ê¤Þ¤¹¡£ ¤·¤«¤·¡¢SQLDescribeCol ¤Ï¤µ¤é¤Ê¤ë¥á¥¿¥Ç¡¼¥¿¤òÄ󶡤·¤Þ¤¹¡£ =begin original See also L and L. =end original L ¤È L ¤â »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $sth = $dbh->primary_key_info( $catalog, $schema, $table ); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Returns an active statement handle that can be used to fetch information about columns that make up the primary key for a table. The arguments don't accept search patterns (unlike table_info()). =end original ¥Æ¡¼¥Ö¥ë¤Î¤¿¤á¤Î¼ç¥­¡¼¤È¤·¤ÆÀßÄꤵ¤ì¤Æ¤¤¤ë¥«¥é¥à¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò ¼è¤ê½Ð¤¹¤¿¤á¤Ë»È¤ï¤ì¤ë Active ¤Êʸ¡¦¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ °ú¿ô¤Ë¸¡º÷¥Ñ¥¿¡¼¥ó¤Ï¼õ¤±¼è¤ê¤Þ¤»¤ó(table_info()¤È¤Ï°ã¤Ã¤Æ)¡£ =begin original The statement handle will return one row per column, ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ. If there is no primary key then the statement handle will fetch no rows. =end original ¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Ï¡¢TABLE_CAT¡¢TABLE_SCHEMA¡¢TABLE_NAME¤ª¤è¤ÓKEY_SEQ¤Î½ç½ø¤Ç¡¢Î󤴤ȤË1¹Ô¤òÌᤷ¤Þ¤¹¡£ ¥×¥é¥¤¥Þ¥ê¥­¡¼¤¬¤Ê¤¤¾ì¹ç¡¢¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Ï¹Ô¤ò¥Õ¥§¥Ã¥Á¤·¤Þ¤»¤ó¡£ (TBR) =begin original Note: The support for the selection criteria, such as $catalog, is driver specific. If the driver doesn't support catalogs and/or schemas, it may ignore these criteria. =end original Ãí°Õ:$catalog ¤Î¤è¤¦¤Ê¡¢ÁªÂò¾ò·ï¤Î¥µ¥Ý¡¼¥È¤Ï¥É¥é¥¤¥Ð¤Ë¤è¤ê¤Þ¤¹¡£ ¤â¤·¥É¥é¥¤¥Ð¤¬¥«¥¿¥í¥°¤ä¥¹¥­¡¼¥Þ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤³¤ì¤é¤Î¾ò·ï¤Ï ̵»ë¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original The statement handle returned has at least the following fields in the order shown below. Other fields, after these, may also be present. =end original ÊÖ¤µ¤ì¤¿¹Ô¥Ï¥ó¥É¥ë¤Ï¾¯¤Ê¤¯¤È¤â¸å½Ò¤¹¤ë½ç½ø¤Ç°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤ò»ý¤Á¤Þ¤¹¡£ ¤³¤ì¤é¤Î¸å¤Ë¡¢Â¾¤Î¥Õ¥£¡¼¥ë¥É¤â¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original B: The catalog identifier. This field is NULL (C) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table. =end original B: ¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤è¤¯¤¢¤ë¤³¤È¤Ç¤¹¤¬¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The schema identifier. This field is NULL (C) if not applicable to the data source, and empty if not applicable to the table. =end original B: ¥¹¥­¡¼¥Þ¼±Ê̻ҡ£ ¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The table identifier. =end original B: ¥Æ¡¼¥Ö¥ë¼±Ê̻ҡ£ =begin original B: The column identifier. =end original B: Îó¼±Ê̻ҡ£ =begin original B: The column sequence number (starting with 1). Note: This field is named B in SQL/CLI. =end original B: ¥«¥é¥à½ç½øÈÖ¹æ(£±»Ï¤Þ¤ê)¡£ Ãí°Õ:SQL/CLI ¤Ç¤Ï¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï B ¤È̾¤Å¤±¤é¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original B: The primary key constraint identifier. This field is NULL (C) if not applicable to the data source. =end original B: ¼ç¥­¡¼À©Ìó¼±Ê̻ҡ£ ¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð NULL(C) ¤Ç¤¹¡£ =begin original See also L and L. =end original L ¤È L ¤â »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C @key_column_names = $dbh->primary_key( $catalog, $schema, $table ); =begin original Simple interface to the primary_key_info() method. Returns a list of the column names that comprise the primary key of the specified table. The list is in primary key column sequence order. If there is no primary key then an empty list is returned. =end original primary_key_info() ¥á¥½¥Ã¥É¤Ø¤Îñ½ã¤Ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¤¹¡£ »ØÄꤵ¤ì¤¿¥Æ¡¼¥Ö¥ë¤Î¼ç¥­¡¼¤ò´Þ¤à¥«¥é¥àÌܤΥꥹ¥È¤òÊÖ¤·¤Þ¤¹¡£ ¤³¤Î¥ê¥¹¥È¤Ï¼ç¥­¡¼¥«¥é¥à½çÈÖ¹æ½ç¤ËÆþ¤ê¤Þ¤¹¡£ ¼ç¥­¡¼¤¬¤Ê¤¤¾ì¹ç¡¢¶õ¥ê¥¹¥È¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =head3 C $sth = $dbh->foreign_key_info( $pk_catalog, $pk_schema, $pk_table , $fk_catalog, $fk_schema, $fk_table ); $sth = $dbh->foreign_key_info( $pk_catalog, $pk_schema, $pk_table , $fk_catalog, $fk_schema, $fk_table , \%attr ); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Returns an active statement handle that can be used to fetch information about foreign keys in and/or referencing the specified table(s). The arguments don't accept search patterns (unlike table_info()). =end original »ØÄꤵ¤ì¤¿¥Æ¡¼¥Ö¥ëÆâ¤Î³°Éô¥­¡¼¤Ë´Ø¤¹¤ë¾ðÊó¤ò¼èÆÀ¤·¤¿¤ê¡¢»ØÄꤵ¤ì¤¿¥Æ¡¼¥Ö¥ë¤ò»²¾È¤¹¤ë¤¿¤á¤Ë»ÈÍѤǤ­¤ë¡¢¥¢¥¯¥Æ¥£¥Ö¤Ê¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ ¤³¤Î°ú¿ô¤Ï¸¡º÷¥Ñ¥¿¡¼¥ó¤ò¼õ¤±ÉÕ¤±¤Þ¤»¤ó(table_info()¤È°Û¤Ê¤ê¤Þ¤¹)¡£ (TBR) =begin original C<$pk_catalog>, C<$pk_schema>, C<$pk_table> identify the primary (unique) key table (B). =end original C<$pk_catalog>, C<$pk_schema>, C<$pk_table> ¤Ï¼ç(¥æ¥Ë¡¼¥¯)¥­¡¼É½ (B) ¤ò¼±Ê̤·¤Þ¤¹¡£ =begin original C<$fk_catalog>, C<$fk_schema>, C<$fk_table> identify the foreign key table (B). =end original C<$fk_catalog>, C<$fk_schema>, C<$fk_table> ¤Ï³°Éô¥­¡¼É½ (B) ¤ò ¼±Ê̤·¤Þ¤¹¡£ =begin original If both B and B are given, the function returns the foreign key, if any, in table B that refers to the primary (unique) key of table B. (Note: In SQL/CLI, the result is implementation-defined.) =end original B¤ÈB¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¥Æ¡¼¥Ö¥ëB¤Î¥×¥é¥¤¥Þ¥ê(°ì°Õ¤Î)¥­¡¼¤ò»²¾È¤¹¤ë³°Éô¥­¡¼¤¬¥Æ¡¼¥Ö¥ëB¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï³°Éô¥­¡¼¤òÊÖ¤·¤Þ¤¹¡£ (Ãí:SQL/CLI¤Ç¤Ï¡¢·ë²Ì¤Ï¼ÂÁõ¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤Þ¤¹¡£ ) (TBR) =begin original If only B is given, then the result set contains the primary key of that table and all foreign keys that refer to it. =end original B ¤Î¤ß¤¬»ØÄꤵ¤ì¤ë¤È¡¢·ë²Ì¥»¥Ã¥È¤Ë¤Ï¤½¤Îɽ¤Î¼ç¥­¡¼¤È¡¢¤½¤ì¤ò »²¾È¤·¤Æ¤¤¤ëÁ´¤Æ¤Î³°Éô¥­¡¼¤¬´Þ¤Þ¤ì¤Þ¤¹¡£ =begin original If only B is given, then the result set contains all foreign keys in that table and the primary keys to which they refer. (Note: In SQL/CLI, the result includes unique keys too.) =end original B¤Î¤ß¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢·ë²Ì¥»¥Ã¥È¤Ë¤Ï¡¢¤½¤Î¥Æ¡¼¥Ö¥ëÆâ¤Î¤¹¤Ù¤Æ¤Î³°Éô¥­¡¼¤È¡¢¤½¤ì¤é¤¬»²¾È¤¹¤ë¥×¥é¥¤¥Þ¥ê¥­¡¼¤¬´Þ¤Þ¤ì¤Þ¤¹(Ãí:SQL/CLI¤Ç¤Ï¡¢·ë²Ì¤Ë¤Ï¥æ¥Ë¡¼¥¯¥­¡¼¤â´Þ¤Þ¤ì¤Þ¤¹)¡£ (TBR) =begin original For example: =end original Î㤨¤Ð: $sth = $dbh->foreign_key_info( undef, $user, 'master'); $sth = $dbh->foreign_key_info( undef, undef, undef , undef, $user, 'detail'); $sth = $dbh->foreign_key_info( undef, $user, 'master', undef, $user, 'detail'); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Note: The support for the selection criteria, such as C<$catalog>, is driver specific. If the driver doesn't support catalogs and/or schemas, it may ignore these criteria. =end original Ãí°Õ:C<$catalog>¤Ê¤É¤ÎÁªÂò´ð½à¤Î¥µ¥Ý¡¼¥È¤Ï¥É¥é¥¤¥Ð¸ÇÍ­¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤¬¥«¥¿¥í¥°¤ä¥¹¥­¡¼¥Þ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢¤³¤ì¤é¤Î´ð½à¤¬Ìµ»ë¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The statement handle returned has the following fields in the order shown below. Because ODBC never includes unique keys, they define different columns in the result set than SQL/CLI. SQL/CLI column names are shown in parentheses. =end original Ìᤵ¤ì¤¿¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Ë¤Ï¡¢¼¡¤Ë¼¨¤¹½ç½ø¤Ç¼¡¤Î¥Õ¥£¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤¹¡£ ODBC¤Ë¤Ï°ì°Õ¤Î¥­¡¼¤¬´Þ¤Þ¤ì¤Ê¤¤¤¿¤á¡¢·ë²Ì¥»¥Ã¥È¤Ë¤ÏSQL/CLI¤È¤Ï°Û¤Ê¤ëÎó¤¬ÄêµÁ¤µ¤ì¤Þ¤¹¡£ SQL/CLI¤ÎÎó̾¤Ï¥«¥Ã¥³Æâ¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original B: The primary (unique) key table catalog identifier. This field is NULL (C) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table. =end original B:¼ç(°ì°Õ¤Î)¥­¡¼¥Æ¡¼¥Ö¥ë¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤµ¤ì¤Ê¤¤¾ì¹ç¤ÏNULL(C)¤Ç¤¹¡£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Æ¡¼¥Ö¥ë¤ËŬÍѤµ¤ì¤Ê¤¤¾ì¹ç¤Ï¶õ¤Ç¤¹¡£ (TBR) =begin original B: The primary (unique) key table schema identifier. This field is NULL (C) if not applicable to the data source, and empty if not applicable to the table. =end original B:¼ç(°ì°Õ¤Î)¥­¡¼¥Æ¡¼¥Ö¥ë¥¹¥­¡¼¥Þ¼±Ê̻ҡ£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤ÏNULL(C)¡¢¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤Ï¶õ¤Ç¤¹¡£ (TBR) =begin original B: The primary (unique) key table identifier. =end original B: ¼ç(¥æ¥Ë¡¼¥¯)¥­¡¼É½¼±Ê̻ҡ£ =begin original B: The primary (unique) key column identifier. =end original B: ¼ç(¥æ¥Ë¡¼¥¯)¥­¡¼Îó¼±Ê̻ҡ£ =begin original B: The foreign key table catalog identifier. This field is NULL (C) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table. =end original B:³°Éô¥­¡¼¥Æ¡¼¥Ö¥ë¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤ÏNULL(C)¤Ç¤¹¡£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤Ï¶õ¤Ç¤¹¡£ (TBR) =begin original B: The foreign key table schema identifier. This field is NULL (C) if not applicable to the data source, and empty if not applicable to the table. =end original B:³°Éô¥­¡¼¥Æ¡¼¥Ö¥ë¥¹¥­¡¼¥Þ¼±Ê̻ҡ£ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤ÏNULL(C)¡¢¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤¤¾ì¹ç¤Ï¶õ¤Ç¤¹¡£ (TBR) =begin original B: The foreign key table identifier. =end original B: ³°Éô¥­¡¼É½¼±Ê̻ҡ£ =begin original B: The foreign key column identifier. =end original B: ³°Éô¥­¡¼Îó¼±Ê̻ҡ£ =begin original B: The column sequence number (starting with 1). =end original B: Îó¥·¡¼¥±¥ó¥¹ÈÖ¹æ(1 ¤«¤é³«»Ï)¡£ =begin original B: The referential action for the UPDATE rule. The following codes are defined: =end original B:UPDATE¥ë¡¼¥ë¤Î»²¾È¥¢¥¯¥·¥ç¥ó¡£ ¼¡¤Î¥³¡¼¥É¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) CASCADE 0 RESTRICT 1 SET NULL 2 NO ACTION 3 SET DEFAULT 4 =begin original B: The referential action for the DELETE rule. The codes are the same as for UPDATE_RULE. =end original B:DELETE¥ë¡¼¥ë¤Î»²¾È¥¢¥¯¥·¥ç¥ó¡£ ¥³¡¼¥É¤ÏUPDATE_RULE¤Î¤â¤Î¤ÈƱ¤¸¤Ç¤¹¡£ (TBR) =begin original B: The foreign key name. =end original B: ³°Éô¥­¡¼Ì¾¡£ =begin original B: The primary (unique) key name. =end original B: ¼ç (¥æ¥Ë¡¼¥¯) ¥­¡¼Ì¾¡£ =begin original B: The deferrability of the foreign key constraint. The following codes are defined: =end original B:³°Éô¥­¡¼À©Ìó¤ÎÃÙ±ä²ÄǽÀ­¡£ ¼¡¤Î¥³¡¼¥É¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) INITIALLY DEFERRED 5 INITIALLY IMMEDIATE 6 NOT DEFERRABLE 7 =begin original B< ( UNIQUE_OR_PRIMARY )>: This column is necessary if a driver includes all candidate (i.e. primary and alternate) keys in the result set (as specified by SQL/CLI). The value of this column is UNIQUE if the foreign key references an alternate key and PRIMARY if the foreign key references a primary key, or it may be undefined if the driver doesn't have access to the information. =end original B< ( UNIQUE_OR_PRIMARY )>:¤³¤ÎÎó¤Ï¡¢¥É¥é¥¤¥Ð¤Î·ë²Ì¥»¥Ã¥È¤Ë¤¹¤Ù¤Æ¤Î¸õÊ䥭¡¼(¼ç¥­¡¼¤ÈÂåÂØ¥­¡¼)¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤ËɬÍפǤ¹(SQL/CLI¤Ç»ØÄê)¡£ ¤³¤ÎÎó¤ÎÃͤϡ¢³°Éô¥­¡¼¤¬ÂåÂØ¥­¡¼¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤ÏUNIQUE¡¢³°Éô¥­¡¼¤¬¼ç¥­¡¼¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤ÏPRIMARY¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤¬¾ðÊó¤Ë¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¾ì¹ç¤Ï¡¢Ì¤ÄêµÁ¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original See also L and L. =end original L ¤È L ¤â »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C =begin original B This method is experimental and may change. =end original B<·Ù¹ð:> ¤³¤Î¥á¥½¥Ã¥É¤Ï¼Â¸³Åª¤Ç¤¢¤êÊѹ¹¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ $sth = $dbh->statistics_info( $catalog, $schema, $table, $unique_only, $quick ); # then $sth->fetchall_arrayref or $sth->fetchall_hashref etc =begin original Returns an active statement handle that can be used to fetch statistical information about a table and its indexes. =end original ɽ¤È¤½¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ë´Ø¤¹¤ëÅý·×¾ðÊó¤ò¼èÆÀ¤¹¤ë¤Î¤Ë»È¤¨¤ë¡¢Í­¸ú¤Ê ʸ¥Ï¥ó¥É¥ë¤òÊÖ¤·¤Þ¤¹¡£ =begin original The arguments don't accept search patterns (unlike L). =end original °ú¿ô¤Ï (L ¤È°ã¤Ã¤Æ) ¸¡º÷¥Ñ¥¿¡¼¥ó¤Ï¼õ¤±ÉÕ¤±¤Þ¤»¤ó¡£ =begin original If the boolean argument $unique_only is true, only UNIQUE indexes will be returned in the result set, otherwise all indexes will be returned. =end original ¿¿µ¶ÃÍ°ú¿ô $unique_only ¤¬¿¿¤Ê¤é¡¢¥æ¥Ë¡¼¥¯¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¤ß¤¬ ·ë²Ì¥»¥Ã¥È¤ÇÊÖ¤µ¤ì¡¢¤µ¤â¤Ê¤±¤ì¤ÐÁ´¤Æ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original If the boolean argument $quick is set, the actual statistical information columns (CARDINALITY and PAGES) will only be returned if they are readily available from the server, and might not be current. Some databases may return stale statistics or no statistics at all with this flag set. =end original ¥Ö¡¼¥ëÃͤΰú¿ô$quick¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¼ÂºÝ¤ÎÅý·×¾ðÊó¤ÎÎó(CARDINALITY¤ª¤è¤ÓPAGES)¤¬ÊÖ¤µ¤ì¤ë¤Î¤Ï¡¢¤½¤ì¤é¤ÎÎ󤬥µ¡¼¥Ð¡¼¤«¤é¤¹¤°¤ËÍøÍѤǤ­¤ë¾ì¹ç¤Î¤ß¤Ç¡¢ºÇ¿·¤Î¤â¤Î¤Ç¤Ï¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤è¤Ã¤Æ¤Ï¡¢¤³¤Î¥Õ¥é¥°¤òÀßÄꤹ¤ë¤È¡¢¸Å¤¤Åý·×¾ðÊó¤¬ÊÖ¤µ¤ì¤¿¤ê¡¢Åý·×¾ðÊ󤬤ޤ俤¯ÊÖ¤µ¤ì¤Ê¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The statement handle will return at most one row per column name per index, plus at most one row for the entire table itself, ordered by NON_UNIQUE, TYPE, INDEX_QUALIFIER, INDEX_NAME, and ORDINAL_POSITION. =end original ¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤Ï¡¢NON_UNIQUE¡¢TYPE¡¢INDEX_QUALIFIER¡¢INDEX_NAME¡¢¤ª¤è¤ÓORDINAL_POSITION¤Î½ç½ø¤Ç¡¢¥¤¥ó¥Ç¥Ã¥¯¥¹¤´¤È¤ËÎó̾¤´¤È¤ËºÇÂç1¤Ä¤Î¥í¡¼¤È¡¢¥Æ¡¼¥Ö¥ëÁ´ÂΤǺÇÂç1¤Ä¤Î¥í¡¼¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original Note: The support for the selection criteria, such as $catalog, is driver specific. If the driver doesn't support catalogs and/or schemas, it may ignore these criteria. =end original Ãí°Õ:$catalog ¤Î¤è¤¦¤Ê¡¢ÁªÂò¾ò·ï¤Î¥µ¥Ý¡¼¥È¤Ï¥É¥é¥¤¥Ð¤Ë¤è¤ê¤Þ¤¹¡£ ¤â¤·¥É¥é¥¤¥Ð¤¬¥«¥¿¥í¥°¤ä¥¹¥­¡¼¥Þ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤³¤ì¤é¤Î¾ò·ï¤Ï ̵»ë¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original The statement handle returned has at least the following fields in the order shown below. Other fields, after these, may also be present. =end original ÊÖ¤µ¤ì¤¿¹Ô¥Ï¥ó¥É¥ë¤Ï¾¯¤Ê¤¯¤È¤â¸å½Ò¤¹¤ë½ç½ø¤Ç°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤ò»ý¤Á¤Þ¤¹¡£ ¤³¤ì¤é¤Î¸å¤Ë¡¢Â¾¤Î¥Õ¥£¡¼¥ë¥É¤â¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original B: The catalog identifier. This field is NULL (C) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table. =end original B: ¥«¥¿¥í¥°¼±Ê̻ҡ£ ¤è¤¯¤¢¤ë¤³¤È¤Ç¤¹¤¬¡¢¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The schema identifier. This field is NULL (C) if not applicable to the data source, and empty if not applicable to the table. =end original B: ¥¹¥­¡¼¥Þ¼±Ê̻ҡ£ ¥Ç¡¼¥¿¥½¡¼¥¹¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬NULL(C)¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¤ËŬÍѤǤ­¤Ê¤±¤ì¤Ð¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¶õ¤Ç¤¹¡£ =begin original B: The table identifier. =end original B: ¥Æ¡¼¥Ö¥ë¼±Ê̻ҡ£ =begin original B: Unique index indicator. Returns 0 for unique indexes, 1 for non-unique indexes =end original B: ¥æ¥Ë¡¼¥¯¥¤¥ó¥Ç¥Ã¥¯¥¹»Ø¼¨»Ò¡£ ¥æ¥Ë¡¼¥¯¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¾ì¹ç¤Ï 0 ¤ò¡¢¤½¤ì°Ê³°¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¤Ï 1 ¤ò ÊÖ¤·¤Þ¤¹¡£ =begin original B: Index qualifier identifier. The identifier that is used to qualify the index name when doing a C; NULL (C) is returned if an index qualifier is not supported by the data source. If a non-NULL (defined) value is returned in this column, it must be used to qualify the index name on a C statement; otherwise, the TABLE_SCHEM should be used to qualify the index name. =end original B:º÷°ú¥¯¥ª¥ê¥Õ¥¡¥¤¥¢¼±Ê̻ҡ£ C¤Î¼Â¹Ô»þ¤Ëº÷°ú̾¤Î½¤¾þ¤Ë»ÈÍѤµ¤ì¤ë¼±Ê̻ҡ£ ¥Ç¡¼¥¿¥½¡¼¥¹¤Çº÷°ú¥¯¥ª¥ê¥Õ¥¡¥¤¥¢¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢NULL(C)¤¬Ìᤵ¤ì¤Þ¤¹¡£ ¤³¤ÎÎó¤ËNULL(ÄêµÁºÑ)°Ê³°¤ÎÃͤ¬Ìᤵ¤ì¤¿¾ì¹ç¤Ï¡¢¤½¤ÎÃͤò»ÈÍѤ·¤ÆCʸ¤Îº÷°ú̾¤ò½¤¾þ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢TABLE_SCHEMA¤ò»ÈÍѤ·¤Æº÷°ú̾¤ò½¤¾þ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original B: The index identifier. =end original B: ¥¤¥ó¥Ç¥Ã¥¯¥¹¼±Ê̻ҡ£ =begin original B: The type of information being returned. Can be any of the following values: 'table', 'btree', 'clustered', 'content', 'hashed', or 'other'. =end original B:Ìᤵ¤ì¤ë¾ðÊó¤Î¥¿¥¤¥×¡£ 'table'¡¢'btree'¡¢'clustered'¡¢'content'¡¢'hashed'¡¢¤Þ¤¿¤Ï'other'¤Î¤¤¤º¤ì¤«¤ÎÃͤˤʤê¤Þ¤¹¡£ (TBR) =begin original In the case that this field is 'table', all fields other than TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TYPE, CARDINALITY, and PAGES will be NULL (C). =end original ¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬'table'¤Î¾ì¹ç¡¢TABLE_CAT¡¢TABLE_SCHEMA¡¢TABLE_NAME¡¢TYPE¡¢CARDINALITY¡¢¤ª¤è¤ÓPAGES°Ê³°¤Î¤¹¤Ù¤Æ¤Î¥Õ¥£¡¼¥ë¥É¤ÏNULL(C)¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original B: Column sequence number (starting with 1). =end original B: Îó¥·¡¼¥±¥ó¥¹ÈÖ¹æ (1 ¤«¤é³«»Ï)¡£ =begin original B: The column identifier. =end original B: Îó¼±Ê̻ҡ£ =begin original B: Column sort sequence. C for Ascending, C for Descending, or NULL (C) if not supported for this index. =end original B:Îó¤Î¥½¡¼¥È½ç½ø¡£ ¾º½ç¤Î¾ì¹ç¤ÏC¡¢¹ß½ç¤Î¾ì¹ç¤ÏC¡¢¤³¤Îº÷°ú¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤ÏNULL(C)¡£ (TBR) =begin original B: Cardinality of the table or index. For indexes, this is the number of unique values in the index. For tables, this is the number of rows in the table. If not supported, the value will be NULL (C). =end original B:ɽ¤Þ¤¿¤Ïº÷°ú¤Î¥«¡¼¥Ç¥£¥Ê¥ê¥Æ¥£¡£ º÷°ú¤Î¾ì¹ç¡¢¤³¤ì¤Ïº÷°úÆâ¤Î°ì°Õ¤ÎÃͤοô¤Ç¤¹¡£ ɽ¤Î¾ì¹ç¡¢¤³¤ì¤Ïɽ¤Î¹Ô¿ô¤Ç¤¹¡£ ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÃͤÏNULL(C)¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original B: Number of storage pages used by this table or index. If not supported, the value will be NULL (C). =end original B: ¤³¤Îɽ¤Þ¤¿¤Ï¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç»È¤ï¤ì¤ë¥Ú¡¼¥¸Èֹ档 Âбþ¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÃÍ¤Ï NULL (C) ¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original B: The index filter condition as a string. If the index is not a filtered index, or it cannot be determined whether the index is a filtered index, this value is NULL (C). If the index is a filtered index, but the filter condition cannot be determined, this value is the empty string C<''>. Otherwise it will be the literal filter condition as a string, such as C. =end original B:ʸ»úÎó¤È¤·¤Æ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¥Õ¥£¥ë¥¿¾ò·ï¡£ ¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥£¥ë¥¿¤µ¤ì¤¿¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¤Ê¤¤¾ì¹ç¡¢¤Þ¤¿¤Ï¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥£¥ë¥¿¤µ¤ì¤¿¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¤¢¤ë¤«¤É¤¦¤«¤òȽÊ̤Ǥ­¤Ê¤¤¾ì¹ç¡¢¤³¤ÎÃͤÏNULL(C)¤Ç¤¹¡£ ¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥£¥ë¥¿¤µ¤ì¤¿¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¤¢¤ë¤¬¡¢¥Õ¥£¥ë¥¿¾ò·ï¤òȽÊ̤Ǥ­¤Ê¤¤¾ì¹ç¡¢¤³¤ÎÃͤ϶õ¤Îʸ»úÎóC<''>¤Ç¤¹¡£ ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢Ê¸»úÎó¤È¤·¤Æ¤Î¥ê¥Æ¥é¥ë¥Õ¥£¥ë¥¿¾ò·ï(C¤Ê¤É)¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original See also L and L. =end original L ¤È L ¤â »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C @names = $dbh->tables( $catalog, $schema, $table, $type ); @names = $dbh->tables; # deprecated =begin original Simple interface to table_info(). Returns a list of matching table names, possibly including a catalog/schema prefix. =end original table_info()¤Ø¤Îñ½ã¤Ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¤¹¡£ ¥Æ¡¼¥Ö¥ë¡¢¥Ó¥å¡¼¤Î̾Á°¤Îñ½ã¤Ê¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹; ¤ª¤½¤é¤¯Æ¬¤Ë¥¹¥­¡¼¥Þ¤¬¤Ä¤¤¤Æ¤­¤Þ¤¹¡£ =begin original See L for a description of the parameters. =end original ¥Ñ¥é¥á¡¼¥¿¤ÎÀâÌÀ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original If C<$dbh-Eget_info(29)> returns true (29 is SQL_IDENTIFIER_QUOTE_CHAR) then the table names are constructed and quoted by L to ensure they are usable even if they contain whitespace or reserved words etc. This means that the table names returned will include quote characters. =end original C<$dbh-Eget_info(29)>¤¬true¤òÊÖ¤¹¾ì¹ç(29¤ÏSQL_IDENTIFIER_QUOTE_CHAR)¡¢¶õÇò¤äͽÌó¸ì¤Ê¤É¤¬´Þ¤Þ¤ì¤Æ¤¤¤Æ¤â»ÈÍѤǤ­¤ë¤è¤¦¤Ë¡¢¥Æ¡¼¥Ö¥ë̾¤ÏL¤Ç¹½À®¤µ¤ì¡¢°úÍÑÉä¤Ç°Ï¤Þ¤ì¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢ÊÖ¤µ¤ì¤ë¥Æ¡¼¥Ö¥ë̾¤Ë°úÍÑÉäʸ»ú¤¬´Þ¤Þ¤ì¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ (TBR) =head3 C $type_info_all = $dbh->type_info_all; =begin original Returns a reference to an array which holds information about each data type variant supported by the database and driver. The array and its contents should be treated as read-only. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¢¤ë¤¤¤Ï¥É¥é¥¤¥Ð¤Ë¤è¤ê¥µ¥Ý¡¼¥È¤µ¤ì¤ë¥Ç¡¼¥¿·¿¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤¬ Æþ¤Ã¤¿ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ÇÛÎóµÚ¤Ó¤½¤ÎÆâÍƤÏÆɤ߹þ¤ßÀìÍѤȤ·¤Æ°·¤ï¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original The first item is a reference to an 'index' hash of CE C pairs. The items following that are references to arrays, one per supported data type variant. The leading index hash defines the names and order of the fields within the arrays that follow it. For example: =end original ºÇ½é¤ÎÍ×ÁÇ¤Ï C<̾Á° => E C<¥¤¥ó¥Ç¥Ã¥¯¥¹>¤È¤¤¤¦¥Ú¥¢¤Î¥Ï¥Ã¥·¥å¤Ø¤Î ¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¹¡£ ¤½¤Î¸å¤ÎÍ×ÁǤϡ¢ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¡¢£±¤Ä¤º¤Ä¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë ¥Ç¡¼¥¿·¿¤Ë¤Ê¤ê¤Þ¤¹¡£ ºÇ½é¤Î¥Ï¥Ã¥·¥å¤¬¸å¤Ë³¤¯ÇÛÎóÍ×ÁǤΥե£¡¼¥ë¥É¤Î̾Á°¤È½ç½ø¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹¡£ Îã: $type_info_all = [ { TYPE_NAME => 0, DATA_TYPE => 1, COLUMN_SIZE => 2, # was PRECISION originally LITERAL_PREFIX => 3, LITERAL_SUFFIX => 4, CREATE_PARAMS => 5, NULLABLE => 6, CASE_SENSITIVE => 7, SEARCHABLE => 8, UNSIGNED_ATTRIBUTE=> 9, FIXED_PREC_SCALE => 10, # was MONEY originally AUTO_UNIQUE_VALUE => 11, # was AUTO_INCREMENT originally LOCAL_TYPE_NAME => 12, MINIMUM_SCALE => 13, MAXIMUM_SCALE => 14, SQL_DATA_TYPE => 15, SQL_DATETIME_SUB => 16, NUM_PREC_RADIX => 17, INTERVAL_PRECISION=> 18, }, [ 'VARCHAR', SQL_VARCHAR, undef, "'","'", undef,0, 1,1,0,0,0,undef,1,255, undef ], [ 'INTEGER', SQL_INTEGER, undef, "", "", undef,0, 0,1,0,0,0,undef,0, 0, 10 ], ]; =begin original More than one row may have the same value in the C field if there are different ways to spell the type name and/or there are variants of the type with different attributes (e.g., with and without C set, with and without C, etc). =end original ¤½¤Î·¿¤Î̾Á°¤Ë°ã¤Ã¤¿½ñ¤­Êý¤¬¤¢¤Ã¤¿¤ê¡¢Â°À­¤Î°ã¤¤¤Ç·¿¤Î¥Ð¥ê¥¨¡¼¥·¥ç¥ó¤¬ ¤¢¤Ã¤¿¤ê(Î㤨¤Ð C ¤¬¤¢¤Ã¤¿¤ê¤Ê¤«¤Ã¤¿¤ê¡¢ C ¤¬¤¢¤Ã¤¿¤ê¤Ê¤«¤Ã¤¿¤ê¤Ê¤É)¤¹¤ì¤Ð¡¢°ì¤Ä°Ê¾å¤Î¥Õ¥£¡¼¥ë¥É¤¬ C ¥Õ¥£¡¼¥ë¥É¤ËƱ¤¸Ãͤò¤â¤Ä¤³¤È¤â¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The rows are ordered by C first and then by how closely each type maps to the corresponding ODBC SQL data type, closest first. =end original ¹Ô¤Ï¤Þ¤º C ¤Ç½ç¤Ë¡¢¤½¤·¤Æ ODBC SQL ¥Ç¡¼¥¿·¿¤Ë¤É¤ì¤¯¤é¤¤¶á¤¯ Âбþ¤·¤Æ¤¤¤ë¤«¤Ë¤è¤Ã¤Æ¶á¤¤¤Û¤ÉÀè¤Ë½ç¤ËʤӤޤ¹¡£ =begin original The meaning of the fields is described in the documentation for the L method. =end original ³Æ¥Õ¥£¡¼¥ë¥É¤Î°ÕÌ£¤Ï L ¥á¥½¥Ã¥É¤ÇÀâÌÀ¤·¤Æ¤¤¤Þ¤¹¡£ =begin original An 'index' hash is provided so you don't need to rely on index values defined above. However, using DBD::ODBC with some old ODBC drivers may return older names, shown as comments in the example above. Another issue with the index hash is that the lettercase of the keys is not defined. It is usually uppercase, as show here, but drivers may return names with any lettercase. =end original 'index' ¥Ï¥Ã¥·¥å¤¬Ä󶡤µ¤ì¤ë¤Î¤Ç¡¢¾å¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹ÃÍ¤Ë Íê¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó¡£ ¤·¤«¤·¡¢¸Å¤¤ ODBC ¥É¥é¥¤¥Ð¤Ç DBD::ODBC ¤ò»È¤¦¤È¡¢¾å½Ò¤ÎÎã¤Î¥³¥á¥ó¥È¤Ë ¤¢¤ë¤è¤¦¤Ë¡¢¸Å¤¤Ì¾Á°¤òÊÖ¤¹¤«¤â¤·¤ì¤Þ¤»¤ó¡£ ¥¤¥ó¥Ç¥Ã¥¯¥¹¥Ï¥Ã¥·¥å¤Ë´Ø¤¹¤ë¤â¤¦°ì¤Ä¤ÎÌäÂê¤Ï¡¢¥­¡¼¤ÎÂçʸ»ú¾®Ê¸»ú¤¬ ̤ÄêµÁ¤Ç¤¢¤ë¤³¤È¤Ç¤¹¡£ ¤½¤ì¤ÏÄ̾¤³¤³¤Ç¸«¤Æ¤­¤¿¤è¤¦¤ËÂçʸ»ú¤Ç¤¹¤¬¡¢¥É¥é¥¤¥Ð¤Ï̾Á°¤òÂçʸ»ú¡¢ ¾®Ê¸»ú¤Î¤É¤Á¤é¤ÇÊÖ¤·¤Æ¤â¼«Í³¤Ç¤¹¡£ =begin original Drivers are also free to return extra driver-specific columns of information - though it's recommended that they start at column index 50 to leave room for expansion of the DBI/ODBC specification. =end original ¥É¥é¥¤¥Ð¤ÏÆÃÊ̤ʥɥ饤¥ÐÀìÍѤξðÊó¤Î¥«¥é¥à¤òÊÖ¤¹¤Î¤â¼«Í³¤Ç¤¹ - ¤·¤«¤· DBI/ODBC »ÅÍͤγÈÄ¥¤Î¤¿¤á¤Î¶õ´Ö¤ò¤¢¤±¤Æ¤ª¤¯¤¿¤á¤Ë¥«¥é¥à¥¤¥ó¥Ç¥Ã¥¯¥¹ 50 ¤«¤é »Ï¤á¤ë¤³¤È¤ò¤ª´«¤á¤·¤Þ¤¹¡£ =begin original The type_info_all() method is not normally used directly. The L method provides a more usable and useful interface to the data. =end original type_info_all()¥á¥½¥Ã¥É¤ÏÄ̾ïľÀÜ»ÈÍѤµ¤ì¤Þ¤»¤ó¡£ L¥á¥½¥Ã¥É¤Ï¡¢¥Ç¡¼¥¿¤Ø¤Î¤è¤ê»ÈÍѲÄǽ¤ÇÍ­ÍѤʥ¤¥ó¥¿¥Õ¥§¡¼¥¹¤òÄ󶡤·¤Þ¤¹¡£ (TBR) =head3 C @type_info = $dbh->type_info($data_type); =begin original Returns a list of hash references holding information about one or more variants of $data_type. The list is ordered by C first and then by how closely each type maps to the corresponding ODBC SQL data type, closest first. If called in a scalar context then only the first (best) element is returned. =end original °ì¤Ä¤¢¤ë¤¤¤ÏÊ£¿ô¤Î $data_type ¤ÎÊÑ·Á¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤¬Æþ¤Ã¤¿¥Ï¥Ã¥·¥å¤Ø¤Î ¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¥ê¥¹¥È¤Ï¤Þ¤º C ¤Ë¤è¤Ã¤Æʤ٤é¤ì¡¢¤½¤·¤Æ³Æ·¿¤¬ ODBC SQL ¥Ç¡¼¥¿·¿¤Ë ¤É¤é¤¯¤é¤¤¶á¤¯Âбþ¤·¤Æ¤¤¤ë¤«¤Ë¤è¤Ã¤Æ¶á¤¤¤Û¤ÉÀè¤Ë½ç¤ËʤӤޤ¹¡£ ¥¹¥«¥é¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ð¤ì¤ì¤Ð¡¢ºÇ½é¤Î(¤â¤Ã¤È¤â¤è¤¤)Í×ÁǤÀ¤±¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original If $data_type is undefined or C, then the list will contain hashes for all data type variants supported by the database and driver. =end original $data_type ¤¬Ì¤ÄêµÁ¤« C ¤Ç¤¢¤ì¤Ð¡¢¥ê¥¹¥È¤Ë¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤È ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿·¿¤¬Æþ¤ê¤Þ¤¹¡£ =begin original If $data_type is an array reference then C returns the information for the I type in the array that has any matches. =end original ¤â¤· $data_type ¤¬ÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¢¤ì¤Ð¡¢C ¤Ï¤½¤ÎÇÛÎó¤Î ¤¤¤º¤ì¤«¤¬Âбþ¤¹¤ëºÇ½é¤Î·¿¤Î¤¿¤á¤Î¾ðÊó¤òÊÖ¤·¤Þ¤¹¡£ =begin original The keys of the hash follow the same letter case conventions as the rest of the DBI (see L). The following uppercase items should always exist, though may be undef: =end original °Ê²¼¤Î¥Ï¥Ã¥·¥å¤Î¥­¡¼¤Ï DBI ¤Î¾¤ÎÉôʬ¤ÈƱ¤¸¤è¤¦¤Ë¤¹¤Ù¤ÆÂçʸ»ú¤â¤·¤¯¤Ï ¾®Ê¸»ú¤Çɽ¤ï¤µ¤ì¤Þ¤¹¡£ (L ¤ò¤´Í÷¤¯¤À¤µ¤¤)¡£ °Ê²¼¤Ë¼¨¤¹Âçʸ»úÍ×ÁǤϴְ㤤̵¤¯Â¸ºß¤·¤Þ¤¹¤¬¡¢Ì¤ÄêµÁ¤«¤â¤·¤ì¤Þ¤»¤ó: =over 4 =item TYPE_NAME (string) =begin original Data type name for use in CREATE TABLE statements etc. =end original CREATE TABLE ʸ¤Ê¤É¤Ç»È¤ï¤ì¤ë¥Ç¡¼¥¿·¿Ì¾¡£ =item DATA_TYPE (integer) =begin original SQL data type number. =end original SQL ¥Ç¡¼¥¿·¿Èֹ档 =item COLUMN_SIZE (integer) =begin original For numeric types, this is either the total number of digits (if the NUM_PREC_RADIX value is 10) or the total number of bits allowed in the column (if NUM_PREC_RADIX is 2). =end original ¿ôÃÍ·¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢¤³¤ì¤Ï(NUM_PREC_RADIX ¤ÎÃͤ¬ 10 ¤Ç¤¢¤ì¤Ð)Áí·å¿ô¡¢ ¤â¤·¤¯¤Ï(NUM_PREC_RADIX ¤ÎÃͤ¬ 2 ¤Ç¤¢¤ì¤Ð)¥«¥é¥à¤ÎÃæ¤Ëµö¤µ¤ì¤ë¥Ó¥Ã¥È¤Î Áí¿ô¡£ =begin original For string types, this is the maximum size of the string in characters. =end original ʸ»úÎ󷿤Ǥ¢¤ì¤Ð¡¢¤³¤ì¤Ïʸ»úÎó¤ÎºÇÂ祵¥¤¥º¤òʸ»ú¿ô¤Çɽ¤·¤¿¤â¤Î¡£ =begin original For date and interval types, this is the maximum number of characters needed to display the value. =end original ÆüÉÕ(date)¤ª¤è¤Ó´ü´Ö(interval)·¿¤Ç¤¢¤ì¤Ð¡¢¤½¤ÎÃͤòɽ¼¨¤¹¤ë¤¿¤á¤ËɬÍפÊʸ»ú¤Î ºÇÂç¿ô¤Ç¤¹¡£ =item LITERAL_PREFIX (string) =begin original Characters used to prefix a literal. A typical prefix is "C<'>" for characters, or possibly "C<0x>" for binary values passed as hexadecimal. NULL (C) is returned for data types for which this is not applicable. =end original ¥ê¥Æ¥é¥ë¤ÎºÇ½é¤Ë»È¤ï¤ì¤ëʸ»ú¡£ ŵ·¿Åª¤Ê¤â¤Î¤È¤·¤Æ¤Ïʸ»ú·¿¤Ë¤Ï "C<'>"¡¢¥Ð¥¤¥Ê¥êÃÍ¤Ë¤Ï 16 ¿Ê¿ô¤òɽ¤ï¤¹ "C<0x>"¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item LITERAL_SUFFIX (string) =begin original Characters used to suffix a literal. Typically "C<'>" for characters. NULL (C) is returned for data types where this is not applicable. =end original ¥ê¥Æ¥é¥ë¤ÎºÇ¸å¤Ë»È¤ï¤ì¤ëʸ»ú¡£ ŵ·¿Åª¤Ê¤â¤Î¤È¤·¤Æ¤Ïʸ»ú·¿¤Ë¤Ï "C<'>"¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C)¡£ =item CREATE_PARAMS (string) =begin original Parameter names for data type definition. For example, C for a C would be "C" if the DECIMAL type should be declared as CIC<)> where I and I are integer values. For a C it would be "C". NULL (C) is returned for data types for which this is not applicable. =end original ¥Ç¡¼¥¿·¿ÄêµÁ¤Î¤¿¤á¤Î¥Ñ¥é¥á¡¼¥¿Ì¾¡£ Î㤨¤Ð C ¤¬ CIC<)> (Á´Âηå¿ô,¾®¿ôÅÀ°Ê²¼·å¿ô)¡¢ I ¤È I ¤ÏÀ°¿ôÃͤΤ褦¤ËÀë¸À¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢ C ¤Î¤¿¤á¤Î C ¤Ï "C" ¤Ë¤Ê¤ê¤Þ¤¹¡£ C ¤Ç¤Ï "C"(ºÇÂçĹ)¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item NULLABLE (integer) =begin original Indicates whether the data type accepts a NULL value: C<0> or an empty string = no, C<1> = yes, C<2> = unknown. =end original ¤³¤Î¥Ç¡¼¥¿·¿¤¬NULLÃͤò¼õ¤±Æþ¤ì¤ë¤«¤É¤¦¤«¤ò¼¨¤·¤Þ¤¹: ( C<0> ¤Þ¤¿¤Ï¶õʸ»úÎó = ¼õ¤±Æþ¤ì¤Ê¤¤, C<1> = ¼õ¤±Æþ¤ì¤ë, C<2> = ÉÔÌÀ) =item CASE_SENSITIVE (boolean) =begin original Indicates whether the data type is case sensitive in collations and comparisons. =end original ¤³¤Î¥Ç¡¼¥¿·¿¤¬¾È²ñ¤äÈæ³Ó¤Î¤µ¤¤¤ËÂçʸ»ú¡¢¾®Ê¸»ú¤ò¶èÊ̤¹¤ë¤«¤É¤¦¤«¤ò¼¨¤·¤Þ¤¹¡£ =item SEARCHABLE (integer) =begin original Indicates how the data type can be used in a WHERE clause, as follows: =end original ¥Ç¡¼¥¿¥¿¥¤¥×¤¬ WHERE ¶ç¤Ç°Ê²¼¤Î¤è¤¦¤Ë»ÈÍѤǤ­¤ë¤«¤É¤¦¤«¤ò¼¨¤·¤Þ¤¹: =begin original 0 - Cannot be used in a WHERE clause 1 - Only with a LIKE predicate 2 - All comparison operators except LIKE 3 - Can be used in a WHERE clause with any comparison operator =end original 0 - WHERE ¶ç¤Ç»È¤¦¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó 1 - LIKE ¤È°ì½ï¤Ë¤Ê¤é»È¤¨¤Þ¤¹¡£ 2 - LIKE ¤ò½ü¤¤¤Æ¤¹¤Ù¤Æ¤ÎÈæ³Ó±é»»»Ò¤¬»È¤¨¤Þ¤¹ 3 - WHERE ¶ç¤Ë¤ª¤¤¤Æ¤¹¤Ù¤Æ¤ÎÈæ³Ó±é»»»Ò¤¬»È¤¨¤Þ¤¹ =item UNSIGNED_ATTRIBUTE (boolean) =begin original Indicates whether the data type is unsigned. NULL (C) is returned for data types for which this is not applicable. =end original ¥Ç¡¼¥¿·¿¤¬Éä¹æ¤Ê¤·¤Ç¤¢¤ë¤«¤É¤¦¤«¤ò¼¨¤·¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item FIXED_PREC_SCALE (boolean) =begin original Indicates whether the data type always has the same precision and scale (such as a money type). NULL (C) is returned for data types for which this is not applicable. =end original ¤½¤Î¥Ç¡¼¥¿·¿¤¬(money ·¿¤Î¤è¤¦¤Ë)¾ï¤ËƱ¤¸ÀºÅÙ¡¢·å¿ô¤ò»ý¤Ä¤«¤É¤¦¤«¤ò ¼¨¤·¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item AUTO_UNIQUE_VALUE (boolean) =begin original Indicates whether a column of this data type is automatically set to a unique value whenever a new row is inserted. NULL (C) is returned for data types for which this is not applicable. =end original ¿·¤·¤¤¹Ô¤¬ÁÞÆþ¤¹¤ë¤È¤­¤Ë¤Ï¤¤¤Ä¤â¡¢¤³¤Î¥Ç¡¼¥¿·¿¤Î¥«¥é¥à¤Ï¼«Æ°Åª¤Ë ¥æ¥Ë¡¼¥¯¤ÊÃͤËÀßÄꤵ¤ì¤ë¤«¤É¤¦¤«¤ò¼¨¤·¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item LOCAL_TYPE_NAME (string) =begin original Localized version of the C for use in dialog with users. NULL (C) is returned if a localized name is not available (in which case C should be used). =end original ¥æ¡¼¥¶¤È¤ÎÂÐÏä˻Ȥï¤ì¤ë C ¤Î¥í¡¼¥«¥ë²½¤µ¤ì¤¿¥Ð¡¼¥¸¥ç¥ó¡£ ¥í¡¼¥«¥ë²½¤µ¤ì¤¿Ì¾Á°¤¬¤Ê¤±¤ì¤ÐNULL (C)(¤³¤Î¾ì¹ç¤Ï C ¤ò »È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó)¡£ =item MINIMUM_SCALE (integer) =begin original The minimum scale of the data type. If a data type has a fixed scale, then C holds the same value. NULL (C) is returned for data types for which this is not applicable. =end original ¥Ç¡¼¥¿·¿¤ÎºÇ¾®·å¿ô¡£ ¥Ç¡¼¥¿·¿¤¬·è¤Þ¤Ã¤¿·å¿ô¤ò¤â¤Ã¤Æ¤¤¤ì¤Ð¡¢C ¤ÈƱ¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item MAXIMUM_SCALE (integer) =begin original The maximum scale of the data type. If a data type has a fixed scale, then C holds the same value. NULL (C) is returned for data types for which this is not applicable. =end original ¥Ç¡¼¥¿·¿¤ÎºÇÂç·å¿ô¡£ ¥Ç¡¼¥¿·¿¤¬·è¤Þ¤Ã¤¿·å¿ô¤ò¤â¤Ã¤Æ¤¤¤ì¤Ð¡¢C ¤ÈƱ¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤±¤ì¤Ð¡¢NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item SQL_DATA_TYPE (integer) =begin original This column is the same as the C column, except for interval and datetime data types. For interval and datetime data types, the C field will return C or C, and the C field below will return the subcode for the specific interval or datetime data type. If this field is NULL, then the driver does not support or report on interval or datetime subtypes. =end original ´ü´Ö(interval)¤ÈÆü»þ(datetime)·¿¤ò½ü¤¤¤Æ¤Ï¡¢¤³¤Î¥«¥é¥à¤Ï C ¤È Ʊ¤¸¤Ç¤¹¡£ ´ü´Ö(interval)¤ÈÆü»þ(datetime)·¿¤Ç¤¢¤ì¤Ð¡¢C ¤Ï C ¤â¤·¤¯¤Ï C ¤òÊÖ¤·¡¢°Ê²¼¤Î C ¤Ï ÆÃÄê¤Î´ü´Ö(interval)¤Þ¤¿¤ÏÆü»þ(datetime)·¿¤Î¤¿¤á¤Î¥µ¥Ö¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£ ¤â¤·¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ NULL ¤Ç¤¢¤ì¤Ð¡¢¥É¥é¥¤¥Ð¤Ï´ü´Ö(interval)¤Þ¤¿¤Ï Æü»þ(datetime)·¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¤«¡¢Êó¹ð¤·¤Þ¤»¤ó¡£ =item SQL_DATETIME_SUB (integer) =begin original For interval or datetime data types, where the C field above is C or C, this field will hold the I for the specific interval or datetime data type. Otherwise it will be NULL (C). =end original ´ü´Ö(interval)¤ÈÆü»þ(datetime)·¿¤Ç¤¢¤ì¤Ð¡¢¾åµ­¤Î C ¤Ï C ¤â¤·¤¯¤Ï C ¤òÊÖ¤·¡¢ ¤³¤Î¥Õ¥£¡¼¥ë¥É¤ÏÆÃÄê¤Î´ü´Ö(interval)¤Þ¤¿¤ÏÆü»þ(datetime)·¿¤Î¤¿¤á¤Î ¥µ¥Ö¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£ ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐNULL(undef)¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original Although not mentioned explicitly in the standards, it seems there is a simple relationship between these values: =end original ɸ½à¤Ë¤ÏÌÀ¼¨Åª¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¤¬¡¢¤³¤ì¤é¤ÎÃͤˤÏñ½ã¤Ê´Ø·¸¤¬ ¤¢¤ë¤è¤¦¤Ç¤¹: DATA_TYPE == (10 * SQL_DATA_TYPE) + SQL_DATETIME_SUB =item NUM_PREC_RADIX (integer) =begin original The radix value of the data type. For approximate numeric types, C contains the value 2 and C holds the number of bits. For exact numeric types, C contains the value 10 and C holds the number of decimal digits. NULL (C) is returned either for data types for which this is not applicable or if the driver cannot report this information. =end original ¤½¤Î¥Ç¡¼¥¿·¿¤Î´ð¿ô¤òÊÖ¤·¤Þ¤¹¡£ ³µ»»¤Î¿ôÃÍ·¿¤Ç¤Ï¡¢NUM_PREC_RADIX ¤ÎÃÍ¤Ï 2 ¤Ç COLUMN_SIZE ¤Ï¥Ó¥Ã¥È¤Î¿ô¤ò »ý¤Á¤Þ¤¹¡£ ¸·Ì©¤Ê¿ôÃÍ·¿¤Ç¤Ï C ¤ÎÃÍ¤Ï 10 ¤Ç¡¢COLUMN_SIZE ¤Ë¤Ï 10 ¿Ê¿ô¤Î·å¿ô¤¬Æþ¤ê¤Þ¤¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤¤¤«¡¢¥É¥é¥¤¥Ð¤¬¤³¤Î¾ðÊó¤òÊó¹ð¤Ç¤­¤Ê¤±¤ì¤Ð¡¢ NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =item INTERVAL_PRECISION (integer) =begin original The interval leading precision for interval types. NULL is returned either for data types for which this is not applicable or if the driver cannot report this information. =end original ´ü´Ö(interval)·¿¤Î¤¿¤á¤ÎÀè¹ÔÀºÅ٤Ǥ¹¡£ ¤³¤Î¥Ç¡¼¥¿·¿¤ËÅö¤Æ¤Ï¤Þ¤é¤Ê¤¤¤«¡¢¥É¥é¥¤¥Ð¤¬¤³¤Î¾ðÊó¤òÊó¹ð¤Ç¤­¤Ê¤±¤ì¤Ð¡¢ NULL (C) ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =back =begin original For example, to find the type name for the fields in a select statement you can do: =end original Î㤨¤Ð select ʸ¤Ç¤Î¥Õ¥£¡¼¥ë¥É¤Î¤¿¤á¤Î¥Ç¡¼¥¿·¿Ì¾¤ò¸«¤Ä¤±¤ë¤Ë¤Ï °Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹: @names = map { scalar $dbh->type_info($_)->{TYPE_NAME} } @{ $sth->{TYPE} } =begin original Since DBI and ODBC drivers vary in how they map their types into the ISO standard types you may need to search for more than one type. Here's an example looking for a usable type to store a date: =end original DBI ¤È ODBC ¥É¥é¥¤¥Ð¤È¤Ï·¿¤ò ISO ɸ½à·¿¤Ë¤É¤Î¤è¤¦¤Ë¥Þ¥Ã¥Ô¥ó¥°¤¹¤ë¤Î¤«¤¬ °Û¤Ê¤Ã¤Æ¤¤¤ë¤¿¤á¡¢°ì¤Ä°Ê¾å¤Î·¿¤òõ¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£ °Ê²¼¤ËÆüÉÕ¤ò³ÊǼ¤¹¤ë¤Î¤Ë»È¤¨¤ë¥Ç¡¼¥¿·¿¤òõ¤¹Îã¤ò¼¨¤·¤Þ¤¹: $my_date_type = $dbh->type_info( [ SQL_DATE, SQL_TIMESTAMP ] ); =begin original Similarly, to more reliably find a type to store small integers, you could use a list starting with C, C, C, etc. =end original Ʊ¤¸¤è¤¦¤Ë¡¢¾®¤µ¤ÊÀ°¿ô¤ò³ÊǼ¤¹¤ë¤¿¤á¤Î·¿¤Î¸¡º÷¤ò¿®Íê¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¡¢ C, C, C ¤Ê¤É¤«¤é»Ï¤Þ¤ë¥ê¥¹¥È¤ò »È¤¦¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ =begin original See also L. =end original L ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head3 C $sql = $dbh->quote($value); $sql = $dbh->quote($value, $data_type); =begin original Quote a string literal for use as a literal value in an SQL statement, by escaping any special characters (such as quotation marks) contained within the string and adding the required type of outer quotation marks. =end original ʸ»úÎó¤ÎÃæ¤Î(¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¥Þ¡¼¥¯¤Î¤è¤¦¤Ê)Æüì¤Êʸ»ú¤ò¥¨¥¹¥±¡¼¥×¤·¡¢ ɬÍפȤµ¤ì¤ë¥¿¥¤¥×¤Î³°Â¦¤Î¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¥Þ¡¼¥¯¤ò²Ã¤¨¤ë¤³¤È¤Ë¤è¤ê¡¢ ʸ»úÎó¥ê¥Æ¥é¥ë¤ò SQL ʸ¤Ç»È¤¦¥ê¥Æ¥é¥ëÃͤȤ·¤Æ»È¤¨¤ë¤è¤¦¤Ë¥¯¥©¡¼¥È¤·¤Þ¤¹¡£ $sql = sprintf "SELECT foo FROM bar WHERE baz = %s", $dbh->quote("Don't"); =begin original For most database types, at least those that conform to SQL standards, quote would return C<'Don''t'> (including the outer quotation marks). For others it may return something like C<'Don\'t'> =end original ¤Û¤È¤ó¤É¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢¾¯¤Ê¤¯¤È¤â SQL ɸ½à¤Ë½¾¤Ã¤Æ¤¤¤ë¤â¤Î¤Ê¤é¡¢ quote ¤Ï C<'Don"t'> ¤òÊÖ¤·¤Þ¤¹(³°Â¦¤Î¥¯¥©¡¼¥Æ¡¼¥·¥ç¥ó¥Þ¡¼¥¯¤ò´Þ¤ß¤Þ¤¹)¡£ ¤½¤Î¾¤Î¾ì¹ç¤Ï C<'Don\'t'> ¤Î¤è¤¦¤Ê¤â¤Î¤òÊÖ¤·¤Þ¤¹¡£ =begin original An undefined C<$value> value will be returned as the string C (without single quotation marks) to match how NULLs are represented in SQL. =end original ̤ÄêµÁ¤Î C<$value> ¤ÎÃÍ¤Ï SQL ¤Ç NULL ¤òɽ¤¹¤³¤È¤ËÂбþ¤¹¤ë¤è¤¦¡¢Ê¸»úÎó NULL (¥·¥ó¥°¥ë¥¯¥©¡¼¥Æ¥·¥ç¥ó¥Þ¡¼¥¯¤Ê¤·)¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original If C<$data_type> is supplied, it is used to try to determine the required quoting behaviour by using the information returned by L. As a special case, the standard numeric types are optimized to return C<$value> without calling C. =end original C<$data_type> ¤¬Í¿¤¨¤é¤ì¤ë¤È¡¢L ¤«¤éÊÖ¤µ¤ì¤ë¾ðÊó¤ò¸µ¤Ë¤·¤Æ Í׵ᤵ¤ì¤¿¥¯¥©¡¼¥È¤Î½èÍý¤ò·è¤á¤Þ¤¹¡£ Æüì¤Ê¾ì¹ç¤È¤·¤Æ¡¢É¸½à¤Î¿ôÃÍ·¿¤Ï C ¤ò¸Æ¤Ð¤º¤Ë¡¢C<$value> ¤ò ÊÖ¤¹¤è¤¦¤ËºÇŬ²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original Quote will probably I be able to deal with all possible input (such as binary data or data containing newlines), and is not related in any way with escaping or quoting shell meta-characters. =end original quote ¤Ï(¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ä²þ¹Ô¤¬Æþ¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿¤Î¤è¤¦¤Ë)¤¹¤Ù¤Æ¤ÎÆþÎÏ¤Ë Âбþ¤Ç¤­¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó; ¤½¤·¤Æ¥·¥§¥ë¤Î¥¨¥¹¥±¡¼¥×¤ä¥á¥¿Ê¸»ú¤Ë¤Ï¤Þ¤Ã¤¿¤¯ ´ØÏ¢¤·¤Æ¤Ï¤¤¤Þ¤»¤ó¡£ =begin original It is valid for the quote() method to return an SQL expression that evaluates to the desired string. For example: =end original ɬÍפÊʸ»úÎó¤òɾ²Á¤¹¤ë SQL ¼°¤òÊÖ¤¹¤¿¤á¤Î quote() ¥á¥½¥Ã¥É¤âÍ­¸ú¤Ç¤¹¡£ Î㤨¤Ð: $quoted = $dbh->quote("one\ntwo\0three") =begin original may return something like: =end original ¤È¤¤¤¦¤â¤Î¤Ï°Ê²¼¤Î¤è¤¦¤Ê¤â¤Î¤òÊÖ¤·¤Þ¤¹: CONCAT('one', CHAR(12), 'two', CHAR(0), 'three') =begin original The quote() method should I be used with L. =end original quote() ¥á¥½¥Ã¥É¤Ï L ¤È»È¤¦¤Ù¤­¤Ç¤Ï I<¤¢¤ê¤Þ¤»¤ó> ¡£ =head3 C $sql = $dbh->quote_identifier( $name ); $sql = $dbh->quote_identifier( $catalog, $schema, $table, \%attr ); =begin original Quote an identifier (table name etc.) for use in an SQL statement, by escaping any special characters (such as double quotation marks) it contains and adding the required type of outer quotation marks. =end original SQLʸ¤Ç»ÈÍѤ¹¤ë¼±ÊÌ»Ò(¥Æ¡¼¥Ö¥ë̾¤Ê¤É)¤ò°úÍÑÉä¤Ç°Ï¤à¤Ë¤Ï¡¢¼±Ê̻Ҥ˴ޤޤì¤ëÆüìʸ»ú(Æó½Å°úÍÑÉä¤Ê¤É)¤ò¥¨¥¹¥±¡¼¥×¤·¡¢É¬Íפʥ¿¥¤¥×¤Î³°Éô°úÍÑÉä¤òÄɲä·¤Þ¤¹¡£ (TBR) =begin original Undefined names are ignored and the remainder are quoted and then joined together, typically with a dot (C<.>) character. For example: =end original ̤ÄêµÁ¤Î̾Á°¤Ï̵»ë¤µ¤ì¡¢»Ä¤ê¤Ï¥¯¥©¡¼¥È¤µ¤ì¤Æ¤«¤é¸ß¤¤¤Ë (ŵ·¿Åª¤Ë¤Ï¥É¥Ã¥È (C<.>) ʸ»ú¤Ç)·ë¹ç¤µ¤ì¤Þ¤¹¡£ Î㤨¤Ð: $id = $dbh->quote_identifier( undef, 'Her schema', 'My table' ); =begin original would, for most database types, return C<"Her schema"."My table"> (including all the double quotation marks). =end original ¤È¤¤¤¦¤Î¤Ï¡¢¤Û¤È¤ó¤É¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹·¿¤Ç¤Ï¡¢ C<"Her schema"."My table"> (¥À¥Ö¥ë¥¯¥©¡¼¥È¤ò´Þ¤ß¤Þ¤¹) ¤òÊÖ¤·¤Þ¤¹¡£ =begin original If three names are supplied then the first is assumed to be a catalog name and special rules may be applied based on what L returns for SQL_CATALOG_NAME_SEPARATOR (41) and SQL_CATALOG_LOCATION (114). For example, for Oracle: =end original 3¤Ä¤Î̾Á°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢ºÇ½é¤Î̾Á°¤Ï¥«¥¿¥í¥°Ì¾¤È¸«¤Ê¤µ¤ì¡¢L¤¬SQL_CATALOG_NAME_SEPARATOR(41)¤ª¤è¤ÓSQL_CATALOG_LOCATION(114)¤ËÂФ·¤ÆÊÖ¤¹ÆâÍƤ˴ð¤Å¤¤¤ÆÆÃÊ̤ʥ롼¥ë¤¬Å¬ÍѤµ¤ì¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢Oracle¤Î¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) $id = $dbh->quote_identifier( 'link', 'schema', 'table' ); =begin original would return C<"schema"."table"@"link">. =end original ¤Ï C<"schema"."table"@"link"> ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C $imp_data = $dbh->take_imp_data; =begin original Leaves the $dbh in an almost dead, zombie-like, state and returns a binary string of raw implementation data from the driver which describes the current database connection. Effectively it detaches the underlying database API connection data from the DBI handle. After calling take_imp_data(), all other methods except C will generate a warning and return undef. =end original $dbh¤ò¤Û¤È¤ó¤ÉÆ°¤«¤Ê¤¤¡¢¥¾¥ó¥Ó¤Î¤è¤¦¤Ê¾õÂ֤Τޤޤˤ·¤Æ¡¢¸½ºß¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤òµ­½Ò¤¹¤ë¥É¥é¥¤¥Ð¤«¤é¤ÎÀ¸¤Î¼ÂÁõ¥Ç¡¼¥¿¤Î¥Ð¥¤¥Ê¥êʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£ ¼Â¼ÁŪ¤Ë¡¢´ðÁäȤʤë¥Ç¡¼¥¿¥Ù¡¼¥¹APIÀܳ¥Ç¡¼¥¿¤òDBI¥Ï¥ó¥É¥ë¤«¤éÀÚ¤êÎ¥¤·¤Þ¤¹¡£ take_imp_data()¤ò¸Æ¤Ó½Ð¤·¤¿¸å¡¢C¤ò½ü¤¯Â¾¤Î¤¹¤Ù¤Æ¤Î¥á¥½¥Ã¥É¤Ï·Ù¹ð¤òÀ¸À®¤·¡¢undef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original Why would you want to do this? You don't, forget I even mentioned it. Unless, that is, you're implementing something advanced like a multi-threaded connection pool. See L. =end original ¤Ê¤¼¤¢¤Ê¤¿¤Ï¤³¤ì¤ò¤·¤¿¤¤¤Î¤Ç¤¹¤«?¤¢¤Ê¤¿¤Ï¤·¤Þ¤»¤ó¡¢»ä¤¬¤½¤ì¤ò¸À¤Ã¤¿¤³¤È¤µ¤¨Ëº¤ì¤Æ¤¯¤À¤µ¤¤¡£ ¤¿¤À¤·¡¢¥Þ¥ë¥Á¥¹¥ì¥Ã¥ÉÀܳ¥×¡¼¥ë¤Î¤è¤¦¤Ê¹âÅ٤ʤâ¤Î¤ò¼ÂÁõ¤·¤Æ¤¤¤ë¾ì¹ç¤Ï½ü¤­¤Þ¤¹¡£ L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The returned $imp_data can be passed as a C attribute to a later connect() call, even in a separate thread in the same process, where the driver can use it to 'adopt' the existing connection that the implementation data was taken from. =end original ÊÖ¤µ¤ì¤¿$imp_data¤Ï¡¢¸å¤Îconnect()¸Æ¤Ó½Ð¤·¤ËC¤Î°À­¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ Ʊ¤¸¥×¥í¥»¥¹Æâ¤ÎÊ̤Υ¹¥ì¥Ã¥É¤Ç¤¢¤Ã¤Æ¤â¤«¤Þ¤¤¤Þ¤»¤ó¡£ ¥É¥é¥¤¥Ð¤Ï¡¢¤³¤Î°À­¤ò»ÈÍѤ·¤Æ¡¢¼ÂÁõ¥Ç¡¼¥¿¤¬¼èÆÀ¤µ¤ì¤¿´û¸¤ÎÀܳ¤ò¡ÖºÎÍѡפǤ­¤Þ¤¹¡£ (TBR) =begin original Some things to keep in mind... =end original ³Ð¤¨¤Æ¤ª¤¯¤Ù¤­¤³¤È¤Ï¡Ä =begin original B<*> the $imp_data holds the only reference to the underlying database API connection data. That connection is still 'live' and won't be cleaned up properly unless the $imp_data is used to create a new $dbh which is then allowed to disconnect() normally. =end original B<*>$imp_data¤Ï¡¢´ðÁäȤʤë¥Ç¡¼¥¿¥Ù¡¼¥¹APIÀܳ¥Ç¡¼¥¿¤Ø¤ÎÍ£°ì¤Î»²¾È¤òÊÝ»ý¤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ÎÀܳ¤Ï¤Þ¤À¡ÖÍ­¸ú¡×¤Ç¤¢¤ê¡¢$imp_data¤ò»ÈÍѤ·¤Æ¿·¤·¤¤$dbh¤òºîÀ®¤·¡¢Ä̾ï¤É¤ª¤êdisconnect()¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Ê¤¤¸Â¤ê¡¢Å¬Àڤ˥¯¥ê¡¼¥ó¥¢¥Ã¥×¤µ¤ì¤Þ¤»¤ó¡£ (TBR) =begin original B<*> using the same $imp_data to create more than one other new $dbh at a time may well lead to unpleasant problems. Don't do that. =end original B<*>Ʊ¤¸$imp_data¤ò»ÈÍѤ·¤Æ°ìÅÙ¤ËÊ£¿ô¤Î¿·¤·¤¤$dbh¤òºîÀ®¤¹¤ë¤È¡¢ÉÔ²÷¤ÊÌäÂ꤬ȯÀ¸¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤ó¤Ê¤³¤È¤·¤Ê¤¤¤Ç¡£ (TBR) =begin original Any child statement handles are effectively destroyed when take_imp_data() is called. =end original »Òʸ¥Ï¥ó¥É¥ë¤Ï¡¢take_imp_data() ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤ÈÀµ¤·¤¯Ç˲õ¤µ¤ì¤Þ¤¹¡£ =begin original The C method was added in DBI 1.36 but wasn't useful till 1.49. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.36 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¤¬ 1.49 ¤Þ¤Ç¤ÏÍ­ÍѤǤϤ¢¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£ =head2 Database Handle Attributes (¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë°À­) =begin original This section describes attributes specific to database handles. =end original ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ç¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ËÆÃÍ­¤Î°À­¤Ë¤Ä¤¤¤Æµ­½Ò¤·¤Þ¤¹¡£ =begin original Changes to these database handle attributes do not affect any other existing or future database handles. =end original ¤³¤ì¤é¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë°À­¤òÊѹ¹¤·¤Æ¤â¡¢´û¸¤Î¾¤Î ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤¢¤ë¤¤¤Ï¤³¤Î¸å¡¢À¸À®¤µ¤ì¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Ë¤Ï ±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó¡£ =begin original Attempting to set or get the value of an unknown attribute generates a warning, except for private driver-specific attributes (which all have names starting with a lowercase letter). =end original ¥É¥é¥¤¥ÐÆÃÍ­¤Î¥×¥é¥¤¥Ù¡¼¥È¤Ê°À­(¤³¤ì¤é¤Î̾Á°¤Ï¾®Ê¸»ú¤Ç¤Ï¤¸¤Þ¤ê¤Þ¤¹)¤ò ½ü¤¤¤Æ¤Ï¡¢·è¤á¤é¤ì¤Æ¤¤¤Ê¤¤Â°À­¤òÀßÄꤢ¤ë¤¤¤Ï¼èÆÀ¤·¤è¤¦¤È¤¹¤ë¤È ·Ù¹ð¤¬È¯À¸¤·¤Þ¤¹¡£ =begin original Example: =end original Îã: $h->{AutoCommit} = ...; # set/write ... = $h->{AutoCommit}; # get/read =head3 C (boolean) =begin original If true, then database changes cannot be rolled-back (undone). If false, then database changes automatically occur within a "transaction", which must either be committed or rolled back using the C or C methods. =end original ¿¿¤Ç¤¢¤ì¤Ð¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÊѹ¹¤ò¥í¡¼¥ë¥Ð¥Ã¥¯¤¹¤ë(¸µ¤ËÌ᤹)¤³¤È¤Ï ¤Ç¤­¤Þ¤»¤ó¡£ µ¶¤Ç¤¢¤ì¤Ð¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÊѹ¹¤Ï¼«Æ°Åª¤Ë¡Ö¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¡×¤ÎÃæ¤ËÆþ¤ê¡¢ C ¤Þ¤¿¤Ï C ¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ¥³¥ß¥Ã¥È¤¢¤ë¤¤¤Ï ¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original Drivers should always default to C mode (an unfortunate choice largely forced on the DBI by ODBC and JDBC conventions.) =end original ¥É¥é¥¤¥Ð¤Ï¥Ç¥Õ¥©¥ë¥È¤ò C ¥â¡¼¥É¤Ë¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó (ODBC ¤È JDBC ¤Î·è¤Þ¤ê¤Ë¤è¤ê¡¢»ÄÇ°¤Ê¤¬¤é DBI ¤Ï¤³¤¦¤»¤¶¤ë¤òÆÀ¤Þ¤»¤ó¡£) =begin original Attempting to set C to an unsupported value is a fatal error. This is an important feature of the DBI. Applications that need full transaction behaviour can set C<$dbh-E{AutoCommit} = 0> (or set C to 0 via L) without having to check that the value was assigned successfully. =end original C ¤ò¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤ÃͤËÀßÄꤷ¤è¤¦¤È¤¹¤ë¤È¡¢Ã×̿Ū¤Ê ¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤ì¤Ï DBI ¤Î½ÅÍפʵ¡Ç½¤Ç¤¹¡£ ´°Á´¤Ê¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òɬÍפȤ¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢Ãͤ¬Àµ¤·¤¯ÂåÆþ¤µ¤ì¤¿¤« ¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤³¤È¤Ê¤¯ C<$dbh-E{AutoCommit} = 0> ¤È ¤¹¤ë(¤Þ¤¿¤Ï L ¥á¥½¥Ã¥É¤Ç¤Î C ¤ò 0 ¤ËÀßÄꤹ¤ë)¤³¤È¤¬ ¤Ç¤­¤Þ¤¹¡£ =begin original For the purposes of this description, we can divide databases into three categories: =end original ¤³¤ÎÅÀ¤«¤é¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò»°¤Ä¤Î¥«¥Æ¥´¥ê¤Ëʬ¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original Databases which don't support transactions at all. Databases in which a transaction is always active. Databases in which a transaction must be explicitly started (C<'BEGIN WORK'>). =end original Á´¤¯¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹ ¤¤¤Ä¤Ç¤â¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Í­¸ú¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹ ÌÀ¼¨Åª¤Ë¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï(C<'BEGIN WORK'>¤Ê¤É¤Ë¤è¤ê)¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Ê¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹ =begin original B<* Databases which don't support transactions at all> =end original B<* Á´¤¯¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹> =begin original For these databases, attempting to turn C off is a fatal error. C and C both issue warnings about being ineffective while C is in effect. =end original ¤³¤ì¤é¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¡¢C ¤ò¥ª¥Õ¤Ë¤·¤è¤¦¤È¤¹¤ë¤È Ã×̿Ū¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£ C, C ¤Ï C ¤¬Í­¸ú¤Ê´Ö¤Ï̵¸ú¤Ç¤¢¤ë¤È¤¤¤¦ ·Ù¹ð¤òµ¯¤³¤·¤Þ¤¹¡£ =begin original B<* Databases in which a transaction is always active> =end original B<* ¤¤¤Ä¤Ç¤â¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬Í­¸ú¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹> =begin original These are typically mainstream commercial relational databases with "ANSI standard" transaction behaviour. If C is off, then changes to the database won't have any lasting effect unless L is called (but see also L). If L is called then any changes since the last commit are undone. =end original ¡ÖANSIɸ½à¡×¥È¥é¥ó¥¶¥¯¥·¥ç¥óµ¡Ç½¤ò»ý¤Ã¤¿¾¦ÍÑ¥ê¥ì¡¼¥·¥ç¥Ê¥ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢ ¤³¤ì¤¬¼çή¤Ç¤¹¡£ C ¤¬¥ª¥Õ¤Ç¤¢¤ë¤È¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤ÎÊѹ¹¤Ï L ¤µ¤ì¤ë¤Þ¤Ç Í­¸ú¤Ë¤Ê¤ê¤Þ¤»¤ó (¤·¤«¤· L ¤â¤´Í÷¤¯¤À¤µ¤¤)¡£ ¤â¤· L ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢ºÇ¸å¤Î¥³¥ß¥Ã¥È°Ê¹ß¤Î¤¤¤«¤Ê¤ëÊѹ¹¤â¸µ¤Ë Ìᤵ¤ì¤Þ¤¹¡£ =begin original If C is on, then the effect is the same as if the DBI called C automatically after every successful database operation. So calling C or C explicitly while C is on would be ineffective because the changes would have already been committed. =end original C ¤¬¥ª¥ó¤Ç¤¢¤ë¤È¡¢DBI ¤Ï¤Þ¤ë¤ÇÀµ¾ï½ªÎ»¤·¤¿¥Ç¡¼¥¿¥Ù¡¼¥¹Áàºî¤Î¸å¡¢ ¼«Æ°Åª¤Ë C ¤ò¸Æ¤ó¤Ç¤¤¤ë¤Î¤ÈƱ¤¸¤è¤¦¤Ë¿¶¤ëÉñ¤¤¤Þ¤¹¡£ ½¾¤Ã¤Æ C ¤¬¥ª¥ó¤Î´Ö¤Ë C, C ¤òÌÀ¼¨Åª¤Ë ¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤¹¤Ç¤Ë¥³¥ß¥Ã¥È¤µ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢²¿¤â¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡£ =begin original Changing C from off to on will trigger a L. =end original C ¤ò¥ª¥Õ¤«¤é¥ª¥ó¤ËÊѤ¨¤ë¤È¡¢ÂçÄñ¤Î¥É¥é¥¤¥Ð¤Ï L ¤·¤Þ¤¹¡£ =begin original For databases which don't support a specific auto-commit mode, the driver has to commit each statement automatically using an explicit C after it completes successfully (and roll it back using an explicit C if it fails). The error information reported to the application will correspond to the statement which was executed, unless it succeeded and the commit or rollback failed. =end original ¼«Æ°¥³¥ß¥Ã¥È¥â¡¼¥É¤òÆä˥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢¥É¥é¥¤¥Ð¤Ï ³Æʸ¤¬Àµ¾ï½ªÎ»¤·¤¿¤é¡¢ÌÀ¼¨Åª¤Ë C ¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢ ¼«Æ°Åª¤Ë¥³¥ß¥Ã¥È¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó(¼ºÇÔ¤·¤¿¤éÌÀ¼¨Åª¤Ë C ¤·¤Æ ¸µ¤ËÌᤵ¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó)¡£ ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÅÁ¤¨¤é¤ì¤ë¥¨¥é¡¼¾ðÊó¤Ï¡¢Ê¸¤¬Àµ¾ï½ªÎ»¤·¤¿¸å¡¢ ¥³¥ß¥Ã¥È¤ä¥í¡¼¥ë¥Ð¥Ã¥¯¤¬¼ºÇÔ¤·¤Ê¤¤¸Â¤ê¤Ï¡¢¼Â¹Ô¤µ¤ì¤¿Ê¸¤Ë Âбþ¤·¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£ =begin original B<* Databases in which a transaction must be explicitly started> =end original B<* ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬ÌÀ¼¨Åª¤Ë³«»Ï¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¥Ç¡¼¥¿¥Ù¡¼¥¹> =begin original For these databases, the intention is to have them act like databases in which a transaction is always active (as described above). =end original ¤³¤ì¤é¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï(¾åµ­¤Î¤è¤¦¤Ê)¤¤¤Ä¤Ç¤â Í­¸ú¤Ë¤Ê¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÈƱ¤¸¤è¤¦¤Ë¤·¤Þ¤¹¡£ =begin original To do this, the driver will automatically begin an explicit transaction when C is turned off, or after a L or L (or when the application issues the next database operation after one of those events). =end original ¤³¤¦¤¹¤ë¤¿¤á¡¢¥É¥é¥¤¥Ð¤Ï C ¤¬¥ª¥Õ¤Ë¤Ê¤ë¤«¡¢ L ¤ä L ¤Î¸å(¤¢¤ë¤¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¤³¤ì¤é¤Î ¥¤¥Ù¥ó¥È¤Î°ì¤Ä¤Î¸å¼¡¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹Áàºî¤ò¹Ô¤Ã¤¿¤È¤­)¡¢¼«Æ°Åª¤Ë ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤·¤Þ¤¹¡£ =begin original In this way, the application does not have to treat these databases as a special case. =end original ¤³¤¦¤·¤Æ¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ì¤é¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤òÆÃÊ̤ʥ±¡¼¥¹¤È¤·¤Æ °·¤ï¤Ê¤¯¤Æ¤â¤è¤¯¤Ê¤ë¤Î¤Ç¤¹¡£ =begin original See L, L and L for other important notes about transactions. =end original ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤Î¤Û¤«¤Î½ÅÍפʾðÊó¤Ë¤Ä¤¤¤Æ¤Ï L, L, L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C (handle) =begin original Holds the handle of the parent driver. The only recommended use for this is to find the name of the driver using: =end original ¥Ï¥ó¥É¥ë¤Î¿Æ¥É¥é¥¤¥Ð¤òÊÝ»ý¤·¤Þ¤¹¡£ Í£°ì¿ä¾©¤µ¤ì¤ë¤³¤ì¤Î»È¤¤Êý¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¥É¥é¥¤¥Ð¤Î̾Á°¤ò ¸«¤Ä¤±¤ë¤³¤È¤À¤±¤Ç¤¹: $dbh->{Driver}->{Name} =head3 C (string) =begin original Holds the "name" of the database. Usually (and recommended to be) the same as the "C" string used to connect to the database, but with the leading "C" removed. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î̾Á°¤¬Æþ¤ê¤Þ¤¹¡£ Ä̾ï¤Ï(¤½¤·¤Æ¿ä¾©¤µ¤ì¤ë¤³¤È¤Ç¤¹¤¬)¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤ÎÀܳ¤Ë»È¤ï¤ì¤ë "C" ʸ»úÎ󤫤éÀèƬ¤Î "C" ¤ò ¼è¤Ã¤¿¤â¤Î¤Ë¤Ê¤ê¤Þ¤¹¡£ =head3 C (string, read-only) =begin original Returns the statement string passed to the most recent L method called in this database handle, even if that method failed. This is especially useful where C is enabled and the exception handler checks $@ and sees that a 'prepare' method call failed. =end original ¤³¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤ÇºÇ¸å¤Î L ¥á¥½¥Ã¥É¤ËÅϤµ¤ì¤¿ ʸʸ»úÎó¤òÊÖ¤·¤Þ¤¹¡£ ¤â¤·¤½¤Î¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤Æ¤¤¤¿¤È¤·¤Æ¤â¤Ç¤¹¡£ ¤³¤ì¤Ï C ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢Îã³°¥Ï¥ó¥É¥é¤¬ $@ ¤ò¥Á¥§¥Ã¥¯¤·¡¢ 'prepare' ¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤¿¤«¤â¤·¤ì¤Ê¤¤¤È»×¤ï¤ì¤ë¤È¤­¤Ë¤ÏÆäËÊØÍø¤Ç¤·¤ç¤¦¡£ =head3 C (integer) =begin original A hint to the driver indicating the size of the local row cache that the application would like the driver to use for future C ʸ¤Î¤¿¤á¤Ë»È¤ï¤»¤¿¤¤ ¥í¡¼¥«¥ë¤Ê¹Ô¥­¥ã¥Ã¥·¥å¤ÎÂ礭¤µ¤ò¼¨¤¹¥É¥é¥¤¥Ð¤Ø¤Î¥Ò¥ó¥È¤Ç¤¹¡£ ¹Ô¥­¥ã¥Ã¥·¥å¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢C ¤ÎÀßÄê¤Ï̵»ë¤µ¤ì¡¢ÃÍ¤Ï C ¤¬ÊÖ¤ê¤Þ¤¹¡£ =begin original Some C values have special meaning, as follows: =end original C ¤ÎÃͤˤϰʲ¼¤Î¤è¤¦¤Ê°ÕÌ£¤¬¤¢¤ê¤Þ¤¹: =begin original 0 - Automatically determine a reasonable cache size for each C. =end original 0 - ¼«Æ°Åª¤Ë³Æ C ¤Î¤¿¤á¤Ë¥á¥â¥ê¤ÎÎ̤˹ç¤ï¤»¤Æ¤Ç¤­¤ë¤À¤±Â¿¤¯¤Î¹Ô¤ò¥­¥ã¥Ã¥·¥å¤·¤Þ¤¹ =begin original Note that large cache sizes may require a very large amount of memory (I). Also, a large cache will cause a longer delay not only for the first fetch, but also whenever the cache needs refilling. =end original ¥­¥ã¥Ã¥·¥å¤ÎÂ礭¤µ¤òÂ礭¤¯¤¹¤ë¤ÈÂçÎ̤Υá¥â¥ê¤¬É¬Íפˤʤ뤳¤È (¥­¥ã¥Ã¥·¥å¤µ¤ì¤ë¹Ô¤Î¿ô¡ß¹Ô¤ÎºÇÂ祵¥¤¥º)¡¢¤½¤·¤ÆÂ礭¤Ê¥­¥ã¥Ã¥·¥å¤ò¤È¤ë¤È ¤½¤ì¤À¤±ºÇ½é¤Î¼èÆÀ¤¢¤ë¤¤¤Ï¼¡¤Î¥­¥ã¥Ã¥·¥åʬ¤ò¼èÆÀ¤Î¤µ¤¤¤Ë»þ´Ö¤¬¤«¤«¤ë¤è¤¦¤Ë ¤Ê¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original See also the L statement handle attribute. =end original L ʸ¥Ï¥ó¥É¥ë°À­¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C (string) =begin original Returns the username used to connect to the database. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¤È¤ÎÀܳ¤Ë»È¤ï¤ì¤¿¥æ¡¼¥¶¡¼Ì¾¤òÊÖ¤·¤Þ¤¹¡£ =head1 DBI STATEMENT HANDLE OBJECTS (DBI ʸ¥Ï¥ó¥É¥ë¥ª¥Ö¥¸¥§¥¯¥È) =begin original This section lists the methods and attributes associated with DBI statement handles. =end original ¤³¤ÎÀá¤Ç¤Ï DBI ʸ¥Ï¥ó¥É¥ë¤Ë´ØÏ¢¤¹¤ë¥á¥½¥Ã¥É¤È°À­¤ò°ìÍ÷¤Ë¤·¤Þ¤¹¡£ =head2 Statement Handle Methods (ʸ¥Ï¥ó¥É¥ë¥á¥½¥Ã¥É) =begin original The DBI defines the following methods for use on DBI statement handles: =end original DBI ¤Ï DBI ʸ¥Ï¥ó¥É¥ë¤Î¤¿¤á¤Ë°Ê²¼¤Î¥á¥½¥Ã¥É¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹: =head3 C $sth->bind_param($p_num, $bind_value) $sth->bind_param($p_num, $bind_value, \%attr) $sth->bind_param($p_num, $bind_value, $bind_type) =begin original The C method takes a copy of $bind_value and associates it (binds it) with a placeholder, identified by $p_num, embedded in the prepared statement. Placeholders are indicated with question mark character (C). For example: =end original C ¥á¥½¥Ã¥É¤Ï $bind_value ¤Î¥³¥Ô¡¼¤ò¼è¤Ã¤Æ¡¢prepared ʸ¤Ë Ëä¤á¹þ¤Þ¤ì¤Æ¤¤¤ë¡¢$p_num ¤Ç¼±Ê̤µ¤ì¤ë¥×¥ì¡¼¥¹¥Û¥ë¥À¤È·ë¤Ó¤Ä¤±¤Þ¤¹¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ïµ¿ÌäÉä(C)¤Ë¤è¤ê¼¨¤µ¤ì¤Þ¤¹¡£ Î㤨¤Ð: =begin original $dbh->{RaiseError} = 1; # save having to check each method call $sth = $dbh->prepare("SELECT name, age FROM people WHERE name LIKE ?"); $sth->bind_param(1, "John%"); # placeholders are numbered from 1 $sth->execute; DBI::dump_results($sth); =end original $dbh->{RaiseError} = 1; # ³Æ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤è¤¦¤Ë¤¹¤ë $sth = $dbh->prepare("select name, age from people where name like ?"); $sth->bind_param(1, "John%"); # ¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï 1 ¤«¤é½çÈÖ $sth->execute; DBI::dump_results($sth); =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò »²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original B =end original B<¥×¥ì¡¼¥¹¥Û¥ë¥À¤Î¥Ç¡¼¥¿·¿> =begin original The C<\%attr> parameter can be used to hint at the data type the placeholder should have. This is rarely needed. Typically, the driver is only interested in knowing if the placeholder should be bound as a number or a string. =end original C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤¬»ý¤Ä¤Ù¤­¥Ç¡¼¥¿·¿¤ò»ØÄꤹ¤ë¤¿¤á¤Ë »È¤ï¤ì¤Þ¤¹¡£ Ä̾¥É¥é¥¤¥Ð¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤¬·ë¤Ó¤Ä¤±¤é¤ì¤ë¤Î¤¬¿ôÃͤȤ·¤Æ¤Ê¤Î¤«¡¢ ʸ»úÎó¤È¤·¤Æ¤Ê¤Î¤«¤òÃΤ뤳¤È¤À¤±¤Ë´Ø¿´¤¬¤¢¤ê¤Þ¤¹¡£ $sth->bind_param(1, $value, { TYPE => SQL_INTEGER }); =begin original As a short-cut for the common case, the data type can be passed directly, in place of the C<\%attr> hash reference. This example is equivalent to the one above: =end original ¤è¤¯¤¢¤ë¥±¡¼¥¹¤Î¤¿¤á¤Îû½Ì·Á¤È¤·¤Æ¡¢¥Ç¡¼¥¿·¿¤òľÀÜ C<\%attr> ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¾ì½ê¤ËľÀÜ¡¢ÅϤ¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤³¤ÎÎã¤Ï¡¢¾åµ­¤Î¤â¤Î¤ÈƱ¤¸¤Ç¤¹¡£ $sth->bind_param(1, $value, SQL_INTEGER); =begin original The C value indicates the standard (non-driver-specific) type for this parameter. To specify the driver-specific type, the driver may support a driver-specific attribute, such as C<{ ora_type =E 97 }>. =end original C ¤ÎÃͤϤ³¤Î¥Ñ¥é¥á¡¼¥¿¤Ç¤Ï(¥É¥é¥¤¥Ð¤ËÆÃÍ­¤Ç¤Ê¤¤)ɸ½à¤Î·¿¤ò¼¨¤·¤Þ¤¹¡£ ¥É¥é¥¤¥ÐÆÃÍ­¤Î·¿¤ò»ØÄꤹ¤ë¤¿¤á¤Ë¡¢¥É¥é¥¤¥Ð¤Ï C<{ ora_type => 97 }> ¤È¤¤¤Ã¤¿ ¥É¥é¥¤¥ÐÆÃÍ­¤Î·¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ =begin original The SQL_INTEGER and other related constants can be imported using =end original SQL_INTEGER ¤ª¤è¤Ó´ØÏ¢¤¹¤ëÄê¿ô¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¥¤¥ó¥Ý¡¼¥È¤Ç¤­¤Þ¤¹ use DBI qw(:sql_types); =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original The data type is 'sticky' in that bind values passed to execute() are bound with the data type specified by earlier bind_param() calls, if any. Portable applications should not rely on being able to change the data type after the first C call. =end original ¥Ç¡¼¥¿·¿¤Ï'sticky'¤Ç¡¢execute()¤ËÅϤµ¤ì¤¿¥Ð¥¤¥ó¥ÉÃͤϡ¢Á°¤Îbind_param()¸Æ¤Ó½Ð¤·¤Ç»ØÄꤵ¤ì¤¿¥Ç¡¼¥¿·¿¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Þ¤¹(¸ºß¤¹¤ë¾ì¹ç)¡£ °Ü¿¢À­¤Î¤¢¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢ºÇ½é¤ÎC¸Æ¤Ó½Ð¤·¤Î¸å¤Ë¥Ç¡¼¥¿·¿¤òÊѹ¹¤Ç¤­¤ë¤³¤È¤Ë°Í¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ (TBR) =begin original Perl only has string and number scalar data types. All database types that aren't numbers are bound as strings and must be in a format the database will understand except where the bind_param() TYPE attribute specifies a type that implies a particular format. For example, given: =end original Perl¤Ë¤Ï¡¢Ê¸»úÎó¤È¿ôÃͤΥ¹¥«¥é¡¼¥Ç¡¼¥¿·¿¤·¤«¤¢¤ê¤Þ¤»¤ó¡£ ¿ôÃͰʳ°¤Î¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥¿¥¤¥×¤Ïʸ»úÎó¤È¤·¤Æ¥Ð¥¤¥ó¥É¤µ¤ì¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬Íý²ò¤Ç¤­¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ ¤¿¤À¤·¡¢bind_param()TYPE°À­¤¬ÆÃÄê¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò¼¨¤¹¥¿¥¤¥×¤ò»ØÄꤷ¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤­¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) $sth->bind_param(1, $value, SQL_DATETIME); =begin original the driver should expect $value to be in the ODBC standard SQL_DATETIME format, which is 'YYYY-MM-DD HH:MM:SS'. Similarly for SQL_DATE, SQL_TIME etc. =end original ¥É¥é¥¤¥Ð¤Ï¡¢$value¤¬ODBCɸ½à¤ÎSQL_DATETIME·Á¼°('YYYY-MM-DD HH:MM:SS')¤Ç¤¢¤ë¤³¤È¤òÁÛÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ SQL_DATE¡¢SQL_TIME¤Ê¤É¤Ë¤Ä¤¤¤Æ¤âƱÍͤǤ¹¡£ (TBR) =begin original As an alternative to specifying the data type in the C call, you can let the driver pass the value as the default type (C). You can then use an SQL function to convert the type within the statement. For example: =end original ¥Ç¡¼¥¿·¿¤ò C ¸Æ¤Ó½Ð¤·¤ÎºÝ¤Ë»ØÄꤹ¤ëÂå¤ï¤ê¤Ë¡¢¥É¥é¥¤¥Ð¤Ë ¥Ç¡¼¥¿¤ò¥Ç¥Õ¥©¥ë¥È¤Î·¿(C)¤È¤·¤ÆÅϤ¹¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¤½¤·¤Æ SQL ´Ø¿ô¤Çʸ¤ÎÃæ¤ÇÊÑ´¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð: INSERT INTO price(code, price) VALUES (?, CONVERT(MONEY,?)) =begin original The C function used here is just an example. The actual function and syntax will vary between different databases and is non-portable. =end original C ´Ø¿ô¤Ïñ¤Ê¤ëÎã¤È¤·¤Æ»È¤ï¤ì¤Æ¤¤¤Þ¤¹¡£ ¼ÂºÝ¤Î´Ø¿ô¤È½ñ¤­Êý¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤è¤Ã¤ÆÂ礭¤¯°ã¤¤¤Þ¤¹¤·¡¢°Ü¿¢À­¤â¤¢¤ê¤Þ¤»¤ó¡£ =begin original See also L for more information. =end original ¾Ü¤·¤¤¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤â¤´Í÷²¼¤µ¤¤¡£ =head3 C $rc = $sth->bind_param_inout($p_num, \$bind_value, $max_len) or die $sth->errstr; $rv = $sth->bind_param_inout($p_num, \$bind_value, $max_len, \%attr) or ... $rv = $sth->bind_param_inout($p_num, \$bind_value, $max_len, $bind_type) or ... =begin original This method acts like L, but also enables values to be updated by the statement. The statement is typically a call to a stored procedure. The C<$bind_value> must be passed as a reference to the actual value to be used. =end original ¤³¤Î¥á¥½¥Ã¥É¤Ï L ¤È»÷¤Æ¤¤¤Þ¤¹¤¬¡¢Ê¸¤«¤é¤Î¹¹¿·¤â ²Äǽ¤È¤·¤Æ¤¤¤Þ¤¹¡£ ʸ¤ÏÄ̾¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã¤È¸Æ¤Ð¤ì¤Þ¤¹¡£ C<$bind_value> ¤Ï¼ÂºÝ¤Ë»È¤ï¤ì¤ëÊÑ¿ô¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤È¤·¤ÆÅϤµ¤ì¤Þ¤¹¡£ =begin original Note that unlike L, the C<$bind_value> variable is not copied when C is called. Instead, the value in the variable is read at the time L is called. =end original L ¤È¤Ï°ã¤¤¡¢C<$bind_value> ÊÑ¿ô¤Ï C ¤¬ ¸Æ¤Ð¤ì¤¿¤È¤­¤Ë¤Ï¥³¥Ô¡¼¤µ¤ì¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ÊÑ¿ô¤ÎÃÍ¤Ï L ¤¬¸Æ¤Ð¤ì¤¿¤È¤­¤ËÆɤߤ³¤Þ¤ì¤Þ¤¹¡£ =begin original The additional C<$max_len> parameter specifies the minimum amount of memory to allocate to C<$bind_value> for the new value. If the value returned from the database is too big to fit, then the execution should fail. If unsure what value to use, pick a generous length, i.e., a length larger than the longest value that would ever be returned. The only cost of using a larger value than needed is wasted memory. =end original Äɲ䵤줿 C<$max_len> ¥Ñ¥é¥á¡¼¥¿¤Ï¡¢C<$bin_value> ¤Î¿·¤·¤¤ÃͤΤ¿¤á¤Ë ³ÎÊݤµ¤ì¤ëºÇ¾®¸Â¤Î¥á¥â¥êÎ̤ò»ØÄꤷ¤Þ¤¹¡£ ¤â¤·¼ÂºÝ¤ÎÃͤ¬Â礭¤¹¤®¤Æ¼ý¤Þ¤é¤Ê¤±¤ì¤Ð¡¢¼Â¹Ô¤Ï¼ºÇÔ¤·¤Þ¤¹¡£ »ÈÍѤ¹¤ëÎ̤¬¤ï¤«¤é¤Ê¤±¤ì¤Ð¡¢Â礭¤ÊŤµ¤òÀˤ·¤ß¤Ê¤¯¡¢¤Ä¤Þ¤ê ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤°ìÈÖŤ¤Ãͤè¤êŤ¯Ãͤò»ØÄꤷ¤Þ¤·¤ç¤¦¡£ ɬÍפè¤ê¤âÂ礭¤ÊÃͤò»È¤¦¤¿¤á¤Ëµ¾À·¤Ë¤Ê¤ë¤Î¤Ï¡¢¥á¥â¥ê¤ÎϲÈñ¤À¤±¤Ç¤¹¡£ =begin original Undefined values or C are used to indicate null values. See also L for more information. =end original ̤ÄêµÁ¤ÎÃͤ¢¤ë¤¤¤Ï C ¤Ï NULL Ãͤò¼¨¤¹¤Î¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¤µ¤é¤Ë¾Ü¤·¤¤¾ðÊó¤Ï L ¤â¤´Í÷²¼¤µ¤¤¡£ =head3 C $rc = $sth->bind_param_array($p_num, $array_ref_or_value) $rc = $sth->bind_param_array($p_num, $array_ref_or_value, \%attr) $rc = $sth->bind_param_array($p_num, $array_ref_or_value, $bind_type) =begin original The C method is used to bind an array of values to a placeholder embedded in the prepared statement which is to be executed with L. For example: =end original C¥á¥½¥Ã¥É¤Ï¡¢L¤Ç¼Â¹Ô¤µ¤ì¤ë½àÈ÷ʸ¤ËËä¤á¹þ¤Þ¤ì¤¿¥×¥ì¡¼¥¹¥Û¥ë¥À¤ËÃͤÎÇÛÎó¤ò¥Ð¥¤¥ó¥É¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $dbh->{RaiseError} = 1; # save having to check each method call $sth = $dbh->prepare("INSERT INTO staff (first_name, last_name, dept) VALUES(?, ?, ?)"); $sth->bind_param_array(1, [ 'John', 'Mary', 'Tim' ]); $sth->bind_param_array(2, [ 'Booth', 'Todd', 'Robinson' ]); $sth->bind_param_array(3, "SALES"); # scalar will be reused for each row $sth->execute_array( { ArrayTupleStatus => \my @tuple_status } ); =begin original The C<%attr> ($bind_type) argument is the same as defined for L. Refer to L for general details on using placeholders. =end original C<%attr>($bind_type)°ú¿ô¤Ï¡¢L¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¹¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤Î»ÈÍѤ˴ؤ¹¤ë°ìÈÌŪ¤Ê¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original (Note that bind_param_array() can I be used to expand a placeholder into a list of values for a statement like "SELECT foo WHERE bar IN (?)". A placeholder can only ever represent one value per execution.) =end original (bind_param_array()¤ò»ÈÍѤ·¤Æ¡¢¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò¡ÖSELECT foo WHERE bar IN(?)¡×¤Î¤è¤¦¤Êʸ¤ÎÃͤΥꥹ¥È¤ËŸ³«¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï¡¢1²ó¤Î¼Â¹Ô¤Ç1¤Ä¤ÎÃͤ·¤«É½¤¹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£ ) (TBR) =begin original Scalar values, including C, may also be bound by C. In which case the same value will be used for each L call. Driver-specific implementations may behave differently, e.g., when binding to a stored procedure call, some databases may permit mixing scalars and arrays as arguments. =end original C¤ò´Þ¤à¥¹¥«¥é¡¼Ãͤϡ¢C¤Ë¤è¤Ã¤Æ¤â¥Ð¥¤¥ó¥É¤Ç¤­¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢³ÆL¸Æ¤Ó½Ð¤·¤ËƱ¤¸Ãͤ¬»ÈÍѤµ¤ì¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¸ÇÍ­¤Î¼ÂÁõ¤Ï¡¢°Û¤Ê¤ëÆ°ºî¤ò¤¹¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã¥³¡¼¥ë¤Ë¥Ð¥¤¥ó¥É¤¹¤ë¾ì¹ç¡¢°ìÉô¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢°ú¿ô¤È¤·¤Æ¥¹¥«¥é¡¼¤ÈÇÛÎó¤òº®ºß¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original The default implementation provided by DBI (for drivers that have not implemented array binding) is to iteratively call L for each parameter tuple provided in the bound arrays. Drivers may provide more optimized implementations using whatever bulk operation support the database API provides. The default driver behaviour should match the default DBI behaviour, but always consult your driver documentation as there may be driver specific issues to consider. =end original DBI¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë¥Ç¥Õ¥©¥ë¥È¤Î¼ÂÁõ(ÇÛÎó¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¥É¥é¥¤¥Ð¤Î¾ì¹ç)¤Ï¡¢¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÇÛÎó¤ÇÄ󶡤µ¤ì¤ë³Æ¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤ËÂФ·¤ÆL¤ò·«¤êÊÖ¤·¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹API¤¬Ä󶡤¹¤ë¥Ð¥ë¥¯Áàºî¥µ¥Ý¡¼¥È¤ò»ÈÍѤ·¤Æ¡¢¤è¤êºÇŬ²½¤µ¤ì¤¿¼ÂÁõ¤òÄ󶡤¹¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¥É¥é¥¤¥ÐÆ°ºî¤Ï¥Ç¥Õ¥©¥ë¥È¤ÎDBIÆ°ºî¤È°ìÃפ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¤¬¡¢¹Íθ¤¹¤Ù¤­¥É¥é¥¤¥Ð¸ÇÍ­¤ÎÌäÂ꤬¤¢¤ë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢¾ï¤Ë¥É¥é¥¤¥Ð¤Îʸ½ñ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original Note that the default implementation currently only supports non-data returning statements (INSERT, UPDATE, but not SELECT). Also, C and L cannot be mixed in the same statement execution, and C must be used with L; using C will have no effect for L. =end original ¥Ç¥Õ¥©¥ë¥È¤Î¼ÂÁõ¤Ç¤Ï¡¢¸½ºß¡¢¥Ç¡¼¥¿¤òÊÖ¤µ¤Ê¤¤Ê¸(INSERT¡¢UPDATE¡¢SELECT°Ê³°)¤Î¤ß¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¡¢C¤ÈL¤òƱ¤¸Ê¸¤Î¼Â¹Ô¤Çº®ºß¤µ¤»¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£ ¤Þ¤¿¡¢C¤ÏL¤È¤È¤â¤Ë»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ C¤ò»ÈÍѤ·¤Æ¤âL¤Ë¤Ï±Æ¶Á¤·¤Þ¤»¤ó¡£ (TBR) =begin original The C method was added in DBI 1.22. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.22 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $rv = $sth->execute or die $sth->errstr; $rv = $sth->execute(@bind_values) or die $sth->errstr; =begin original Perform whatever processing is necessary to execute the prepared statement. An C is returned if an error occurs. A successful C always returns true regardless of the number of rows affected, even if it's zero (see below). It is always important to check the return status of C (and most other DBI methods) for errors if you're not using L. =end original prepare ¤µ¤ì¤¿Ê¸¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤ËɬÍפʽèÍý¤ò¤¹¤Ù¤Æ¹Ô¤¤¤Þ¤¹¡£ ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤é¡¢C ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ Àµ¾ï¤Ê C ¤Ï¡¢±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤Î¿ô¤Ë´Ø·¸Ìµ¤¯¡¢Î㤨¤½¤ì¤¬ 0 ¤Ç¤¢¤Ã¤Æ¤â(²¼µ­¤ò»²¾È)¿¿¤òÊÖ¤·¤Þ¤¹¡£ L ¤ò»È¤Ã¤Æ¤¤¤Ê¤¤¤Ê¤é¡¢C(¤½¤·¤Æ¾¤Î¤Û¤È¤ó¤É¤Î DBI ¥á¥½¥Ã¥É)¤ÎÌá¤ê¥¹¥Æ¡¼¥¿¥¹¤ò¥¨¥é¡¼¤Ç¤Ê¤¤¤«¥Á¥§¥Ã¥¯¤¹¤ë¤³¤È¤Ï ¾ï¤Ë½ÅÍפǤ¹¡£ =begin original For a I-C ʸ¤Ê¤é¡¢C ¤Ï¡¢¤â¤·¤ï¤«¤ì¤Ð±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤Î¿ô¤ò ÊÖ¤·¤Þ¤¹¡£ ±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤¬Ìµ¤¤¾ì¹ç¤Ë¤Ï¡¢C ¤Ï "C<0E0>" ¤òÊÖ¤·¤Þ¤¹¡£ Perl ¤Ï¤³¤ì¤ò 0 ¤È¤·¤Æ°·¤¤¤Þ¤¹¤¬¡¢¿¿¤ÈȽÄꤷ¤Þ¤¹¡£ ±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤¬Ìµ¤¤¤³¤È¼«ÂΤϥ¨¥é¡¼¤Ç¤Ï¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ±Æ¶Á¤ò¼õ¤±¤¿¹Ô¤Î¿ô¤¬¤ï¤«¤é¤Ê¤±¤ì¤Ð¡¢C ¤Ï -1 ¤òÊÖ¤·¤Þ¤¹¡£ =begin original For C ʸ¤Ç¤Ï execute ¤ÏÌ䤤¹ç¤ï¤»¤òñ¤Ë¥¨¥ó¥¸¥ó¤Ç¡Ö³«»Ï¡×¤¹¤ë¤À¤±¤Ç¤¹¡£ C ¤ò¸Æ¤Ó½Ð¤·¤¿¸å¤Ï¡¢fetch ¥á¥½¥Ã¥É¤Î¤É¤ì¤«¤ò»È¤Ã¤Æ¥Ç¡¼¥¿¤ò ¼è¤ê½Ð¤·¤Æ¤¯¤À¤µ¤¤¡£ C ¥á¥½¥Ã¥É¤ÏÌ䤤¹ç¤ï¤»¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¹Ô¤Î¿ô¤ò I<ÊÖ¤·¤Þ¤»¤ó> (¤È¤¤¤¦¤Î¤â¤Û¤È¤ó¤É¤Î¥¨¥ó¥¸¥ó¤ÏÁ°¤â¤Ã¤Æ¶µ¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¤é¤Ç¤¹); ¤½¤ì¤Ïñ¤Ë¿¿¤òÊÖ¤·¤Þ¤¹¡£ =begin original You can tell if the statement was a C¥¹¥Æ¡¼¥È¥á¥ó¥È¤«¤É¤¦¤«¤Ï¡¢C<$sth-E{NUM_OF_FIELDS}>¤¬¥¼¥í¤è¤êÂ礭¤¤¤«¤É¤¦¤«¤òC¤Î¸Æ¤Ó½Ð¤·¸å¤Ë¥Á¥§¥Ã¥¯¤¹¤ë¤³¤È¤Ç¤ï¤«¤ê¤Þ¤¹¡£ (TBR) =begin original If any arguments are given, then C will effectively call L for each value before executing the statement. Values bound in this way are usually treated as C types unless the driver can determine the correct type (which is rare), or unless C (or C) has already been used to specify the type. =end original ²¿¤«°ú¿ô¤¬Í¿¤¨¤é¤ì¤ë¤È¡¢C ¤Ï¡¢¤½¤Îʸ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¡¢ ¤½¤ì¤¾¤ì¤Ë¤Ä¤¤¤Æ¸úΨ¤è¤¯ L ¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ë¤·¤Æ·ë¤ÓÉÕ¤±¤é¤ì¤¿Ãͤϡ¢¥É¥é¥¤¥Ð¤¬Àµ¤·¤¤·¿¤òȽÄê¤Ç¤­¤ë¤« (ȽÄê¤Ç¤­¤ë¤³¤È¤Ï¤Þ¤ì¤Ç¤¹)¡¢´û¤Ë C(¤Þ¤¿¤Ï C)¤¬·¿¤òÆÃÄꤹ¤ë¤¿¤á¤Ë»È¤ï¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢Ä̾ï C ¥¿¥¤¥×¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ =begin original Note that passing C an empty array is the same as passing no arguments at all, which will execute the statement with previously bound values. That's probably not what you want. =end original C¤Ë¶õ¤ÎÇÛÎó¤òÅϤ¹¤³¤È¤Ï¡¢°ú¿ô¤ò¤Þ¤Ã¤¿¤¯ÅϤµ¤Ê¤¤¤³¤È¤ÈƱ¤¸¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤³¤ì¤Ë¤è¤ê¡¢°ÊÁ°¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤¿Ãͤò»ÈÍѤ·¤Æʸ¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£ ¤½¤ì¤Ï¤ª¤½¤é¤¯¤¢¤Ê¤¿¤¬Ë¾¤à¤â¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¡£ (TBR) =begin original If execute() is called on a statement handle that's still active ($sth->{Active} is true) then it should effectively call finish() to tidy up the previous execution results before starting this new execution. =end original execute()¤¬¤Þ¤À¥¢¥¯¥Æ¥£¥Ö¤Ê¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç($sth->{Active}¤¬true)¡¢¤³¤Î¿·¤·¤¤¼Â¹Ô¤ò³«»Ï¤¹¤ëÁ°¤Ë¡¢Á°¤Î¼Â¹Ô·ë²Ì¤òÀ°Íý¤¹¤ë¤¿¤á¤Ëfinish()¤ò¸ú²ÌŪ¤Ë¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head3 C $tuples = $sth->execute_array(\%attr) or die $sth->errstr; $tuples = $sth->execute_array(\%attr, @bind_values) or die $sth->errstr; ($tuples, $rows) = $sth->execute_array(\%attr) or die $sth->errstr; ($tuples, $rows) = $sth->execute_array(\%attr, @bind_values) or die $sth->errstr; =begin original Execute the prepared statement once for each parameter tuple (group of values) provided either in the @bind_values, or by prior calls to L, or via a reference passed in \%attr. =end original @bind_values¡¢°ÊÁ°¤ÎL¤Î¸Æ¤Ó½Ð¤·¡¢¤Þ¤¿¤Ï\%attr¤ÇÅϤµ¤ì¤¿»²¾È¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤¿¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë(ÃͤΥ°¥ë¡¼¥×)¤´¤È¤Ë¡¢½àÈ÷¤µ¤ì¤¿Ê¸¤ò1²ó¼Â¹Ô¤·¤Þ¤¹¡£ (TBR) =begin original When called in scalar context the execute_array() method returns the number of tuples executed, or C if an error occurred. Like execute(), a successful execute_array() always returns true regardless of the number of tuples executed, even if it's zero. If there were any errors the ArrayTupleStatus array can be used to discover which tuples failed and with what errors. =end original ¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢execute_array()¥á¥½¥Ã¥É¤Ï¼Â¹Ô¤µ¤ì¤¿¥¿¥×¥ë¤Î¿ô¤òÊÖ¤·¤Þ¤¹¡£ ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏC¤òÊÖ¤·¤Þ¤¹¡£ execute()¤ÈƱÍͤˡ¢À®¸ù¤·¤¿execute_array()¤Ï¡¢¼Â¹Ô¤µ¤ì¤¿¥¿¥×¥ë¤Î¿ô¤Ë´Ø·¸¤Ê¤¯¡¢0¤Ç¤¢¤Ã¤Æ¤â¾ï¤Ëtrue¤òÊÖ¤·¤Þ¤¹¡£ ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ï¡¢ArrayTupleStatusÇÛÎó¤ò»ÈÍѤ·¤Æ¡¢¼ºÇÔ¤·¤¿¥¿¥×¥ë¤È¥¨¥é¡¼¤ò¸¡½Ð¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original When called in list context the execute_array() method returns two scalars; $tuples is the same as calling execute_array() in scalar context and $rows is the sum of the number of rows affected for each tuple, if available or -1 if the driver cannot determine this. If you are doing an update operation the returned rows affected may not be what you expect if, for instance, one or more of the tuples affected the same row multiple times. Some drivers may not yet support list context, in which case $rows will be undef, or may not be able to provide the number of rows affected when performing this batch operation, in which case $rows will be -1. =end original ¥ê¥¹¥È¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢execute_array()¥á¥½¥Ã¥É¤Ï2¤Ä¤Î¥¹¥«¥é¡¼¤òÊÖ¤·¤Þ¤¹¡£ $tuples¤Ï¡¢¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Çexecute_array()¤ò¸Æ¤Ó½Ð¤¹¤Î¤ÈƱ¤¸¤Ç¤¹¡£ $rows¤Ï¡¢¥¿¥×¥ë¤´¤È¤Ë±Æ¶Á¤ò¼õ¤±¤ë¹Ô¿ô¤Î¹ç·×¤Ç¤¹(ÍøÍѲÄǽ¤Ê¾ì¹ç)¡£ ¥É¥é¥¤¥Ð¤¬¤³¤ì¤òȽÃǤǤ­¤Ê¤¤¾ì¹ç¤Ï-1¤Ç¤¹¡£ ¹¹¿·Áàºî¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç¡¢¤¿¤È¤¨¤Ð¡¢1¤Ä°Ê¾å¤Î¥¿¥×¥ë¤¬Æ±¤¸¹Ô¤ËÊ£¿ô²ó±Æ¶Á¤ò¼õ¤±¤¿¾ì¹ç¡¢±Æ¶Á¤ò¼õ¤±¤ëÊÖ¤µ¤ì¤¿¹Ô¤Ï´üÂԤɤª¤ê¤Ç¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ °ìÉô¤Î¥É¥é¥¤¥Ð¤Ï¡¢¥ê¥¹¥È¥³¥ó¥Æ¥­¥¹¥È¤ò¤Þ¤À¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢$rows¤Ïundef¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤Þ¤¿¤Ï¡¢¤³¤Î¥Ð¥Ã¥ÁÁàºî¤ò¼Â¹Ô¤¹¤ë¤È¤­¤Ë±Æ¶Á¤ò¼õ¤±¤ë¹Ô¿ô¤òÄ󶡤Ǥ­¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢$rows¤Ï-1¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original Bind values for the tuples to be executed may be supplied row-wise by an C attribute, or else column-wise in the C<@bind_values> argument, or else column-wise by prior calls to L. =end original ¼Â¹Ô¤µ¤ì¤ë¥¿¥×¥ë¤Î¥Ð¥¤¥ó¥ÉÃͤϡ¢C°À­¤Ë¤è¤Ã¤Æ¹ÔÊý¸þ¤ËÄ󶡤µ¤ì¤ë¤«¡¢C<@bind_values>°ú¿ô¤ÇÎóÊý¸þ¤ËÄ󶡤µ¤ì¤ë¤«¡¢¤Þ¤¿¤ÏL¤Ø¤Î°ÊÁ°¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆÎóÊý¸þ¤ËÄ󶡤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Where column-wise binding is used (via the C<@bind_values> argument or calls to bind_param_array()) the maximum number of elements in any one of the bound value arrays determines the number of tuples executed. Placeholders with fewer values in their parameter arrays are treated as if padded with undef (NULL) values. =end original (C<@bind_values>°ú¿ô¤Þ¤¿¤Ïbind_param_array()¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤Æ)Îóñ°Ì¤Î¥Ð¥¤¥ó¥É¤¬»ÈÍѤµ¤ì¤ë¾ì¹ç¡¢¥Ð¥¤¥ó¥ÉÃÍÇÛÎó¤Î¤¤¤º¤ì¤«¤ÎÍ×ÁǤκÇÂç¿ô¤Ë¤è¤Ã¤Æ¡¢¼Â¹Ô¤µ¤ì¤ë¥¿¥×¥ë¤Î¿ô¤¬·èÄꤵ¤ì¤Þ¤¹¡£ ¥Ñ¥é¥á¡¼¥¿ÇÛÎó¤ÎÃͤ¬¾¯¤Ê¤¤¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ï¡¢undef(NULL)ÃͤÇËä¤á¤é¤ì¤Æ¤¤¤ë¤â¤Î¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ (TBR) =begin original If a scalar value is bound, instead of an array reference, it is treated as a I length array with all elements having the same value. It does not influence the number of tuples executed, so if all bound arrays have zero elements then zero tuples will be executed. If I bound values are scalars then one tuple will be executed, making execute_array() act just like execute(). =end original ¥¹¥«¥é¡¼Ãͤ¬¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢ÇÛÎ󻲾ȤǤϤʤ¯¡¢¤¹¤Ù¤Æ¤ÎÍ×ÁǤ¬Æ±¤¸Ãͤò»ý¤ÄIlengthÇÛÎó¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ ¼Â¹Ô¤µ¤ì¤ë¥¿¥×¥ë¤Î¿ô¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤¤¿¤á¡¢¥Ð¥¤¥ó¥É¤µ¤ì¤¿¤¹¤Ù¤Æ¤ÎÇÛÎó¤ÎÍ×ÁǤ¬¥¼¥í¤Î¾ì¹ç¤Ï¡¢¥¼¥í¤Î¥¿¥×¥ë¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£ I¥Ð¥¤¥ó¥ÉÃͤ¬¥¹¥«¥é¡¼¤Î¾ì¹ç¤Ï¡¢1¤Ä¤Î¥¿¥×¥ë¤¬¼Â¹Ô¤µ¤ì¡¢execute_array()¤Ïexecute()¤ÈƱÍͤËÆ°ºî¤·¤Þ¤¹¡£ (TBR) =begin original The C attribute can be used to specify a reference to a subroutine that will be called to provide the bind values for each tuple execution. The subroutine should return an reference to an array which contains the appropriate number of bind values, or return an undef if there is no more data to execute. =end original C°À­¤ò»ÈÍѤ·¤Æ¡¢³Æ¥¿¥×¥ë¼Â¹Ô¤Î¥Ð¥¤¥ó¥ÉÃͤòÄ󶡤¹¤ë¤¿¤á¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥µ¥Ö¥ë¡¼¥Á¥ó¤Ø¤Î»²¾È¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢Å¬Àڤʿô¤Î¥Ð¥¤¥ó¥ÉÃͤò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤òÊÖ¤¹¤«¡¢¼Â¹Ô¤¹¤ë¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç¤Ïundef¤òÊÖ¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original As a convenience, the C attribute can also be used to specify a statement handle. In which case the fetchrow_arrayref() method will be called on the given statement handle in order to provide the bind values for each tuple execution. =end original Êص¹¾å¡¢C°À­¤ò»ÈÍѤ·¤Æ¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢»ØÄꤵ¤ì¤¿¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ËÂФ·¤Æfetchrow_arrayref()¥á¥½¥Ã¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¡¢³Æ¥¿¥×¥ë¼Â¹Ô¤Î¥Ð¥¤¥ó¥ÉÃͤ¬Ä󶡤µ¤ì¤Þ¤¹¡£ (TBR) =begin original The values specified via bind_param_array() or the @bind_values parameter may be either scalars, or arrayrefs. If any C<@bind_values> are given, then C will effectively call L for each value before executing the statement. Values bound in this way are usually treated as C types unless the driver can determine the correct type (which is rare), or unless C, C, C, or C has already been used to specify the type. See L for details. =end original bind_param_array()¤Þ¤¿¤Ï@bind_values¥Ñ¥é¥á¡¼¥¿¤ò²ð¤·¤Æ»ØÄꤵ¤ì¤¿Ãͤϡ¢¥¹¥«¥é¡¼¤Þ¤¿¤Ïarrayrefs¤Î¤¤¤º¤ì¤«¤Ç¤¹¡£ C<@bind_values>¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢C¤Ïʸ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë³ÆÃͤËÂФ·¤ÆL¤ò¸ú²ÌŪ¤Ë¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ ¤³¤ÎÊýË¡¤Ç¥Ð¥¤¥ó¥É¤µ¤ì¤¿Ãͤϡ¢¥É¥é¥¤¥Ð¤¬Àµ¤·¤¤·¿¤òȽÊ̤Ǥ­¤Ê¤¤¸Â¤ê(¤Þ¤ì¤Ç¤¹)¡¢¤Þ¤¿¤ÏC¡¢C¡¢C¡¢¤Þ¤¿¤ÏC¤¬¤¹¤Ç¤Ë·¿¤Î»ØÄê¤Ë»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤¸Â¤ê¡¢Ä̾ï¤ÏC·¿¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ ¾ÜºÙ¤ÏL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The C attribute can be used to specify a reference to an array which will receive the execute status of each executed parameter tuple. Note the C attribute was mandatory until DBI 1.38. =end original C°À­¤Ï¡¢¼Â¹Ô¤µ¤ì¤¿³Æ¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤Î¼Â¹Ô¥¹¥Æ¡¼¥¿¥¹¤ò¼õ¤±¼è¤ëÇÛÎó¤Ø¤Î»²¾È¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»ÈÍѤǤ­¤Þ¤¹¡£ DBI 1.38¤Þ¤Ç¤Ï¡¢C°À­¤Ïɬ¿Ü¤Ç¤·¤¿¡£ (TBR) =begin original For tuples which are successfully executed, the element at the same ordinal position in the status array is the resulting rowcount. If the execution of a tuple causes an error, then the corresponding status array element will be set to a reference to an array containing the error code and error string set by the failed execution. =end original Àµ¾ï¤Ë¼Â¹Ô¤µ¤ì¤¿¥¿¥×¥ë¤Î¾ì¹ç¡¢¥¹¥Æ¡¼¥¿¥¹ÇÛÎóÆâ¤ÎƱ¤¸½ç½ø°ÌÃ֤ˤ¢¤ëÍ×ÁǤ¬·ë²Ì¤Î¹Ô¥«¥¦¥ó¥È¤Ë¤Ê¤ê¤Þ¤¹¡£ ¥¿¥×¥ë¤Î¼Â¹Ô¤Ë¤è¤Ã¤Æ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¡¢Âбþ¤¹¤ë¥¹¥Æ¡¼¥¿¥¹ÇÛÎóÍ×ÁǤϡ¢¼ºÇÔ¤·¤¿¼Â¹Ô¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¥¨¥é¡¼¥³¡¼¥É¤ª¤è¤Ó¥¨¥é¡¼Ê¸»úÎó¤ò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤ËÀßÄꤵ¤ì¤Þ¤¹¡£ (TBR) =begin original If B tuple execution returns an error, C will return C. In that case, the application should inspect the status array to determine which parameter tuples failed. Some databases may not continue executing tuples beyond the first failure. In this case the status array will either hold fewer elements, or the elements beyond the failure will be undef. =end original B¥¿¥×¥ë¤Î¼Â¹Ô¤Ç¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤¿¾ì¹ç¡¢C¤ÏC¤òÊÖ¤·¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¥¹¥Æ¡¼¥¿¥¹ÇÛÎó¤ò¸¡ºº¤·¤Æ¡¢¤É¤Î¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤¬¼ºÇÔ¤·¤¿¤«¤òȽÊ̤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ °ìÉô¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢ºÇ½é¤Î¼ºÇ԰ʹߡ¢¥¿¥×¥ë¤Î¼Â¹Ô¤¬Â³¹Ô¤µ¤ì¤Ê¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤Î¾ì¹ç¡¢¥¹¥Æ¡¼¥¿¥¹ÇÛÎó¤ËÊÝ»ý¤µ¤ì¤ëÍ×ÁǤ¬¾¯¤Ê¤¯¤Ê¤ë¤«¡¢¼ºÇ԰ʹߤÎÍ×ÁǤ¬undef¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original If all parameter tuples are successfully executed, C returns the number tuples executed. If no tuples were executed, then execute_array() returns "C<0E0>", just like execute() does, which Perl will treat as 0 but will regard as true. =end original ¤¹¤Ù¤Æ¤Î¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤¬Àµ¾ï¤Ë¼Â¹Ô¤µ¤ì¤¿¾ì¹ç¡¢C¤Ï¡¢¼Â¹Ô¤µ¤ì¤¿¥¿¥×¥ë¤Î¿ô¤òÌᤷ¤Þ¤¹¡£ ¥¿¥×¥ë¤¬¼Â¹Ô¤µ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢execute_array()¤Ï¡¢execute()¤ÈƱÍͤË"C<0E0>"¤òÌᤷ¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢Perl¤Ç¤Ï0¤È¤·¤Æ½èÍý¤µ¤ì¤Þ¤¹¤¬¡¢true¤È¤ß¤Ê¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original For example: =end original Î㤨¤Ð: $sth = $dbh->prepare("INSERT INTO staff (first_name, last_name) VALUES (?, ?)"); my $tuples = $sth->execute_array( { ArrayTupleStatus => \my @tuple_status }, \@first_names, \@last_names, ); if ($tuples) { print "Successfully inserted $tuples records\n"; } else { for my $tuple (0..@last_names-1) { my $status = $tuple_status[$tuple]; $status = [0, "Skipped"] unless defined $status; next unless ref $status; printf "Failed to insert (%s, %s): %s\n", $first_names[$tuple], $last_names[$tuple], $status->[1]; } } =begin original Support for data returning statements such as SELECT is driver-specific and subject to change. At present, the default implementation provided by DBI only supports non-data returning statements. =end original SELECT¤Ê¤É¤Î¥Ç¡¼¥¿¤òÊÖ¤¹¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î¥µ¥Ý¡¼¥È¤Ï¥É¥é¥¤¥Ð¸ÇÍ­¤Ç¤¢¤ê¡¢Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¸½ºß¡¢DBI¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë¥Ç¥Õ¥©¥ë¥È¤Î¼ÂÁõ¤Ç¤Ï¡¢¥Ç¡¼¥¿¤òÊÖ¤µ¤Ê¤¤¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î¤ß¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =begin original Transaction semantics when using array binding are driver and database specific. If C is on, the default DBI implementation will cause each parameter tuple to be individually committed (or rolled back in the event of an error). If C is off, the application is responsible for explicitly committing the entire set of bound parameter tuples. Note that different drivers and databases may have different behaviours when some parameter tuples cause failures. In some cases, the driver or database may automatically rollback the effect of all prior parameter tuples that succeeded in the transaction; other drivers or databases may retain the effect of prior successfully executed parameter tuples. Be sure to check your driver and database for its specific behaviour. =end original ÇÛÎó¥Ð¥¤¥ó¥É¤ò»ÈÍѤ¹¤ë¾ì¹ç¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¥»¥Þ¥ó¥Æ¥£¥¯¥¹¤Ï¡¢¥É¥é¥¤¥Ð¤ª¤è¤Ó¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¸ÇÍ­¤Ç¤¹¡£ C¤¬¥ª¥ó¤Î¾ì¹ç¡¢¥Ç¥Õ¥©¥ë¥È¤ÎDBI¼ÂÁõ¤Ç¤Ï¡¢³Æ¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤¬¸ÄÊ̤˥³¥ß¥Ã¥È(¤Þ¤¿¤Ï¥¨¥é¡¼È¯À¸»þ¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯)¤µ¤ì¤Þ¤¹¡£ C¤¬¥ª¥Õ¤Î¾ì¹ç¡¢¥Ð¥¤¥ó¥É¤µ¤ì¤¿¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤Î¥»¥Ã¥ÈÁ´ÂΤòÌÀ¼¨Åª¤Ë¥³¥ß¥Ã¥È¤¹¤ë¤Î¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÀÕǤ¤Ç¤¹¡£ °ìÉô¤Î¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤Ç¾ã³²¤¬È¯À¸¤·¤¿¾ì¹ç¡¢°Û¤Ê¤ë¥É¥é¥¤¥Ð¤ª¤è¤Ó¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤ÏÆ°ºî¤¬°Û¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ï¡¢¥É¥é¥¤¥Ð¤Þ¤¿¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ÇÀ®¸ù¤·¤¿°ÊÁ°¤Î¤¹¤Ù¤Æ¤Î¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤Î±Æ¶Á¤ò¼«Æ°Åª¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¾¤Î¥É¥é¥¤¥Ð¤Þ¤¿¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï¡¢°ÊÁ°¤ËÀµ¾ï¤Ë¼Â¹Ô¤µ¤ì¤¿¥Ñ¥é¥á¡¼¥¿¥¿¥×¥ë¤Î±Æ¶Á¤òÊÝ»ý¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤ª¤è¤Ó¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÆÃÄê¤ÎÆ°ºî¤òɬ¤º³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original Note that, in general, performance will usually be better with C turned off, and using explicit C after each C call. =end original °ìÈ̤ˡ¢C¤ò¥ª¥Õ¤Ë¤·¡¢³ÆC¸Æ¤Ó½Ð¤·¤Î¸å¤ËÌÀ¼¨Åª¤ËC¤ò»ÈÍѤ¹¤ë¤È¡¢¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤¬¸þ¾å¤¹¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The C method was added in DBI 1.22, and ArrayTupleFetch was added in 1.36. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.22 ¤ÇÄɲ䵤졢ArrayTupleFetch ¤Ï 1.36 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $tuples = $sth->execute_for_fetch($fetch_tuple_sub); $tuples = $sth->execute_for_fetch($fetch_tuple_sub, \@tuple_status); ($tuples, $rows) = $sth->execute_for_fetch($fetch_tuple_sub); ($tuples, $rows) = $sth->execute_for_fetch($fetch_tuple_sub, \@tuple_status); =begin original The execute_for_fetch() method is used to perform bulk operations and is most often used via the execute_array() method, not directly. =end original execute_for_fetch()¥á¥½¥Ã¥É¤Ï¡¢¥Ð¥ë¥¯¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¡¢¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢Ä¾ÀܤǤϤʤ¯execute_array()¥á¥½¥Ã¥É¤ò²ð¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£ (TBR) =begin original The fetch subroutine, referenced by $fetch_tuple_sub, is expected to return a reference to an array (known as a 'tuple') or undef. =end original $fetch_tuple_sub¤Ë¤è¤Ã¤Æ»²¾È¤µ¤ì¤ë¥Õ¥§¥Ã¥Á¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï¡¢ÇÛÎó(¡Ö¥¿¥×¥ë¡×¤È¸Æ¤Ð¤ì¤ë)¤Þ¤¿¤Ïundef¤Ø¤Î»²¾È¤òÊÖ¤¹¤³¤È¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =begin original The execute_for_fetch() method calls $fetch_tuple_sub, without any parameters, until it returns a false value. Each tuple returned is used to provide bind values for an $sth->execute(@$tuple) call. =end original execute_for_fetch()¥á¥½¥Ã¥É¤Ï¡¢µ¶¤ÎÃͤòÊÖ¤¹¤Þ¤Ç¡¢¥Ñ¥é¥á¡¼¥¿¤Ê¤·¤Ç$fetch_tuple_sub¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ ÊÖ¤µ¤ì¤¿³Æ¥¿¥×¥ë¤Ï¡¢$sth->execute(@$tuple)¸Æ¤Ó½Ð¤·¤Î¥Ð¥¤¥ó¥ÉÃͤòÄ󶡤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ (TBR) =begin original In scalar context execute_for_fetch() returns C if there were any errors and the number of tuples executed otherwise. Like execute() and execute_array() a zero is returned as "0E0" so execute_for_fetch() is only false on error. If there were any errors the @tuple_status array can be used to discover which tuples failed and with what errors. =end original ¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢execute_for_fetch()¤Ï¡¢¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤ÏC¤òÊÖ¤·¡¢¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¼Â¹Ô¤µ¤ì¤¿¥¿¥×¥ë¤Î¿ô¤òÊÖ¤·¤Þ¤¹¡£ execute()¤ª¤è¤Óexecute_array()¤ÈƱÍͤˡ¢¥¼¥í¤Ï¡Ö0E0¡×¤È¤·¤ÆÊÖ¤µ¤ì¤ë¤¿¤á¡¢execute_for_fetch()¤Ï¥¨¥é¡¼¤Î¾ì¹ç¤Ë¤Î¤ßfalse¤Ë¤Ê¤ê¤Þ¤¹¡£ ¥¨¥é¡¼¤¬¤¢¤Ã¤¿¾ì¹ç¤Ï??????@tuple_statusÇÛÎó¤ò»ÈÍѤ·¤Æ¡¢¼ºÇÔ¤·¤¿¥¿¥×¥ë¤È¥¨¥é¡¼¤ò¸¡½Ð¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original When called in list context execute_for_fetch() returns two scalars; $tuples is the same as calling execute_for_fetch() in scalar context and $rows is the sum of the number of rows affected for each tuple, if available or -1 if the driver cannot determine this. If you are doing an update operation the returned rows affected may not be what you expect if, for instance, one or more of the tuples affected the same row multiple times. Some drivers may not yet support list context, in which case $rows will be undef, or may not be able to provide the number of rows affected when performing this batch operation, in which case $rows will be -1. =end original ¥ê¥¹¥È¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢execute_for_fetch()¤Ï2¤Ä¤Î¥¹¥«¥é¡¼¤òÊÖ¤·¤Þ¤¹¡£ $tuples¤Ï¡¢¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Çexecute_for_fetch()¤ò¸Æ¤Ó½Ð¤¹¤Î¤ÈƱ¤¸¤Ç¤¹¡£ $rows¤Ï¡¢¥¿¥×¥ë¤´¤È¤Ë±Æ¶Á¤ò¼õ¤±¤ë¹Ô¿ô¤Î¹ç·×¤Ç¤¹(ÍøÍѲÄǽ¤Ê¾ì¹ç)¡£ ¥É¥é¥¤¥Ð¤¬¤³¤ì¤òȽÃǤǤ­¤Ê¤¤¾ì¹ç¤Ï-1¤Ç¤¹¡£ ¹¹¿·Áàºî¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç¡¢¤¿¤È¤¨¤Ð¡¢1¤Ä°Ê¾å¤Î¥¿¥×¥ë¤¬Æ±¤¸¹Ô¤ËÊ£¿ô²ó±Æ¶Á¤ò¼õ¤±¤¿¾ì¹ç¡¢±Æ¶Á¤ò¼õ¤±¤ëÊÖ¤µ¤ì¤¿¹Ô¤Ï´üÂÔ¤·¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ °ìÉô¤Î¥É¥é¥¤¥Ð¤Ï¡¢¥ê¥¹¥È¥³¥ó¥Æ¥­¥¹¥È¤ò¤Þ¤À¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢$rows¤Ïundef¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤Þ¤¿¤Ï¡¢¤³¤Î¥Ð¥Ã¥ÁÁàºî¤Î¼Â¹Ô»þ¤Ë±Æ¶Á¤ò¼õ¤±¤ë¹Ô¿ô¤òÄ󶡤Ǥ­¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤Î¾ì¹ç¡¢$rows¤Ï-1¤Ë¤Ê¤ê¤Þ¤¹¡£ (TBR) =begin original If \@tuple_status is passed then the execute_for_fetch method uses it to return status information. The tuple_status array holds one element per tuple. If the corresponding execute() did not fail then the element holds the return value from execute(), which is typically a row count. If the execute() did fail then the element holds a reference to an array containing ($sth->err, $sth->errstr, $sth->state). =end original \@tuple_status¤¬ÅϤµ¤ì¤¿¾ì¹ç¡¢execute_for_fetch¥á¥½¥Ã¥É¤Ï¤½¤ì¤ò»ÈÍѤ·¤Æ¥¹¥Æ¡¼¥¿¥¹¾ðÊó¤òÊÖ¤·¤Þ¤¹¡£ tuple_statusÇÛÎó¤Ï¡¢¥¿¥×¥ë¤´¤È¤Ë1¤Ä¤ÎÍ×ÁǤòÊÝ»ý¤·¤Þ¤¹¡£ Âбþ¤¹¤ëexecute()¤¬¼ºÇÔ¤·¤Ê¤«¤Ã¤¿¾ì¹ç¡¢Í×ÁǤÏexecute()¤«¤é¤ÎÌá¤êÃÍ(Ä̾ï¤Ï¹Ô¥«¥¦¥ó¥È)¤òÊÝ»ý¤·¤Þ¤¹¡£ execute()¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢Í×ÁǤÏ($sth->err,$sth->errstr,$sth->state)¤ò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤òÊÝ»ý¤·¤Þ¤¹¡£ (TBR) =begin original If the driver detects an error that it knows means no further tuples can be executed then it may return, with an error status, even though $fetch_tuple_sub may still have more tuples to be executed. =end original ¥É¥é¥¤¥Ð¤¬¥¨¥é¡¼¤ò¸¡½Ð¤·¡¢¤½¤ì°Ê¾å¥¿¥×¥ë¤ò¼Â¹Ô¤Ç¤­¤Ê¤¤¤³¤È¤¬¤ï¤«¤Ã¤¿¾ì¹ç¡¢$fetch_tuple_sub¤¬¤Þ¤À¼Â¹Ô¤¹¤Ù¤­¥¿¥×¥ë¤òÊÝ»ý¤·¤Æ¤¤¤Æ¤â¡¢¥¨¥é¡¼¥¹¥Æ¡¼¥¿¥¹¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original Although each tuple returned by $fetch_tuple_sub is effectively used to call $sth->execute(@$tuple_array_ref) the exact timing may vary. Drivers are free to accumulate sets of tuples to pass to the database server in bulk group operations for more efficient execution. However, the $fetch_tuple_sub is specifically allowed to return the same array reference each time (which is what fetchrow_arrayref() usually does). =end original $fetch_tuple_sub¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë³Æ¥¿¥×¥ë¤Ï¡¢$sth->execute(@$tuple_array_ref)¤ò¸Æ¤Ó½Ð¤¹¤¿¤á¤Ë¸ú²ÌŪ¤Ë»ÈÍѤµ¤ì¤Þ¤¹¤¬¡¢Àµ³Î¤Ê¥¿¥¤¥ß¥ó¥°¤Ï°Û¤Ê¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¡¢¤è¤ê¸úΨŪ¤Ê¼Â¹Ô¤Î¤¿¤á¤Ë¡¢¥Ð¥ë¥¯¥°¥ë¡¼¥×Áàºî¤Ç¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤ËÅϤ¹¥¿¥×¥ë¤Î¥»¥Ã¥È¤ò¼«Í³¤ËÃßÀѤǤ­¤Þ¤¹¡£ ¤¿¤À¤·¡¢$fetch_tuple_sub¤Ï¡¢Ëè²óƱ¤¸ÇÛÎ󻲾ȤòÊÖ¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹(¤³¤ì¤Ïfetchrow_arrayref()¤¬Ä̾ï¹Ô¤¦¤³¤È¤Ç¤¹)¡£ (TBR) =begin original For example: =end original Î㤨¤Ð: my $sel = $dbh1->prepare("select foo, bar from table1"); $sel->execute; my $ins = $dbh2->prepare("insert into table2 (foo, bar) values (?,?)"); my $fetch_tuple_sub = sub { $sel->fetchrow_arrayref }; my @tuple_status; $rc = $ins->execute_for_fetch($fetch_tuple_sub, \@tuple_status); my @errors = grep { ref $_ } @tuple_status; =begin original Similarly, if you already have an array containing the data rows to be processed you'd use a subroutine to shift off and return each array ref in turn: =end original ƱÍͤˡ¢½èÍý¤µ¤ì¤ë¥Ç¡¼¥¿¹Ô¤ò´Þ¤àÇÛÎ󤬤¹¤Ç¤Ë¤¢¤ë¾ì¹ç¤Ï¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤ò»ÈÍѤ·¤Æ¥·¥Õ¥È¥ª¥Õ¤·¡¢³ÆÇÛÎóref¤ò½çÈÖ¤ËÊÖ¤·¤Þ¤¹¡£ (TBR) $ins->execute_for_fetch( sub { shift @array_of_arrays }, \@tuple_status); =begin original The C method was added in DBI 1.38. =end original C ¥á¥½¥Ã¥É¤Ï DBI 1.38 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C $ary_ref = $sth->fetchrow_arrayref; $ary_ref = $sth->fetch; # alias =begin original Fetches the next row of data and returns a reference to an array holding the field values. Null fields are returned as C values in the array. This is the fastest way to fetch data, particularly if used with C<$sth-Ebind_columns>. =end original ¼¡¤Î¥Ç¡¼¥¿¤Î¹Ô¤ò¼è¤ê½Ð¤·¡¢¥Õ¥£¡¼¥ë¥É¤ÎÃͤò¤â¤Ã¤¿ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤ò ÊÖ¤·¤Þ¤¹¡£ Null ¤Î¥Õ¥£¡¼¥ë¥É¤Ï C ¤ÇÊÖ¤µ¤ì¤Þ¤¹¡£ ÆÃ¤Ë C<$sth-Ebind_columns> ¤ò»È¤Ã¤Æ¤¤¤ë¤Ê¤é¤Ð¡¢¤³¤ì¤¬¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤¹ ºÇ¤â®¤¤ÊýË¡¤Ç¤¹¡£ =begin original If there are no more rows or if an error occurs, then C returns an C. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the C returned was due to an error. =end original ¤â¤¦¹Ô¤¬Ìµ¤¤¤«¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢C ¤Ï C ¤òÊÖ¤·¤Þ¤¹¡£ ¸å¤ÇÊÖ¤µ¤ì¤¿ C ¤¬¥¨¥é¡¼¤Ë¤è¤ë¤â¤Î¤«¤É¤¦¤«¤ò¸«¤ë¤¿¤á¤Ë¡¢ C<$sth-Eerr> ¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Ù¤­¤Ç¤¹(¤¢¤ë¤¤¤Ï C °À­¤ò »È¤¦¤«)¡£ =begin original Note that the same array reference is returned for each fetch, so don't store the reference and then use it after a later fetch. Also, the elements of the array are also reused for each row, so take care if you want to take a reference to an element. See also L. =end original ¸½¾õ¤Ç¤Ï¡¢¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤¹¤¿¤Ó¤ËƱ¤¸ÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤¬ÊÖ¤µ¤ì¤ë¤³¤È¤¬ ¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¤½¤Î¤¿¤á¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼è¤Ã¤Æ¤ª¤¤¤Æ¡¢¥Ç¡¼¥¿¤Î¼è¤ê½Ð¤·¤ò¿Ê¤á¤¿¸å¤Ç¡¢ »È¤ï¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ ƱÍͤËÇÛÎó¤ÎÍ×ÁǤâ³Æ¹Ô¤ÇºÆ»ÈÍѤµ¤ì¤Þ¤¹¡£ Í×ÁǤΥê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ¤·¤¿¤¤¤Ê¤é¤Ð¡¢Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ L ¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C @ary = $sth->fetchrow_array; =begin original An alternative to C. Fetches the next row of data and returns it as a list containing the field values. Null fields are returned as C values in the list. =end original C ¤ÎÂåÍÑÉʤǤ¹¡£ ¼¡¤Î¥Ç¡¼¥¿¹Ô¤ò¼è¤ê½Ð¤·¡¢¥Õ¥£¡¼¥ë¥É¤ÎÃͤò»ý¤Ã¤¿ÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£ Null ¤Î¥Õ¥£¡¼¥ë¥É¤Ï¥ê¥¹¥È¤ÎÃæ¤Î C ÃͤȤ·¤ÆÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original If there are no more rows or if an error occurs, then C returns an empty list. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the empty list returned was due to an error. =end original ¤â¤¦¹Ô¤¬Ìµ¤¤¤«¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢C ¤Ï¶õ¥ê¥¹¥È¤òÊÖ¤·¤Þ¤¹¡£ ¸å¤ÇÊÖ¤µ¤ì¤¿¶õ¥ê¥¹¥È¤¬¥¨¥é¡¼¤Ë¤è¤ë¤â¤Î¤«¤É¤¦¤«¤ò¸«¤ë¤¿¤á¤Ë¡¢ C<$sth-Eerr> ¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Ù¤­¤Ç¤¹(¤¢¤ë¤¤¤Ï C °À­¤ò »È¤¦¤«)¡£ =begin original If called in a scalar context for a statement handle that has more than one column, it is undefined whether the driver will return the value of the first column or the last. So don't do that. Also, in a scalar context, an C is returned if there are no more rows or if an error occurred. That C can't be distinguished from an C returned because the first field value was NULL. For these reasons you should exercise some caution if you use C in a scalar context. =end original Ê£¿ô¤ÎÎó¤ò»ý¤Ä¥¹¥Æ¡¼¥È¥á¥ó¥È¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢¥É¥é¥¤¥Ð¤¬ºÇ½é¤ÎÎó¤ÎÃͤòÊÖ¤¹¤Î¤«ºÇ¸å¤ÎÎó¤ÎÃͤòÊÖ¤¹¤Î¤«¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ¤½¤Î¤¿¤á¡¢¤½¤¦¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ ¤Þ¤¿¡¢¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤Ç¤Ï¡¢¹Ô¤¬¤Ê¤¯¤Ê¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ËC¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¤³¤ÎC¤Ï¡¢ºÇ½é¤Î¥Õ¥£¡¼¥ë¥ÉÃͤ¬NULL¤Ç¤¢¤Ã¤¿¤¿¤á¤ËÊÖ¤µ¤ì¤¿C¤È¤Ï¶èÊ̤Ǥ­¤Þ¤»¤ó¡£ ¤³¤ì¤é¤ÎÍýͳ¤«¤é¡¢¥¹¥«¥é¡¼¥³¥ó¥Æ¥­¥¹¥È¤ÇC¤ò»ÈÍѤ¹¤ë¾ì¹ç¤ÏÃí°Õ¤¬É¬ÍפǤ¹¡£ (TBR) =head3 C $hash_ref = $sth->fetchrow_hashref; $hash_ref = $sth->fetchrow_hashref($name); =begin original An alternative to C. Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs. Null fields are returned as C values in the hash. =end original C ¤ÎÂåÍÑÉʤǤ¹¡£ ¼¡¤Î¥Ç¡¼¥¿¹Ô¤ò¼è¤ê½Ð¤·¡¢¥Õ¥£¡¼¥ë¥É¤Î̾Á°¤ÈÃͤΥڥ¢¤ò»ý¤Ã¤¿¥Ï¥Ã¥·¥å¤Ø¤Î ¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ NULL ¥Õ¥£¡¼¥ë¥É¤Ï¥Ï¥Ã¥·¥å¤Î¤Ê¤«¤Î C ¤È¤·¤ÆÊÖ¤µ¤ì¤Þ¤¹¡£ =begin original If there are no more rows or if an error occurs, then C returns an C. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the C returned was due to an error. =end original ¤â¤¦¹Ô¤¬Ìµ¤¤¤«¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢C ¤Ï C ¤ò ÊÖ¤·¤Þ¤¹¡£ ¸å¤ÇÊÖ¤µ¤ì¤¿ C ¤¬¥¨¥é¡¼¤Ë¤è¤ë¤â¤Î¤«¤É¤¦¤«¤ò¸«¤ë¤¿¤á¤Ë¡¢ C<$sth-Eerr> ¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Ù¤­¤Ç¤¹(¤¢¤ë¤¤¤Ï C °À­¤ò »È¤¦¤«)¡£ =begin original The optional C<$name> parameter specifies the name of the statement handle attribute. For historical reasons it defaults to "C", however using either "C" or "C" is recommended for portability. =end original ¥ª¥×¥·¥ç¥ó¤Î C<$name> ¥Ñ¥é¥á¡¼¥¿¤Ë¤Ï¡¢Ê¸¥Ï¥ó¥É¥ë°À­¤Î̾Á°¤ò »ØÄꤷ¤Þ¤¹¡£ °Ü¿¢À­¤ÎÌ̤«¤é¤Ï "C" ¤ä "C" ¤ò»È¤¦¤³¤È¤¬´«¤á¤é¤ì¤ë¤Î¤Ç¤¹¤¬¡¢ Îò»ËŪ¤ÊÍýͳ¤«¤é¡¢¥Ç¥Õ¥©¥ë¥È¤Ï "C" ¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original The keys of the hash are the same names returned by C<$sth-E{$name}>. If more than one field has the same name, there will only be one entry in the returned hash for those fields, so statements like "C" or "C"¤Î¤è¤¦¤Ê¥¹¥Æ¡¼¥È¥á¥ó¥È¤Ï¡¢C¤«¤é1¤Ä¤Î¥­¡¼¤Î¤ß¤òÊÖ¤·¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ï¡¢Îó¤ÎÊÌ̾¤Þ¤¿¤ÏC¤ò»ÈÍѤ·¤Þ¤¹¡£ "C"¤Þ¤¿¤Ï"C"¤Î¤è¤¦¤Ê´Ø¿ô¤ò´Þ¤à¥Õ¥£¡¼¥ë¥É¤ËI¤òÄ󶡤¹¤ë¤Î¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð(DBD¼ÂÁõ¤Ç¤Ï¤Ê¤¤)¤Ç¤¢¤ê¡¢´û¸¤ÎÎó̾¤È¶¥¹ç¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤(¤Û¤È¤ó¤É¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤Ï¡¢·ë²Ì¥»¥Ã¥ÈÆâ¤ÎÎó̾¤Î½ÅÊ£¤Ï¹Í褵¤ì¤Þ¤»¤ó)¡£ ¤³¤ì¤é¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹´Ö¤ÇƱ¤¸°ì°Õ¤Î̾Á°¤È¤·¤ÆÊÖ¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬¥µ¥Ý¡¼¥È¤¹¤ë¹½Ê¸¤Ë±þ¤¸¤Æ¡¢"C"¤Î¤è¤¦¤ËI¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) =begin original Because of the extra work C and Perl have to perform, it is not as efficient as C or C. =end original C ¤ÏÄɲäÎÆ°ºî¤ò¤·¡¢¤µ¤é¤Ë Perl ¤¬Æ°¤«¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ç¡¢ C ¤ä C ¤Û¤É¸úΨ¤è¤¯¤¢¤ê¤Þ¤»¤ó¡£ =begin original By default a reference to a new hash is returned for each row. It is likely that a future version of the DBI will support an attribute which will enable the same hash to be reused for each row. This will give a significant performance boost, but it won't be enabled by default because of the risk of breaking old code. =end original ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¹ÔËè¤Ë¿·¤·¤¤¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤Î DBI ¤Ç¤Ï¹ÔËè¤ËƱ¤¸¥Ï¥Ã¥·¥å¤òºÆÍøÍѤ¹¤ë¤³¤È¤òÍ­¸ú¤Ë¤¹¤ë ¿·¤·¤¤Â°À­¤ËÂбþ¤¹¤ëͽÄê¤Ç¤¹¡£ ¤³¤ì¤ÏÂ礭¤¯À­Ç½¤ò²þÁ±¤µ¤»¤Þ¤¹¤¬¡¢¸Å¤¤¥³¡¼¥É¤ò²õ¤¹¥ê¥¹¥¯¤¬¤¢¤ë¤Î¤Ç ¥Ç¥Õ¥©¥ë¥È¤Ç¤ÏÍ­¸ú¤Ë¤Ê¤é¤Ê¤¤Í½Äê¤Ç¤¹¡£ =head3 C $tbl_ary_ref = $sth->fetchall_arrayref; $tbl_ary_ref = $sth->fetchall_arrayref( $slice ); $tbl_ary_ref = $sth->fetchall_arrayref( $slice, $max_rows ); =begin original The C method can be used to fetch all the data to be returned from a prepared and executed statement handle. It returns a reference to an array that contains one reference per row. =end original C ¥á¥½¥Ã¥É¤Ï prepare ¤µ¤ì¡¢execute ¤µ¤ì¤¿ ʸ¥Ï¥ó¥É¥ë¤«¤é¡¢ÊÖ¤µ¤ì¤ë¤Ù¤­¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤¹¤¿¤á¤Ë »È¤¤¤Þ¤¹¡£ 1 ¹Ô¤Ë¤Ä¤­°ì¤Ä¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤¬Æþ¤Ã¤Æ¤¤¤ëÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original If there are no rows to return, C returns a reference to an empty array. If an error occurs, C returns the data fetched thus far, which may be none. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the data is complete or was truncated due to an error. =end original ¤â¤¦¹Ô¤¬Ìµ¤¤¤«¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢C ¤Ï¶õ¤ÎÇÛÎó¤Ø¤Î ¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤é¡¢C ¤Ï¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤»¤¿¤È¤³¤í¤Þ¤Ç ÊÖ¤·¤Þ¤¹(¤³¤ì¤Ï¶õ¤Ç¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó)¡£ ¥Ç¡¼¥¿¤¬´°Á´¤Ç¤¢¤ë¤«¡¢¥¨¥é¡¼¤Ë¤è¤êÀÚ¤ê¼Î¤Æ¤é¤ì¤¿¤«¤ò¸«¤ë¤¿¤á¤Ë¡¢¸å¤Ç C<$sth-Eerr> ¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤Ù¤­¤Ç¤¹(¤¢¤ë¤¤¤Ï C °À­¤ò »È¤¦¤«)¡£ =begin original If $slice is an array reference, C uses L to fetch each row as an array ref. If the $slice array is not empty then it is used as a slice to select individual columns by perl array index number (starting at 0, unlike column and parameter numbers which start at 1). =end original $slice ¤¬ÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤Ê¤é¡¢C ¤Ï L ¤ò»È¤Ã¤ÆÇÛÎó¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç³Æ¹Ô¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£ ¤â¤· $slice ¤ÎÇÛÎ󤬶õ¤Ç¤Ê¤±¤ì¤Ð¡¢perl ÇÛÎ󥤥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ (0 ¤«¤é»Ï¤Þ¤ê¤Þ¤¹; 1 ¤«¤é»Ï¤Þ¤ëÎó¤ä¥Ñ¥é¥á¡¼¥¿¤ÎÈÖ¹æ¤È¤Ï°ã¤¤¤Þ¤¹) ¤Ë¤è¤Ã¤Æ¤½¤ì¤¾¤ì¤ÎÎó¤òÁªÂò¤·ÀÚ¤ê½Ð¤¹¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ =begin original With no parameters, or if $slice is undefined, C acts as if passed an empty array ref. =end original ¥Ñ¥é¥á¡¼¥¿¤¬¤Ê¤¤¤«¡¢$slice ¤¬Ì¤ÄêµÁÃͤʤ顢C ¤Ï ¶õ¤ÎÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤¬ÅϤµ¤ì¤¿¤è¤¦¤ËÆ°¤­¤Þ¤¹¡£ =begin original If $slice is a hash reference, C uses L to fetch each row as a hash reference. If the $slice hash is empty then fetchrow_hashref() is simply called in a tight loop and the keys in the hashes have whatever name lettercase is returned by default from fetchrow_hashref. (See L attribute.) If the $slice hash is not empty, then it is used as a slice to select individual columns by name. The values of the hash should be set to 1. The key names of the returned hashes match the letter case of the names in the parameter hash, regardless of the L attribute. =end original $slice ¤¬¥Ï¥Ã¥·¥å¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ê¤é¡¢C ¤Ï L ¤ò»È¤Ã¤Æ¡¢³Æ¹Ô¤ò¥Ï¥Ã¥·¥å¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¼è¤ê½Ð¤·¤Þ¤¹¡£ $slice ¥Ï¥Ã¥·¥å¤¬¶õ¤Ê¤é¡¢C ¤Ïñ¤Ë¤­¤Ä¤¤¥ë¡¼¥×¤Ç ¸Æ¤Ð¤ì¤ë¤À¤±¤Ç¡¢¥Ï¥Ã¥·¥å¤Î¥­¡¼¤Ï fetchrow_hashref ¤«¤é¤Î¥Ç¥Õ¥©¥ë¥È¤Ç ÊÖ¤µ¤ì¤ë¤¹¤Ù¤Æ¤Î¾®Ê¸»ú¤Î̾Á°¤ò»ý¤Ä¤À¤±¤Ç¤¹ (L °À­¤ò¤´Í÷¤¯¤À¤µ¤¤)¡£ $slice ¥Ï¥Ã¥·¥å¤¬¶õ¤Ç¤Ê¤±¤ì¤Ð¡¢Ì¾Á°¤Ç¸Ä¡¹¤ÎÎó¤òÁªÂò¤¹¤ë¤¿¤á¤Î¥¹¥é¥¤¥¹¤È¤·¤Æ »È¤ï¤ì¤Þ¤¹¡£ ¥Ï¥Ã¥·¥å¤ÎÃÍ¤Ï 1 ¤ËÀßÄꤵ¤ì¤ë¤Ù¤­¤Ç¤¹¡£ ¤«¤¨¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤Î¥­¡¼Ì¾¤Ï¡¢L °À­¤Ë¤«¤«¤ï¤é¤º ¥Ñ¥é¥á¡¼¥¿¥Ï¥Ã¥·¥å¤Î̾Á°¤Î¾®Ê¸»ú¤È¥Þ¥Ã¥Á¥ó¥°¤µ¤ì¤Þ¤¹¡£ =begin original For example, to fetch just the first column of every row: =end original Î㤨¤Ð¡¢³Æ¹Ô¤ÎÀèƬ¤ÎÎó¤À¤±¤ò¼è¤ê½Ð¤·¤¿¤¤¾ì¹ç¤Ï: $tbl_ary_ref = $sth->fetchall_arrayref([0]); =begin original To fetch the second to last and last column of every row: =end original ³Æ¹Ô¤Î°ìÈÖ¸å¤í¡¢¤½¤ÎľÁ°¤ÎÎó¤ò¼è¤ê½Ð¤¹¤Ë¤Ï: $tbl_ary_ref = $sth->fetchall_arrayref([-2,-1]); =begin original To fetch all fields of every row as a hash ref: =end original ³Æ¹Ô¤ò¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤È¤·¤Æ¼è¤ê½Ð¤¹¤¿¤á¤Ë¤Ï: $tbl_ary_ref = $sth->fetchall_arrayref({}); =begin original To fetch only the fields called "foo" and "bar" of every row as a hash ref (with keys named "foo" and "BAR"): =end original ("foo" ¤ª¤è¤Ó "BAR" ¤È¤¤¤¦¥­¡¼Ì¾¤Ç) ³Æ¹Ô¤Î "foo" ¤È "bar" ¤È¤¤¤¦ ¥Õ¥£¡¼¥ë¥É¤À¤±¤ò¼è¤ê½Ð¤¹¤¿¤á¤Ë¤Ï: $tbl_ary_ref = $sth->fetchall_arrayref({ foo=>1, BAR=>1 }); =begin original The first two examples return a reference to an array of array refs. The third and forth return a reference to an array of hash refs. =end original ºÇ½é¤ÎÆó¤Ä¤ÎÎã¤Ç¤Ï¡¢ÇÛÎó¥ê¥Õ¥¡¥ì¥ó¥¹¤ÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ 3 ÈÖÌÜ¤È 4 ÈÖÌܤÎÎã¤Ï¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤ÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original If $max_rows is defined and greater than or equal to zero then it is used to limit the number of rows fetched before returning. fetchall_arrayref() can then be called again to fetch more rows. This is especially useful when you need the better performance of fetchall_arrayref() but don't have enough memory to fetch and return all the rows in one go. =end original $max_rows¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Æ¡¢0°Ê¾å¤Î¾ì¹ç¤Ï¡¢ÊÖ¤µ¤ì¤ëÁ°¤Ë¥Õ¥§¥Ã¥Á¤µ¤ì¤ë¥í¡¼¤Î¿ô¤òÀ©¸Â¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ ¤½¤Î¸å¡¢fetchall_arrayref()¤òºÆÅٸƤӽФ·¤Æ¡¢¤µ¤é¤Ë¥í¡¼¤ò¥Õ¥§¥Ã¥Á¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢fetchall_arrayref()¤Î¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ò¸þ¾å¤µ¤»¤ëɬÍפ¬¤¢¤ë¤¬¡¢¤¹¤Ù¤Æ¤Î¥í¡¼¤ò°ìÅ٤˥ե§¥Ã¥Á¤·¤ÆÊÖ¤¹¤¿¤á¤Î½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¤ËÆäËÊØÍø¤Ç¤¹¡£ (TBR) =begin original Here's an example (assumes RaiseError is enabled): =end original °Ê²¼¤ÏÎã¤Ç¤¹(RaiseError ¤¬Í­¸ú¤Ç¤¢¤ë¤³¤È¤ò²¾Äꤷ¤Æ¤¤¤Þ¤¹): my $rows = []; # cache for batches of rows while( my $row = ( shift(@$rows) || # get row from cache, or reload cache: shift(@{$rows=$sth->fetchall_arrayref(undef,10_000)||[]}) ) ) { ... } =begin original That I be the fastest way to fetch and process lots of rows using the DBI, but it depends on the relative cost of method calls vs memory allocation. =end original ¤³¤ì¤Ï DBI ¤ò»È¤Ã¤Æ¤¿¤¯¤µ¤ó¤ÎÎó¤ò¥Õ¥§¥Ã¥Á¤·¤Æ½èÍý¤¹¤ë¤¿¤á¤ÎºÇ®¤ÎÊýË¡ I<¤«¤â¤·¤ì¤Þ¤»¤ó> ¤¬¡¢¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·ÂÐ¥á¥â¥ê³ä¤êÅö¤Æ¤ÎÁêÂÐ¥³¥¹¥È¤Ë °Í¸¤·¤Þ¤¹¡£ =begin original A standard C loop with column binding is often faster because the cost of allocating memory for the batch of rows is greater than the saving by reducing method calls. It's possible that the DBI may provide a way to reuse the memory of a previous batch in future, which would then shift the balance back towards fetchall_arrayref(). =end original Îó¥Ð¥¤¥ó¥É¤ò»ÈÍѤ·¤¿É¸½à¤ÎC¥ë¡¼¥×¤Ï¡¢Â¿¤¯¤Î¾ì¹ç¡¢¤è¤ê¹â®¤Ç¤¹¡£ ¤³¤ì¤Ï¡¢¹Ô¤Î¥Ð¥Ã¥Á¤Ë¥á¥â¥ê¤ò³ä¤êÅö¤Æ¤ë¥³¥¹¥È¤¬¡¢¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤òºï¸º¤¹¤ë¤³¤È¤Ë¤è¤ëÀáÌó¤è¤ê¤âÂ礭¤¤¤¿¤á¤Ç¤¹¡£ DBI¤Ï¡¢¾­Íè¡¢°ÊÁ°¤Î¥Ð¥Ã¥Á¤Î¥á¥â¥ê¤òºÆÍøÍѤ¹¤ëÊýË¡¤òÄ󶡤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢¤½¤ì¤Ë¤è¤Ã¤Æ¡¢»Ä¤ê¤ÎÉôʬ¤¬fetchall_arrayref()¤Ë¥·¥Õ¥È¥Ð¥Ã¥¯¤µ¤ì¤Þ¤¹¡£ (TBR) =head3 C $hash_ref = $sth->fetchall_hashref($key_field); =begin original The C method can be used to fetch all the data to be returned from a prepared and executed statement handle. It returns a reference to a hash containing a key for each distinct value of the $key_field column that was fetched. For each key the corresponding value is a reference to a hash containing all the selected columns and their values, as returned by C. =end original C¥á¥½¥Ã¥É¤ò»ÈÍѤ¹¤ë¤È¡¢½àÈ÷¤µ¤ì¼Â¹Ô¤µ¤ì¤¿Ê¸¥Ï¥ó¥É¥ë¤«¤éÌᤵ¤ì¤ë¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ò¥Õ¥§¥Ã¥Á¤Ç¤­¤Þ¤¹¡£ ¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢¥Õ¥§¥Ã¥Á¤µ¤ì¤¿$key_fieldÎó¤Î¸ÄÊ̤ÎÃͤ´¤È¤Ë¥­¡¼¤ò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÌᤷ¤Þ¤¹¡£ ³Æ¥­¡¼¤ËÂбþ¤¹¤ëÃͤϡ¢ÁªÂò¤µ¤ì¤¿¤¹¤Ù¤Æ¤ÎÎó¤È¤½¤ÎÃͤò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤Ç¤¢¤ê¡¢C¤Ë¤è¤Ã¤ÆÌᤵ¤ì¤Þ¤¹¡£ (TBR) =begin original If there are no rows to return, C returns a reference to an empty hash. If an error occurs, C returns the data fetched thus far, which may be none. You should check C<$sth-Eerr> afterwards (or use the C attribute) to discover if the data is complete or was truncated due to an error. =end original ÊÖ¤µ¤ì¤ë¹Ô¤¬¤Ê¤¤¾ì¹ç¡¢C¤Ï¶õ¤Î¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤·¤Þ¤¹¡£ ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¡¢C¤Ï¤½¤ì¤Þ¤Ç¤Ë¥Õ¥§¥Ã¥Á¤µ¤ì¤¿¥Ç¡¼¥¿¤òÊÖ¤·¤Þ¤¹¤¬¡¢²¿¤âÊÖ¤µ¤ì¤Ê¤¤¾ì¹ç¤â¤¢¤ê¤Þ¤¹¡£ ¸å¤ÇC<$sth-Eerr>¤ò¥Á¥§¥Ã¥¯¤·¤Æ(¤Þ¤¿¤ÏC°À­¤ò»ÈÍѤ·¤Æ)¡¢¥Ç¡¼¥¿¤¬´°Á´¤Ç¤¢¤ë¤«¡¢¥¨¥é¡¼¤Î¤¿¤á¤ËÀÚ¤ê¼Î¤Æ¤é¤ì¤¿¤«¤ò¸¡½Ð¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original The $key_field parameter provides the name of the field that holds the value to be used for the key for the returned hash. For example: =end original $key_field ¥Ñ¥é¥á¡¼¥¿¤ÏÊÖ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤Î¥­¡¼¤Î¤¿¤á¤Ë»È¤ï¤ì¤ëÃͤò ÊÝ»ý¤¹¤ë¥Õ¥£¡¼¥ë¥É̾¤òÄ󶡤·¤Þ¤¹¡£ Î㤨¤Ð: $dbh->{FetchHashKeyName} = 'NAME_lc'; $sth = $dbh->prepare("SELECT FOO, BAR, ID, NAME, BAZ FROM TABLE"); $sth->execute; $hash_ref = $sth->fetchall_hashref('id'); print "Name for id 42 is $hash_ref->{42}->{name}\n"; =begin original The $key_field parameter can also be specified as an integer column number (counting from 1). If $key_field doesn't match any column in the statement, as a name first then as a number, then an error is returned. =end original $key_field¥Ñ¥é¥á¡¼¥¿¤Ï¡¢À°¿ô¤ÎÎóÈÖ¹æ(1¤«¤é¿ô¤¨¤ë)¤È¤·¤Æ»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£ $key_field¤¬¥¹¥Æ¡¼¥È¥á¥ó¥ÈÆâ¤Î¤É¤ÎÎó¤È¤â°ìÃפ·¤Ê¤¤¾ì¹ç¤Ï¡¢ºÇ½é¤Ë̾Á°¡¢¼¡¤ËÈÖ¹æ¤È¤·¤Æ¡¢¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original For queries returning more than one 'key' column, you can specify multiple column names by passing $key_field as a reference to an array containing one or more key column names (or index numbers). For example: =end original Ê£¿ô¤Î'key'Îó¤òÊÖ¤¹¥¯¥¨¥ê¤Î¾ì¹ç¡¢1¤Ä°Ê¾å¤Î¥­¡¼Îó̾(¤Þ¤¿¤Ï¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ)¤ò´Þ¤àÇÛÎó¤Ø¤Î»²¾È¤È¤·¤Æ$key_field¤òÅϤ¹¤³¤È¤Ë¤è¤ê¡¢Ê£¿ô¤ÎÎó̾¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $sth = $dbh->prepare("SELECT foo, bar, baz FROM table"); $sth->execute; $hash_ref = $sth->fetchall_hashref( [ qw(foo bar) ] ); print "For foo 42 and bar 38, baz is $hash_ref->{42}->{38}->{baz}\n"; =begin original The fetchall_hashref() method is normally used only where the key fields values for each row are unique. If multiple rows are returned with the same values for the key fields then later rows overwrite earlier ones. =end original fetchall_hashref()¥á¥½¥Ã¥É¤Ï¡¢Ä̾³Æ¹Ô¤Î¥­¡¼¥Õ¥£¡¼¥ë¥ÉÃͤ¬°ì°Õ¤Ç¤¢¤ë¾ì¹ç¤Ë¤Î¤ß»ÈÍѤµ¤ì¤Þ¤¹¡£ ¥­¡¼¥Õ¥£¡¼¥ë¥É¤ËƱ¤¸Ãͤò»ý¤ÄÊ£¿ô¤Î¹Ô¤¬ÊÖ¤µ¤ì¤¿¾ì¹ç¡¢¸å¤Î¹Ô¤¬Á°¤Î¹Ô¤ò¾å½ñ¤­¤·¤Þ¤¹¡£ (TBR) =head3 C $rc = $sth->finish; =begin original Indicate that no more data will be fetched from this statement handle before it is either executed again or destroyed. You almost certainly do I need to call this method. =end original ¤â¤¦°ìÅÙ execute ¤µ¤ì¤ë¤«¡¢Ç˲õ¤µ¤ì¤ë¤Þ¤Ç¡¢¤³¤Îʸ¥Ï¥ó¥É¥ë¤«¤é¤Ï ¤â¤¦¥Ç¡¼¥¿¤¬¼è¤ê½Ð¤µ¤ì¤Ê¤¤¤³¤È¤ò¼¨¤·¤Þ¤¹¡£ ¤Û¤Ü³Î¼Â¤Ë¡¢¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹É¬Í×¤Ï I<¤¢¤ê¤Þ¤»¤ó>¡£ =begin original Adding calls to C after loop that fetches all rows is a common mistake, don't do it, it can mask genuine problems like uncaught fetch errors. =end original Á´¤Æ¤Î¹Ô¤ò¥Õ¥§¥Ã¥Á¤·¤¿¥ë¡¼¥×¤Î¸å¤Ë C ¸Æ¤Ó½Ð¤·¤òÄɲ乤ë¤Î¤Ï ¤è¤¯¤¢¤ë´Ö°ã¤¤¤Ç¤¹; Ê᪤µ¤ì¤Æ¤¤¤Ê¤¤¥Õ¥§¥Ã¥Á¤Î¥¨¥é¡¼¤Î¤è¤¦¤ÊËÜÅö¤ÎÌäÂê¤ò ±£¤·¤Æ¤·¤Þ¤¦¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç¡¢¤½¤¦¤·¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£ =begin original When all the data has been fetched from a C ʸ¤«¤é¼è¤ê½Ð¤µ¤ì¤¿¤é¡¢¥É¥é¥¤¥Ð¤Ï ¼«Æ°Åª¤Ë¤¢¤Ê¤¿¤ËÂå¤Ã¤Æ C ¤·¤Þ¤¹¡£ ¤½¤Î¤¿¤á¡¢Ê¸¥Ï¥ó¥É¥ë¤«¤éÁ´¤Æ¤Î¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤·¤Æ¤ª¤é¤º¡¢ I<¤«¤Ä> ¥Ï¥ó¥É¥ë¤¬¤¹¤°¤Ë¤ÏÇ˲õ¤µ¤ì¤Ê¤¤¾ì¹ç I<°Ê³°¤Ï> ¤³¤ì¤òÌÀ¼¨Åª¤Ë¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤Ï I<¤¢¤ê¤Þ¤»¤ó>¡£ =begin original The most common example is when you only want to fetch just one row, but in that case the C methods are usually better anyway. =end original ¤â¤Ã¤È¤â¤è¤¯¤¢¤ëÎã¤Ï¡¢¤¿¤Ã¤¿ 1 ¹Ô¤À¤±¤ò¥Õ¥§¥Ã¥Á¤·¤¿¤¤¤À¤±¤Î¾ì¹ç¤Ç¤¹¤¬¡¢ ¤½¤Î¾ì¹ç¤Ï C ¥á¥½¥Ã¥É¤ÎÊý¤¬ÉáÄ̤ÏÍ¥¤ì¤Æ¤¤¤Þ¤¹¡£ =begin original Consider a query like: =end original °Ê²¼¤Î¤è¤¦¤ÊÌ䤤¹ç¤ï¤»¤ò¹Í¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤: SELECT foo FROM table WHERE bar=? ORDER BY baz =begin original on a very large table. When executed, the database server will have to use temporary buffer space to store the sorted rows. If, after executing the handle and selecting just a few rows, the handle won't be re-executed for some time and won't be destroyed, the C method can be used to tell the server that the buffer space can be freed. =end original ¤³¤ì¤ò¤È¤Æ¤âÂ礭¤Ê¥Æ¡¼¥Ö¥ë¤ËÂФ·¤Æ¹Ô¤¤¤Þ¤¹¡£ ¼Â¹Ô¤µ¤ì¤ë¤È¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤Ï°ì»þŪ¤Ê¥Ð¥Ã¥Õ¥¡Îΰè¤ò¥½¡¼¥È¤µ¤ì¤¿¹Ô¤ò ³ÊǼ¤¹¤ë¤¿¤á¤Ë»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ ¤â¤·¼Â¹Ô¤·¡¢¿ô¹ÔÁªÂò¤·¤¿¸å¤Ç¡¢¤·¤Ð¤é¤¯¥Ï¥ó¥É¥ë¤¬ºÆ¼Â¹Ô¤µ¤ì¤Ê¤«¤Ã¤¿¤ê¡¢ Ç˲õ¤µ¤ì¤Ê¤¤¤Ê¤é¤Ð¡¢C ¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ¥µ¡¼¥Ð¤Ë¥Ð¥Ã¥Õ¥¡Îΰè¤ò ²òÊü¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤ò¶µ¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original Calling C resets the L attribute for the statement. It may also make some statement handle attributes (such as C and C) unavailable if they have not already been accessed (and thus cached). =end original C ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤Îʸ¤Î L °À­¤Ï ¥ê¥»¥Ã¥È¤µ¤ì¤Þ¤¹¡£ (C ¤ä C ¤Î¤è¤¦¤Ê)¾¤Îʸ¥Ï¥ó¥É¥ë°À­¤Î¤¤¤¯¤Ä¤«¤â¡¢ ´û¤Ë¥¢¥¯¥»¥¹¤µ¤ì¤Æ(¤½¤·¤Æ¥­¥ã¥Ã¥·¥å¤µ¤ì¤Æ)¤¤¤ë¤Î¤Ç¤Ê¤±¤ì¤Ð¡¢ »ÈÍѤǤ­¤Ê¤¯¤Ê¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ =begin original The C method does not affect the transaction status of the database connection. It has nothing to do with transactions. It's mostly an internal "housekeeping" method that is rarely needed. See also L and the L attribute. =end original C ¥á¥½¥Ã¥É¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤Î¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î¾õÂ֤ˤϤʤˤ⠱ƶÁ¤òÍ¿¤¨¤Þ¤»¤ó¡£ ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤È¤Ï̵´Ø·¸¤Ç¤¹¡£ ¤³¤ì¤Ï¤Û¤È¤ó¤ÉÆâÉô¤Î¡Ö²È»öŪ(='housekeeping')¡×¥á¥½¥Ã¥É¤Ç¡¢¤¢¤Þ¤ê ɬÍפʤ³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£ L ¤È L °À­¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original The C method should have been called C. =end original C ¥á¥½¥Ã¥É¤Ï C ¤È¸Æ¤Ð¤ì¤ë¤Ù¤­¤Ç¤·¤¿¡£ =head3 C $rv = $sth->rows; =begin original Returns the number of rows affected by the last row affecting command, or -1 if the number of rows is not known or not available. =end original ºÇ¸å¤Î¥³¥Þ¥ó¥É¤Ë¤è¤ê±Æ¶Á¤ò¼õ¤±¤¿¹Ô¿ô¤òÊÖ¤·¤Þ¤¹¡£ ÉÔÌÀ¤Þ¤¿¤Ï»ÈÍÑÉÔǽ¤Î¾ì¹ç¤Ï -1 ¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original Generally, you can only rely on a row count after a I-C statement. =end original Ä̾¹Ô¥«¥¦¥ó¥È¤Ï I<Èó> C ʸ¤Î¤¹¤Ù¤Æ¤Î¹Ô¤ò ¼è¤ê½Ð¤·¤¿¸å¤Ë¤·¤«¡¢¿®ÍѤǤ­¤Þ¤»¤ó¡£ =begin original For C statements is not recommended. =end original C ʸ¤Ë C ¥á¥½¥Ã¥É¤ä C<$DBI::rows> ¤ò »È¤¦¤³¤È¤Ï¤ª´«¤á¤Ç¤­¤Þ¤»¤ó¡£ =begin original One alternative method to get a row count for a C ¤Î¹Ô¥«¥¦¥ó¥È¤òÆÀ¤ë¤¿¤á¤ÎÂå¤ï¤ê¤ÎÊýË¡¤Î°ì¤Ä¤Ï¡¢ "SELECT COUNT(*) FROM ..." ʸ¤ò¡¢"..."¤ò¤¢¤Ê¤¿¤ÎÌ䤤¹ç¤ï¤»¤È Ʊ¤¸¤Ë¤·¤Æ¼Â¹Ô¤·¡¢¤½¤ì¤«¤é¹Ô¿ô¤ò¼è¤ê½Ð¤¹¤³¤È¤Ç¤¹¡£ =head3 C $rc = $sth->bind_col($column_number, \$var_to_bind); $rc = $sth->bind_col($column_number, \$var_to_bind, \%attr ); $rc = $sth->bind_col($column_number, \$var_to_bind, $bind_type ); =begin original Binds a Perl variable and/or some attributes to an output column (field) of a C¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î½ÐÎÏÎó(¥Õ¥£¡¼¥ë¥É)¤Ë¥Ð¥¤¥ó¥É¤·¤Þ¤¹¡£ ÎóÈÖ¹æ¤Ï1¤«¤é¥«¥¦¥ó¥È¤µ¤ì¤Þ¤¹¡£ ¥Ç¡¼¥¿¤ò¥Õ¥§¥Ã¥Á¤¹¤ë¤¿¤á¤Ë½ÐÎÏÎó¤ò¥Ð¥¤¥ó¥É¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó¡£ ¥É¥é¥¤¥Ð´Ö¤Î°Ü¿¢À­¤òºÇÂç¤Ë¤¹¤ë¤¿¤á¤Ë¡¢bind_col()¤Ïexecute()¤ÎÁ°¤Ç¤Ï¤Ê¤¯¸å¤Ë¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ Îã¤Ë¤Ä¤¤¤Æ¤Ï¡¢C¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The binding is performed at a low level using Perl aliasing. Whenever a row is fetched from the database $var_to_bind appears to be automatically updated simply because it now refers to the same memory location as the corresponding column value. This makes using bound variables very efficient. Binding a tied variable doesn't work, currently. =end original ¥Ð¥¤¥ó¥É¤Ï¡¢Perl¥¨¥¤¥ê¥¢¥¹¤ò»ÈÍѤ·¤ÆÄã¥ì¥Ù¥ë¤Ç¼Â¹Ô¤µ¤ì¤Þ¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥í¡¼¤¬¥Õ¥§¥Ã¥Á¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢$var_to_bind¤Ï¼«Æ°Åª¤Ë¹¹¿·¤µ¤ì¤ë¤è¤¦¤Ë¸«¤¨¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢Âбþ¤¹¤ë¥«¥é¥àÃͤÈƱ¤¸¥á¥â¥ê°ÌÃÖ¤ò»²¾È¤¹¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¤¿¤á¤Ç¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢¥Ð¥¦¥ó¥ÉÊÑ¿ô¤Î»ÈÍѤ¬Èó¾ï¤Ë¸úΨŪ¤Ë¤Ê¤ê¤Þ¤¹¡£ ¥¿¥¤ÊÑ¿ô¤Î¥Ð¥¤¥ó¥É¤Ï¡¢¸½ºß¤Î¤È¤³¤íµ¡Ç½¤·¤Þ¤»¤ó¡£ (TBR) =begin original The L method performs a similar, but opposite, function for input variables. =end original L¥á¥½¥Ã¥É¤Ï¡¢ÆþÎÏÊÑ¿ô¤ËÂФ·¤ÆƱÍͤε¡Ç½¤ò¼Â¹Ô¤·¤Þ¤¹¤¬¡¢µÕ¤Îµ¡Ç½¤ò¼Â¹Ô¤·¤Þ¤¹¡£ (TBR) =begin original B =end original B<Îó¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤Î¤¿¤á¤Î¥Ç¡¼¥¿·¿> =begin original The C<\%attr> parameter can be used to hint at the data type formatting the column should have. For example, you can use: =end original C<\%attr>¥Ñ¥é¥á¡¼¥¿¤ò»ÈÍѤ·¤Æ¡¢Îó¤ËɬÍפʥǡ¼¥¿·¿¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò¼¨¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢¼¡¤Î¤è¤¦¤Ë»ÈÍѤǤ­¤Þ¤¹¡£ (TBR) $sth->bind_col(1, undef, { TYPE => SQL_DATETIME }); =begin original to specify that you'd like the column (which presumably is some kind of datetime type) to be returned in the standard format for SQL_DATETIME, which is 'YYYY-MM-DD HH:MM:SS', rather than the native formatting the database would normally use. =end original ¤³¤ì¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬Ä̾ï»ÈÍѤ¹¤ë¥Í¥¤¥Æ¥£¥Ö·Á¼°¤Ç¤Ï¤Ê¤¯¡¢SQL_DATETIME¤Îɸ½à·Á¼°('YYYY-MM-DD HH:MM:SS')¤ÇÊÖ¤µ¤ì¤ëÎó(¤ª¤½¤é¤¯¤¢¤ë¼ï¤ÎÆü»þ·¿)¤ò»ØÄꤷ¤Þ¤¹¡£ (TBR) =begin original There's no $var_to_bind in that example to emphasize the point that bind_col() works on the underlying column and not just a particular bound variable. =end original ¤³¤ÎÎã¤Ç¤Ï¡¢bind_col()¤¬ÆÃÄê¤Î¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÊÑ¿ô¤À¤±¤Ç¤Ê¤¯¡¢´ðÁäȤʤëÎó¤ËÂФ·¤Æµ¡Ç½¤¹¤ë¤È¤¤¤¦ÅÀ¤ò¶¯Ä´¤¹¤ë¤¿¤á¤Î$var_to_bind¤Ï¤¢¤ê¤Þ¤»¤ó¡£ (TBR) =begin original As a short-cut for the common case, the data type can be passed directly, in place of the C<\%attr> hash reference. This example is equivalent to the one above: =end original ¤è¤¯¤¢¤ë¥±¡¼¥¹¤Î¤¿¤á¤Îû½Ì·Á¤È¤·¤Æ¡¢¥Ç¡¼¥¿·¿¤òľÀÜ C<\%attr> ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¾ì½ê¤ËľÀÜ¡¢ÅϤ¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤³¤ÎÎã¤Ï¡¢¾åµ­¤Î¤â¤Î¤ÈƱ¤¸¤Ç¤¹¡£ $sth->bind_col(1, undef, SQL_DATETIME); =begin original The C value indicates the standard (non-driver-specific) type for this parameter. To specify the driver-specific type, the driver may support a driver-specific attribute, such as C<{ ora_type =E 97 }>. =end original C ¤ÎÃͤϤ³¤Î¥Ñ¥é¥á¡¼¥¿¤Ç¤Ï(¥É¥é¥¤¥Ð¤ËÆÃÍ­¤Ç¤Ê¤¤)ɸ½à¤Î·¿¤ò¼¨¤·¤Þ¤¹¡£ ¥É¥é¥¤¥ÐÆÃÍ­¤Î·¿¤ò»ØÄꤹ¤ë¤¿¤á¤Ë¡¢¥É¥é¥¤¥Ð¤Ï C<{ ora_type => 97 }> ¤È¤¤¤Ã¤¿ ¥É¥é¥¤¥ÐÆÃÍ­¤Î·¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ =begin original The SQL_DATETIME and other related constants can be imported using =end original SQL_DATETIME ¤È´ØÏ¢¤¹¤ëÄê¿ô¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¥¤¥ó¥Ý¡¼¥È¤Ç¤­¤Þ¤¹ use DBI qw(:sql_types); =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Few drivers support specifying a data type via a C call (most will simply ignore the data type). Fewer still allow the data type to be altered once set. =end original C¸Æ¤Ó½Ð¤·¤Ë¤è¤ë¥Ç¡¼¥¿·¿¤Î»ØÄê¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥É¥é¥¤¥Ð¤Ï¤Û¤È¤ó¤É¤¢¤ê¤Þ¤»¤ó(¤Û¤È¤ó¤É¤Î¥É¥é¥¤¥Ð¤Ïñ¤Ë¥Ç¡¼¥¿·¿¤ò̵»ë¤·¤Þ¤¹)¡£ °ìÅÙÀßÄꤵ¤ì¤¿¥Ç¡¼¥¿·¿¤òÊѹ¹¤Ç¤­¤ë¥É¥é¥¤¥Ð¤Ï¤µ¤é¤Ë¾¯¤Ê¤¤¤Ç¤¹¡£ (TBR) =begin original The TYPE attribute for bind_col() was first specified in DBI 1.41. =end original bind_col() ¤Î TYPE °À­¤Ï DBI 1.41 ¤ÇºÇ½é¤ËÄêµÁ¤µ¤ì¤Þ¤·¤¿¡£ =begin original From DBI 1.611, drivers can use the C attribute to attempt to cast the bound scalar to a perl type which more closely matches C. At present DBI supports C, C and C. See L for details of how types are cast. =end original DBI 1.611¤«¤é¡¢¥É¥é¥¤¥Ð¤ÏC°À­¤ò»ÈÍѤ·¤Æ¡¢¥Ð¥¤¥ó¥É¤µ¤ì¤¿¥¹¥«¥é¡¼¤òC¤Ë¤è¤ê¶á¤¤perl·¿¤Ë¥­¥ã¥¹¥È¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¸½ºß¡¢DBI¤ÏC¡¢C¡¢¤ª¤è¤ÓC¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ ·¿¤Î¥­¥ã¥¹¥ÈÊýË¡¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original B =end original B<Îó¤Î¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤Î¤¿¤á¤Î¤½¤Î¾¤Î°À­> =begin original The C<\%attr> parameter may also contain the following attributes: =end original C<\%attr> ¥Ñ¥é¥á¡¼¥¿¤Ë¤Ï°Ê²¼¤Î°À­¤ò´Þ¤á¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹: =over =item C =begin original If a C attribute is passed to bind_col, then the driver will attempt to change the bound perl scalar to match the type more closely. If the bound value cannot be cast to the requested C then by default it is left untouched and no error is generated. If you specify C as 1 and the cast fails, this will generate an error. =end original C°À­¤¬bind_col¤ËÅϤµ¤ì¤¿¾ì¹ç¡¢¥É¥é¥¤¥Ð¤Ï¥Ð¥¤¥ó¥É¤µ¤ì¤¿perl¥¹¥«¥é¡¼¤òÊѹ¹¤·¤Æ¡¢·¿¤ò¤è¤ê¸·Ì©¤Ë°ìÃפµ¤»¤è¤¦¤È¤·¤Þ¤¹¡£ ¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÃͤòÍ׵ᤵ¤ì¤¿C¤Ë¥­¥ã¥¹¥È¤Ç¤­¤Ê¤¤¾ì¹ç¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¤½¤Î¤Þ¤Þ¤Ç¤¢¤ê¡¢¥¨¥é¡¼¤ÏÀ¸À®¤µ¤ì¤Þ¤»¤ó¡£ C¤ò1¤Ë»ØÄꤷ¤Æ¥­¥ã¥¹¥È¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢¥¨¥é¡¼¤¬À¸À®¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original This attribute was first added in DBI 1.611. When 1.611 was released few drivers actually supported this attribute but DBD::Oracle and DBD::ODBC should from versions 1.24. =end original ¤³¤Î°À­¤Ï¡¢DBI 1.611¤ÇºÇ½é¤ËÄɲ䵤ì¤Þ¤·¤¿¡£ 1.611¤¬¥ê¥ê¡¼¥¹¤µ¤ì¤¿¤È¤­¡¢¤³¤Î°À­¤ò¼ÂºÝ¤Ë¥µ¥Ý¡¼¥È¤¹¤ë¥É¥é¥¤¥Ð¤Ï¤Û¤È¤ó¤É¤¢¤ê¤Þ¤»¤ó¤Ç¤·¤¿¤¬¡¢DBD::Oracle¤ÈDBD::ODBC¤Ï¥Ð¡¼¥¸¥ç¥ó1.24¤«¤é¥µ¥Ý¡¼¥È¤µ¤ì¤ë¤Ï¤º¤Ç¤¹¡£ (TBR) =item C =begin original When the C attribute is passed to L and the driver successfully casts the bound perl scalar to a non-string type then if C is set to 1, the string portion of the scalar will be discarded. By default, C is not set. =end original C°À­¤¬L¤ËÅϤµ¤ì¡¢¥É¥é¥¤¥Ð¤¬¥Ð¥¤¥ó¥É¤µ¤ì¤¿perl¥¹¥«¥é¡¼¤òʸ»úÎó°Ê³°¤Î·¿¤Ë¥­¥ã¥¹¥È¤¹¤ë¤³¤È¤ËÀ®¸ù¤·¤¿¾ì¹ç¡¢C¤¬1¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤È¡¢¥¹¥«¥é¡¼¤Îʸ»úÎóÉôʬ¤ÏÇË´þ¤µ¤ì¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢C¤ÏÀßÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ (TBR) =begin original This attribute was first added in DBI 1.611. When 1.611 was released few drivers actually supported this attribute but DBD::Oracle and DBD::ODBC should from versions 1.24. =end original ¤³¤Î°À­¤Ï¡¢DBI 1.611¤ÇºÇ½é¤ËÄɲ䵤ì¤Þ¤·¤¿¡£ 1.611¤¬¥ê¥ê¡¼¥¹¤µ¤ì¤¿¤È¤­¡¢¤³¤Î°À­¤ò¼ÂºÝ¤Ë¥µ¥Ý¡¼¥È¤¹¤ë¥É¥é¥¤¥Ð¤Ï¤Û¤È¤ó¤É¤¢¤ê¤Þ¤»¤ó¤Ç¤·¤¿¤¬¡¢DBD::Oracle¤ÈDBD::ODBC¤Ï¥Ð¡¼¥¸¥ç¥ó1.24¤«¤é¥µ¥Ý¡¼¥È¤µ¤ì¤ë¤Ï¤º¤Ç¤¹¡£ (TBR) =back =head3 C $rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind); =begin original Calls L for each column of the C ʸ¤Î³Æ¥«¥é¥à¤Ë L ¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ =begin original The list of references should have the same number of elements as the number of columns in the C¥¹¥Æ¡¼¥È¥á¥ó¥È¤ÎÎó¤Î¿ô¤ÈƱ¤¸¿ô¤ÎÍ×ÁǤ¬´Þ¤Þ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢C¤Ï»ØÄꤵ¤ì¤¿Í×ÁǤòÎó¤Î¿ô¤Þ¤Ç¥Ð¥¤¥ó¥É¤·¡¢¥¨¥é¡¼¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original For maximum portability between drivers, bind_columns() should be called after execute() and not before. =end original ¥É¥é¥¤¥Ð´Ö¤Î°Ü¿¢À­¤òºÇÂç¸Â¤Ë¹â¤á¤ë¤¿¤á¤Ë¤Ï¡¢bind_columns() ¤Ï execute() ¤Î ¸å¤Ë¸Æ¤Ó½Ð¤µ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original For example: =end original Î㤨¤Ð: $dbh->{RaiseError} = 1; # do this, or check every call for errors $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv = $sth->bind_columns(\$region, \$sales); # you can also use Perl's \(...) syntax (see perlref docs): # $sth->bind_columns(\($region, $sales)); # Column binding is the most efficient way to fetch data while ($sth->fetch) { print "$region: $sales\n"; } =begin original For compatibility with old scripts, the first parameter will be ignored if it is C or a hash reference. =end original ÀΤΥ¹¥¯¥ê¥×¥È¤È¤Î¸ß´¹À­¤Î¤¿¤á¤Ë¡¢ºÇ½é¤Î°ú¿ô¤¬ C ¤â¤·¤¯¤Ï ¥Ï¥Ã¥·¥å¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¢¤ì¤Ð¡¢Ìµ»ë¤µ¤ì¤Þ¤¹¡£ =begin original Here's a more fancy example that binds columns to the values I a hash (thanks to H.Merijn Brand): =end original ¥«¥é¥à¤ò¥Ï¥Ã¥·¥å¤ÎÆ⦤ÎÃͤ˷ë¤Ó¤Ä¤±¤ë¤È¤¤¤¦¡¢¤µ¤é¤Ë¤¹¤´¤¤Îã¤ò ¼¨¤·¤Þ¤¹(H.Merijn Brand ¤Ë´¶¼Õ): $sth->execute; my %row; $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } )); while ($sth->fetch) { print "$row{region}: $row{sales}\n"; } =head3 C $rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh); =begin original Fetches all the rows from C<$sth>, calls C for each row, and prints the results to C<$fh> (defaults to C) separated by C<$lsep> (default C<"\n">). C<$fsep> defaults to C<", "> and C<$maxlen> defaults to 35. =end original C<$sth> ¤«¤é¤¹¤Ù¤Æ¤Î¹Ô¤ò¼è¤ê½Ð¤·¡¢³Æ¹Ô¤Ë C ¤ò¸Æ¤Ó½Ð¤·¡¢ ¤½¤Î·ë²Ì¤ò C<$lsep> (¥Ç¥Õ¥©¥ë¥È¤Ï C<"\n">)¤Ç¶èÀڤäơ¢C<$fh>(¥Ç¥Õ¥©¥ë¥È¤Ï C)¤Ë¡¢½ÐÎϤ·¤Þ¤¹¡£ C<$fsep> ¤Î¥Ç¥Õ¥©¥ë¥È¤Ï C<", ">¡¢C<$maxlen> ¤Î¥Ç¥Õ¥©¥ë¥È¤Ï 35 ¤Ç¤¹¡£ =begin original This method is designed as a handy utility for prototyping and testing queries. Since it uses L to format and edit the string for reading by humans, it is not recommended for data transfer applications. =end original ¤³¤Î¥á¥½¥Ã¥É¤ÏÌ䤤¹ç¤ï¤»¤Î¥×¥í¥È¥¿¥¤¥×¤È¥Æ¥¹¥È¤Î¤¿¤á¤Î´Êñ¤Ê ¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤È¤·¤ÆÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ ¿Í¤ÎÌܤˤ狼¤ê¤ä¤¹¤¤¤è¤¦¤Ëʸ»úÎó¤ÎÀ°·Á¤·¡¢ÊÔ½¸¤¹¤ë L ¤ò »È¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢¥Ç¡¼¥¿Å¾Á÷¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤Ï¤ª´«¤á¤·¤Þ¤»¤ó¡£ =head2 Statement Handle Attributes (ʸ¥Ï¥ó¥É¥ë°À­) =begin original This section describes attributes specific to statement handles. Most of these attributes are read-only. =end original ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ç¤Ïʸ¡¦¥Ï¥ó¥É¥ë¤Î°À­¤Ë¤Ä¤¤¤Æµ­½Ò¤·¤Þ¤¹¡£ ÂçȾ¤Î°À­¤ÏÆɹþ¤Î¤ß¤Ç¤¹¡£ =begin original Changes to these statement handle attributes do not affect any other existing or future statement handles. =end original ¤³¤ì¤é¤Îʸ¡¦¥Ï¥ó¥É¥ë°À­¤òÊѹ¹¤·¤Æ¤â¡¢´û¸¤Î¤Û¤«¤Î¥Ï¥ó¥É¥ë¤ä¸å¤ÇºîÀ®¤µ¤ì¤ëʸ¡¦¥Ï¥ó¥É¥ë¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Þ¤»¤ó¡£ =begin original Attempting to set or get the value of an unknown attribute generates a warning, except for private driver specific attributes (which all have names starting with a lowercase letter). =end original ¥É¥é¥¤¥ÐÆÃÍ­¤Î¥×¥é¥¤¥Ù¡¼¥È¤Ê°À­(¤³¤ì¤é¤Î̾Á°¤Ï¾®Ê¸»ú¤Ç¤Ï¤¸¤Þ¤ê¤Þ¤¹)¤ò ½ü¤¤¤Æ¤Ï¡¢·è¤á¤é¤ì¤Æ¤¤¤Ê¤¤Â°À­¤òÀßÄꤢ¤ë¤¤¤Ï¼èÆÀ¤·¤è¤¦¤È¤¹¤ë¤È ·Ù¹ð¤¬È¯À¸¤·¤Þ¤¹¡£ =begin original Example: =end original Îã: ... = $h->{NUM_OF_FIELDS}; # get/read =begin original Some drivers cannot provide valid values for some or all of these attributes until after C<$sth-Eexecute> has been successfully called. Typically the attribute will be C in these situations. =end original ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢C<$sth-Eexecute> ¤¬¸Æ¤Ð¤ì¤ë¤Þ¤Ç¤Ï¡¢°ìÉô¤¢¤ë¤¤¤Ï ¤¹¤Ù¤Æ¤Î°À­¤Ë¤Ä¤¤¤ÆÀµ¤·¤¤ÃͤòÄ󶡤Ǥ­¤Ê¤¤¤â¤Î¤â¤¢¤ê¤Þ¤¹¡£ ŵ·¿Åª¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ç¤Ï°À­¤Ï C ¤Ë¤Ê¤ê¤Þ¤¹¡£ =begin original Some attributes, like NAME, are not appropriate to some types of statement, like SELECT. Typically the attribute will be C in these situations. =end original NAME¤Î¤è¤¦¤Ê¤¤¤¯¤Ä¤«¤Î°À­¤Ï¡¢SELECT¤Î¤è¤¦¤Ê¤¤¤¯¤Ä¤«¤Î¥¿¥¤¥×¤Î¥¹¥Æ¡¼¥È¥á¥ó¥È¤Ë¤ÏŬÀڤǤϤ¢¤ê¤Þ¤»¤ó¡£ Ä̾¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ç¤Ï°À­¤ÏC¤Ç¤¹¡£ (TBR) =begin original For drivers which support stored procedures and multiple result sets (see more_results) these attributes relate to the I result set. =end original ¥¹¥È¥¢¥É¥×¥í¥·¡¼¥¸¥ã¤ÈÊ£¿ô¤Î·ë²Ì¥»¥Ã¥È(more_results¤ò»²¾È)¤ò¥µ¥Ý¡¼¥È¤¹¤ë¥É¥é¥¤¥Ð¤Î¾ì¹ç¡¢¤³¤ì¤é¤Î°À­¤ÏI·ë²Ì¥»¥Ã¥È¤Ë´ØÏ¢¤·¤Þ¤¹¡£ (TBR) =begin original See also L to learn more about the effect it may have on some attributes. =end original ¤¤¤¯¤Ä¤«¤Î°À­¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤¤³¤È¤Ë¤Ä¤¤¤Æ¡¢¤è¤êÃΤ뤿¤á¤Ë L ¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C (integer, read-only) =begin original Number of fields (columns) in the data the prepared statement may return. Statements that don't return rows of data, like C and C set C to 0 (though it may be undef in some drivers). =end original ½àÈ÷(prepare) ¤µ¤ì¤¿ SQL ʸ¤Î¥Õ¥£¡¼¥ë¥É(¥«¥é¥à)¤Î¿ô¤òÊÖ¤·¤Þ¤¹¡£ C ¤ä C ¤Î¤è¤¦¤Ë¹Ô¿ô¤òÊÖ¤µ¤Ê¤¤Ê¸¤Î¾ì¹ç C ¤Ï 0 ¤òÀßÄꤷ¤Þ¤¹(¤·¤«¤·¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï undef ¤ò ÊÖ¤·¤Þ¤¹)¡£ =head3 C (integer, read-only) =begin original The number of parameters (placeholders) in the prepared statement. See SUBSTITUTION VARIABLES below for more details. =end original ½àÈ÷(prepare)¤µ¤ì¤¿SQLʸ¤Î¥Ñ¥é¥á¡¼¥¿(¥×¥ì¡¼¥¹¥Û¥ë¥À)¤Î¿ô¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï²¼µ­¤ÎÃÖ´¹ÊÑ¿ô¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head3 C (array-ref, read-only) =begin original Returns a reference to an array of field names for each column. The names may contain spaces but should not be truncated or have any trailing space. Note that the names have the letter case (upper, lower or mixed) as returned by the driver being used. Portable applications should use L or L. =end original ³Æ¥«¥é¥à¤ËÂбþ¤¹¤ë¥Õ¥£¡¼¥ë¥É̾¤ÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ̾Á°¤Ë¤Ï¶õÇò¤¬Æþ¤Ã¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¡¢ÀÚ¤ê¼Î¤Æ¤é¤ì¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¤·¡¢ ¸å¤í¤Î¶õÇò¤ò»ý¤Á¤Þ¤¹¡£ ÊÖ¤µ¤ì¤ë¤È¤­¤Îʸ»ú¤ÎÂçʸ»ú¡¢¾®Ê¸»ú¡¢¤½¤Îº®¹ç¤Ï»È¤ï¤ì¤Æ¤¤¤ë ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤è¤ë¤È¤¤¤¦¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ °Ü¿¢À­¤Î¹â¤¤¥¢¥×¥ê¡¼¥±¡¼¥·¥ç¥ó¤Ï L ¤Þ¤¿¤Ï L ¤ò»È¤¦¤Ù¤­¤Ç¤¹¡£ print "First column name: $sth->{NAME}->[0]\n"; =begin original Also note that the name returned for (aggregate) functions like C or C is determined by the database server and not by C or the C backend. =end original ¤Þ¤¿¡¢C¤äC¤Ê¤É¤Î(½¸Ìó)´Ø¿ô¤ËÂФ·¤ÆÊÖ¤µ¤ì¤ë̾Á°¤Ï¡¢C¤äC¥Ð¥Ã¥¯¥¨¥ó¥É¤Ç¤Ï¤Ê¤¯¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥µ¡¼¥Ð¤Ë¤è¤Ã¤Æ·èÄꤵ¤ì¤ë¤³¤È¤Ë¤âÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head3 C (array-ref, read-only) =begin original Like L but always returns lowercase names. =end original L ¤ÈƱÍͤǤ¹¤¬¾ï¤Ë¾®Ê¸»ú¤Ç̾Á°¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =head3 C (array-ref, read-only) =begin original Like L but always returns uppercase names. =end original L ¤ÈƱÍͤǤ¹¤¬¾ï¤ËÂçʸ»ú¤Ç̾Á°¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ =head3 C (hash-ref, read-only) =head3 C (hash-ref, read-only) =head3 C (hash-ref, read-only) =begin original The C, C, and C attributes return column name information as a reference to a hash. =end original C¡¢C¡¢¤ª¤è¤ÓC°À­¤Ï¡¢¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤È¤·¤ÆÎó̾¾ðÊó¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original The keys of the hash are the names of the columns. The letter case of the keys corresponds to the letter case returned by the C, C, and C attributes respectively (as described above). =end original ¥Ï¥Ã¥·¥å¤Î¥­¡¼¤ÏÎó¤Î̾Á°¤Ç¤¹¡£ ¥­¡¼¤ÎÂçʸ»ú¾®Ê¸»ú¤Ï¡¢C¡¢C¤ª¤è¤ÓC°À­(Á°½Ò)¤Ë¤è¤Ã¤Æ¤½¤ì¤¾¤ìÌᤵ¤ì¤ëÂçʸ»ú¾®Ê¸»ú¤ËÂбþ¤·¤Þ¤¹¡£ (TBR) =begin original The value of each hash entry is the perl index number of the corresponding column (counting from 0). For example: =end original ³Æ¥Ï¥Ã¥·¥å¥¨¥ó¥È¥ê¤ÎÃͤϡ¢Âбþ¤¹¤ëÎó¤Îperl¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ¤Ç¤¹(0¤«¤é¿ô¤¨¤Þ¤¹)¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) $sth = $dbh->prepare("select Id, Name from table"); $sth->execute; @row = $sth->fetchrow_array; print "Name $row[ $sth->{NAME_lc_hash}{name} ]\n"; =head3 C (array-ref, read-only) =begin original Returns a reference to an array of integer values for each column. The value indicates the data type of the corresponding column. =end original ³Æ¥«¥é¥à¤ËÂбþ¤¹¤ëÀ°¿ôÃͤÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ÃͤÏÂбþ¤¹¤ë¥«¥é¥à¤Î¥Ç¡¼¥¿·¿¤ò¼¨¤·¤Þ¤¹¡£ =begin original The values correspond to the international standards (ANSI X3.135 and ISO/IEC 9075) which, in general terms, means ODBC. Driver-specific types that don't exactly match standard types should generally return the same values as an ODBC driver supplied by the makers of the database. That might include private type numbers in ranges the vendor has officially registered with the ISO working group: =end original ¤³¤ÎÃͤϹñºÝµ¬Ìó(ANSI X3.135 ¤È ISO/IEC 9075)(°ìÈÌ¤Ë¤Ï ODBC ¤ò°ÕÌ£¤·¤Þ¤¹)¤Ë Âбþ¤·¤Æ¤¤¤Þ¤¹¡£ ɸ½à¤Î·¿¤ËÀµ³Î¤Ë¤¢¤Æ¤Ï¤Þ¤é¤Ê¤¤¡¢¥É¥é¥¤¥ÐÆÃÍ­¤Î·¿¤Ç¤Ï¡¢Ä̾¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î ¥á¡¼¥«¡¼¤¬Ä󶡤¹¤ë ODBC ¥É¥é¥¤¥Ð¤ÈƱ¤¸ÃͤòÊÖ¤µ¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó¡£ ¤³¤ì¤Ï¥Ù¥ó¥À¡¼¤¬¸ø¼°¤Ë ISO ¥ï¡¼¥­¥ó¥°¥°¥ë¡¼¥×¤ËͽÌ󤷤Ƥ¤¤ë¥×¥é¥¤¥Ù¡¼¥È¤Ê ·¿ÈÖ¹æ¤ò´Þ¤ß¤Þ¤¹¡£: ftp://sqlstandards.org/SC32/SQL_Registry/ =begin original Where there's no vendor-supplied ODBC driver to be compatible with, the DBI driver can use type numbers in the range that is now officially reserved for use by the DBI: -9999 to -9000. =end original DBI ¥É¥é¥¤¥Ð¤Ï¸ß´¹À­¤ò»ý¤Ä ODBC ¥É¥é¥¤¥Ð¤òÄ󶡤µ¤ì¤Æ¤¤¤ë¥Ù¥ó¥À¡¼¤¬¤Ê¤±¤ì¤Ð¡¢ DBI ¤¬»ÈÍѤ¹¤ë¤¿¤á¤Ë¸ø¼°¤ËͽÌ󤵤ì¤Æ¤¤¤ë -9999 ¤«¤é -9000 ¤ÎÈϰϤη¿ÈÖ¹æ¤ò »È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original All possible values for C should have at least one entry in the output of the C method (see L). =end original C ¤¬¤È¤ê¤¦¤ë¤¹¤Ù¤Æ¤ÎÃͤϡ¢C ¥á¥½¥Ã¥É¤Î½ÐÎϤΤʤ«¤Î¡¢ ¾¯¤Ê¤¯¤È¤â°ì¤Ä¤ÎÍ×ÁǤȤ·¤ÆÆþ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó (L ¤ò¤´Í÷²¼¤µ¤¤)¡£ =head3 C (array-ref, read-only) =begin original Returns a reference to an array of integer values for each column. =end original ³Æ¥«¥é¥à¤ËÂбþ¤¹¤ëÀ°¿ôÃͤÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ =begin original For numeric columns, the value is the maximum number of digits (without considering a sign character or decimal point). Note that the "display size" for floating point types (REAL, FLOAT, DOUBLE) can be up to 7 characters greater than the precision (for the sign + decimal point + the letter E + a sign + 2 or 3 digits). =end original ¿ôÃͤΥ«¥é¥à¤Ç¤Ï¡¢ÃͤϿôÃͤκÇÂç·å¿ô¤Ç¤¹ (Éä¹æʸ»ú¤ä¾®¿ôÅÀ¤ò½ü¤­¤Þ¤¹)¡£ ÉâÆ°¾®¿ôÅÀ¤Î·¿(REAL, FLOAT, DOUBLE)¤Ç¤Ï¡Öɽ¼¨¥µ¥¤¥º¡×¤Ï precision ¤è¤ê¤â 7 ʸ»ú¤Þ¤Ç¤Ï¡¢Â礭¤¤¤«¤â¤·¤ì¤Þ¤»¤ó (Éä¹æ + ¾®¿ôÅÀ + E ¤È¤¤¤¦Ê¸»ú + Éä¹æ +2 ¤Þ¤¿¤Ï 3 ·å)¡£ =begin original For any character type column the value is the OCTET_LENGTH, in other words the number of bytes, not characters. =end original ¤É¤Îʸ»ú¥¿¥¤¥×Îó¤Ç¤â¡¢ÃͤÏOCTET_LENGTH¡¢¤Ä¤Þ¤êʸ»ú¤Ç¤Ï¤Ê¤¯¥Ð¥¤¥È¿ô¤Ç¤¹¡£ (TBR) =begin original (More recent standards refer to this as COLUMN_SIZE but we stick with PRECISION for backwards compatibility.) =end original (ºÇ¶á¤Îɸ½à¤Ç¤Ï¤³¤ì¤òCOLUMN_SIZE¤È¸Æ¤ó¤Ç¤¤¤Þ¤¹¤¬¡¢¸åÊý¸ß´¹À­¤Î¤¿¤á¤ËPRECISION¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹)¡£ (TBR) =head3 C (array-ref, read-only) =begin original Returns a reference to an array of integer values for each column. NULL (C) values indicate columns where scale is not applicable. =end original ³Æ¥«¥é¥à¤ËÂбþ¤¹¤ëÀ°¿ôÃͤÎÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ NULL (C) Ãͤˤϡ¢scale ¤¬Å¬ÍѤµ¤ì¤Ê¤¤¤³¤È¤ò¼¨¤·¤Þ¤¹¡£ =head3 C (array-ref, read-only) =begin original Returns a reference to an array indicating the possibility of each column returning a null. Possible values are C<0> (or an empty string) = no, C<1> = yes, C<2> = unknown. =end original ³Æ¥«¥é¥à¤¬ NULL ¤Ë¤·¤Æ¤¤¤¤¤«¤É¤¦¤«¤ò¼¨¤¹ÃͤòÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ ¤È¤ê¤¦¤ëÃͤϡ¢0 (¤Þ¤¿¤Ï¶õʸ»úÎó)= ¼õ¤±Æþ¤ì¤Ê¤¤¡¢1 = ¼õ¤±Æþ¤ì¤ë¡¢ 2 = ÉÔÌÀ¤Ç¤¹¡£ print "First column may return NULL\n" if $sth->{NULLABLE}->[0]; =head3 C (string, read-only) =begin original Returns the name of the cursor associated with the statement handle, if available. If not available or if the database driver does not support the C<"where current of ..."> SQL syntax, then it returns C. =end original ʸ¥Ï¥ó¥É¥ë¤¬»È¤¨¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢Ê¸¥Ï¥ó¥É¥ë¤Ë ·ë¤ÓÉÕ¤±¤é¤ì¤¿¥«¡¼¥½¥ë̾¤òÊÖ¤·¤Þ¤¹¡£ »È¤¨¤Ê¤¤¤«¡¢"where current of ..." SQL ¤Î½ñ¤­Êý¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹¥É¥é¥¤¥Ð¤¬ ¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤±¤ì¤Ð C ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C (dbh, read-only) =begin original Returns the parent $dbh of the statement handle. =end original ʸ¥Ï¥ó¥É¥ë¤Î¿Æ $dbh ¤òÊÖ¤·¤Þ¤¹¡£ =head3 C (string, read-only) =begin original Returns the statement string passed to the L method. =end original L ¥á¥½¥Ã¥É¤ËÅϤµ¤ì¤¿¡¢Ê¸Ê¸»úÎó¤òÊÖ¤·¤Þ¤¹¡£ =head3 C (hash ref, read-only) =begin original Returns a reference to a hash containing the values currently bound to placeholders. The keys of the hash are the 'names' of the placeholders, typically integers starting at 1. Returns undef if not supported by the driver. =end original ¸½ºß¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤¤¤ëÃͤò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤·¤Þ¤¹¡£ ¥Ï¥Ã¥·¥å¤Î¥­¡¼¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤Î¡Ö̾Á°¡×¤Ç¡¢Ä̾ï¤Ï1¤«¤é»Ï¤Þ¤ëÀ°¿ô¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ïundef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original See L for an example of how this is used. =end original ¤³¤ì¤Î»È¤¤Êý¤Ë´Ø¤¹¤ëÎã¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original * Keys: =end original * ¥­¡¼: =begin original If the driver supports C but no values have been bound yet then the driver should return a hash with placeholders names in the keys but all the values undef, but some drivers may return a ref to an empty hash because they can't pre-determine the names. =end original ¥É¥é¥¤¥Ð¤¬C¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Æ¡¢Ãͤ¬¤Þ¤À¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¥É¥é¥¤¥Ð¤Ï¥­¡¼¤Ë¥×¥ì¡¼¥¹¥Û¥ë¥À̾¤ò»ý¤Ä¥Ï¥Ã¥·¥å¤òÊÖ¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¤¬¡¢¤¹¤Ù¤Æ¤ÎÃͤÏundef¤Ç¤¹¡£ ¤¿¤À¤·¡¢¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï¡¢Ì¾Á°¤ò»öÁ°¤Ë·èÄê¤Ç¤­¤Ê¤¤¤¿¤á¡¢¶õ¤Î¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤¹¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original It is possible that the keys in the hash returned by C are not exactly the same as those implied by the prepared statement. For example, DBD::Oracle translates 'C' placeholders into 'C<:pN>' where N is a sequence number starting at 1. =end original C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¥Ï¥Ã¥·¥åÆâ¤Î¥­¡¼¤Ï¡¢½àÈ÷¤µ¤ì¤¿Ê¸¤Ë¤è¤Ã¤Æ°Å¼¨¤µ¤ì¤ë¥­¡¼¤ÈÀµ³Î¤Ë¤ÏƱ¤¸¤Ç¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢DBD::Oracle¤Ï'C'¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò'C<:pN>'¤ËÊÑ´¹¤·¤Þ¤¹¡£ ¤³¤³¤Ç¡¢N¤Ï1¤«¤é»Ï¤Þ¤ë¥·¡¼¥±¥ó¥¹ÈÖ¹æ¤Ç¤¹¡£ (TBR) =begin original * Values: =end original * ÃÍ: =begin original It is possible that the values in the hash returned by C are not I the same as those passed to bind_param() or execute(). The driver may have slightly modified values in some way based on the TYPE the value was bound with. For example a floating point value bound as an SQL_INTEGER type may be returned as an integer. The values returned by C can be passed to another bind_param() method with the same TYPE and will be seen by the database as the same value. See also L below. =end original C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤ÎÃͤϡ¢bind_param()¤Þ¤¿¤Ïexecute()¤ËÅϤµ¤ì¤¿ÃͤÈ<Àµ³Î¤Ë>Ʊ¤¸¤Ç¤Ï¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¡¢Ãͤ¬¥Ð¥¤¥ó¥É¤µ¤ì¤¿TYPE¤Ë´ð¤Å¤¤¤Æ¡¢²¿¤é¤«¤ÎÊýË¡¤Ç¤ï¤º¤«¤ËÊѹ¹¤µ¤ì¤¿Ãͤò»ý¤Ä¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢SQL_INTEGER·¿¤È¤·¤Æ¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÉâÆ°¾®¿ôÅÀÃͤϡ¢À°¿ô¤È¤·¤ÆÊÖ¤µ¤ì¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤¿Ãͤϡ¢Æ±¤¸TYPE¤ò»ý¤ÄÊ̤Îbind_param()¥á¥½¥Ã¥É¤ËÅϤ¹¤³¤È¤¬¤Ç¤­¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ç¤ÏƱ¤¸ÃͤȤ·¤Æɽ¼¨¤µ¤ì¤Þ¤¹¡£ ¸å½Ò¤ÎL¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original The C attribute was added in DBI 1.28. =end original C °À­¤Ï DBI 1.28 ¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ =head3 C (hash ref, read-only) =begin original Returns a reference to a hash containing the type information currently bound to placeholders. Returns undef if not supported by the driver. =end original ¸½ºß¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ë¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤¤¤ë·¿¾ðÊó¤ò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ïundef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original * Keys: =end original * ¥­¡¼: =begin original See L above. =end original ¾å½Ò¤Î L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original * Values: =end original * ÃÍ: =begin original The hash values are hashrefs of type information in the same form as that passed to the various bind_param() methods (See L for the format and values). =end original ¥Ï¥Ã¥·¥åÃͤϡ¢¤µ¤Þ¤¶¤Þ¤Êbind_param()¥á¥½¥Ã¥É¤ËÅϤµ¤ì¤ë¤â¤Î¤ÈƱ¤¸·Á¼°¤Î·¿¾ðÊó¤Îhashrefs¤Ç¤¹(·Á¼°¤ÈÃͤˤĤ¤¤Æ¤ÏL¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£ (TBR) =begin original It is possible that the values in the hash returned by C are not exactly the same as those passed to bind_param() or execute(). Param attributes specified using the abbreviated form, like this: =end original C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¥Ï¥Ã¥·¥å¤ÎÃͤϡ¢bind_param()¤Þ¤¿¤Ïexecute()¤ËÅϤµ¤ì¤ëÃͤÈÀµ³Î¤Ë¤ÏƱ¤¸¤Ç¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ param°À­¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¾Êά·Á¼°¤ò»ÈÍѤ·¤Æ»ØÄꤵ¤ì¤Þ¤¹¡£ (TBR) $sth->bind_param(1, SQL_INTEGER); =begin original are returned in the expanded form, as if called like this: =end original ¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¸Æ¤Ó½Ð¤µ¤ì¤¿¤«¤Î¤è¤¦¤Ë³ÈÄ¥·Á¼°¤ÇÊÖ¤µ¤ì¤Þ¤¹: $sth->bind_param(1, { TYPE => SQL_INTEGER }); =begin original The driver may have modified the type information in some way based on the bound values, other hints provided by the prepare()'d SQL statement, or alternate type mappings required by the driver or target database system. The driver may also add private keys (with names beginning with the drivers reserved prefix, e.g., odbc_xxx). =end original ¥É¥é¥¤¥Ð¤Ï¡¢¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÃÍ¡¢prepare()¤µ¤ì¤¿SQL¥¹¥Æ¡¼¥È¥á¥ó¥È¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë¾¤Î¥Ò¥ó¥È¡¢¤Þ¤¿¤Ï¥É¥é¥¤¥Ð¤Þ¤¿¤Ï¥¿¡¼¥²¥Ã¥È¥Ç¡¼¥¿¥Ù¡¼¥¹¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤ÆɬÍפȤµ¤ì¤ëÂåÂØ¥¿¥¤¥×¥Þ¥Ã¥Ô¥ó¥°¤Ë´ð¤Å¤¤¤Æ¡¢²¿¤é¤«¤ÎÊýË¡¤Ç¥¿¥¤¥×¾ðÊó¤òÊѹ¹¤·¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¡¢¥×¥é¥¤¥Ù¡¼¥È¥­¡¼(odbc_xxx¤Ê¤É¡¢¥É¥é¥¤¥Ð¤ÎͽÌóºÑ¤ß¥×¥ì¥Õ¥£¥¯¥¹¤Ç»Ï¤Þ¤ë̾Á°¤ò»ý¤Ä)¤òÄɲ乤뤳¤È¤â¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original * Example: =end original * Îã: =begin original The keys and values in the returned hash can be passed to the various bind_param() methods to effectively reproduce a previous param binding. For example: =end original Ìᤵ¤ì¤¿¥Ï¥Ã¥·¥å¤Î¥­¡¼¤ª¤è¤ÓÃͤòÍÍ¡¹¤Êbind_param()¥á¥½¥Ã¥É¤ËÅϤ·¤Æ¡¢Á°¤Îparam¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¸ú²ÌŪ¤ËºÆ¸½¤Ç¤­¤Þ¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) # assuming $sth1 is a previously prepared statement handle my $sth2 = $dbh->prepare( $sth1->{Statement} ); my $ParamValues = $sth1->{ParamValues} || {}; my $ParamTypes = $sth1->{ParamTypes} || {}; $sth2->bind_param($_, $PV->{$_} $PT->{$_}) for keys %{ %$PV, %$PT }; $sth2->execute(); =begin original The C attribute was added in DBI 1.49. Implementation is the responsibility of individual drivers; the DBI layer default implementation simply returns undef. =end original C°À­¤Ï¡¢DBI 1.49¤ÇÄɲ䵤ì¤Þ¤·¤¿¡£ ¼ÂÁõ¤Ï¸Ä¡¹¤Î¥É¥é¥¤¥Ð¤¬¹Ô¤¤¤Þ¤¹¡£ DBI¥ì¥¤¥ä¤Î¥Ç¥Õ¥©¥ë¥È¤Î¼ÂÁõ¤Ï¡¢Ã±¤Ëundef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =head3 C (hash ref, read-only) =begin original Returns a reference to a hash containing the values currently bound to placeholders with L or L. The keys of the hash are the 'names' of the placeholders, typically integers starting at 1. Returns undef if not supported by the driver or no arrays of parameters are bound. =end original L¤Þ¤¿¤ÏL¤ò»ý¤Ä¥×¥ì¡¼¥¹¥Û¥ë¥À¤Ë¸½ºß¥Ð¥¤¥ó¥É¤µ¤ì¤Æ¤¤¤ëÃͤò´Þ¤à¥Ï¥Ã¥·¥å¤Ø¤Î»²¾È¤òÊÖ¤·¤Þ¤¹¡£ ¥Ï¥Ã¥·¥å¤Î¥­¡¼¤Ï¥×¥ì¡¼¥¹¥Û¥ë¥À¤Î¡Ö̾Á°¡×¤Ç¡¢Ä̾ï¤Ï1¤«¤é»Ï¤Þ¤ëÀ°¿ô¤Ç¤¹¡£ ¥É¥é¥¤¥Ð¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¤Þ¤¿¤Ï¥Ñ¥é¥á¡¼¥¿¤ÎÇÛÎ󤬥Х¤¥ó¥É¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢undef¤òÊÖ¤·¤Þ¤¹¡£ (TBR) =begin original Each key value is an array reference containing a list of the bound parameters for that column. =end original ³Æ¥­¡¼Ãͤϡ¢¤½¤ÎÎó¤Î¥Ð¥¤¥ó¥É¤µ¤ì¤¿¥Ñ¥é¥á¡¼¥¿¤Î¥ê¥¹¥È¤ò´Þ¤àÇÛÎ󻲾ȤǤ¹¡£ (TBR) =begin original For example: =end original Î㤨¤Ð: $sth = $dbh->prepare("INSERT INTO staff (id, name) values (?,?)"); $sth->execute_array({},[1,2], ['fred','dave']); if ($sth->{ParamArrays}) { foreach $param (keys %{$sth->{ParamArrays}}) { printf "Parameters for %s : %s\n", $param, join(",", @{$sth->{ParamArrays}->{$param}}); } } =begin original It is possible that the values in the hash returned by C are not I the same as those passed to L or L. The driver may have slightly modified values in some way based on the TYPE the value was bound with. For example a floating point value bound as an SQL_INTEGER type may be returned as an integer. =end original C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤¿¥Ï¥Ã¥·¥å¤ÎÃͤϡ¢L¤Þ¤¿¤ÏL¤ËÅϤµ¤ì¤¿ÃͤÈ<Àµ³Î¤Ë>Ʊ¤¸¤Ç¤Ï¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ï¡¢Ãͤ¬¥Ð¥¤¥ó¥É¤µ¤ì¤¿TYPE¤Ë´ð¤Å¤¤¤Æ¡¢²¿¤é¤«¤ÎÊýË¡¤Ç¤ï¤º¤«¤ËÊѹ¹¤µ¤ì¤¿Ãͤò»ý¤Ä¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢SQL_INTEGER·¿¤È¤·¤Æ¥Ð¥¤¥ó¥É¤µ¤ì¤¿ÉâÆ°¾®¿ôÅÀÃͤϡ¢À°¿ô¤È¤·¤ÆÊÖ¤µ¤ì¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original It is also possible that the keys in the hash returned by C are not exactly the same as those implied by the prepared statement. For example, DBD::Oracle translates 'C' placeholders into 'C<:pN>' where N is a sequence number starting at 1. =end original ¤Þ¤¿¡¢C¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¥Ï¥Ã¥·¥åÆâ¤Î¥­¡¼¤¬¡¢½àÈ÷¤µ¤ì¤¿Ê¸¤Ë¤è¤Ã¤Æ°Å¼¨¤µ¤ì¤ë¥­¡¼¤ÈÀµ³Î¤ËƱ¤¸¤Ç¤Ê¤¤²ÄǽÀ­¤â¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢DBD::Oracle¤Ï¡¢'C'¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò'C<:pN>'¤ËÊÑ´¹¤·¤Þ¤¹¡£ ¤³¤³¤Ç¡¢N¤Ï1¤«¤é»Ï¤Þ¤ë¥·¡¼¥±¥ó¥¹ÈÖ¹æ¤Ç¤¹¡£ (TBR) =head3 C (integer, read-only) =begin original If the driver supports a local row cache for C ʸ¤Ë¤Ä¤¤¤Æ¥í¡¼¥«¥ë¤Ê¹Ô¥­¥ã¥Ã¥·¥å¤ò ¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ì¤Ð¡¢¤³¤Î°À­¤Ï¥­¥ã¥·¥å¤Î¤Ê¤«¤Ç fetch ¤µ¤ì¤Æ¤¤¤Ê¤¤¹Ô¿ô¤ò ÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤¬¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢C ¤òÊÖ¤·¤Þ¤¹¡£ ¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï execute »þÅÀ¤ÇÁ°¤â¤Ã¤Æ¼è¤ê½Ð¤¹¤â¤Î¤â¤¢¤ê¤Þ¤¹¤·¡¢ºÇ½é¤Î fetch ¤¬Íè¤ë¤Þ¤ÇÂԤĤâ¤Î¤â¤¢¤ê¤Þ¤¹¡£ =begin original See also the L database handle attribute. =end original ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë°À­ L ¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =head1 FURTHER INFORMATION (¤µ¤é¤Ê¤ë¾ðÊó) =head2 Catalog Methods (¥«¥¿¥í¥°¥á¥½¥Ã¥É) =begin original An application can retrieve metadata information from the DBMS by issuing appropriate queries on the views of the Information Schema. Unfortunately, C views are seldom supported by the DBMS. Special methods (catalog methods) are available to return result sets for a small but important portion of that metadata: =end original ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¾ðÊó¥¹¥­¡¼¥Þ¤Î¥Ó¥å¡¼¤ËÂФ·¤ÆŬÀÚ¤ÊÌä¹ç¤»¤òȯ¹Ô¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢DBMS¤«¤é¥á¥¿¥Ç¡¼¥¿¾ðÊó¤ò¼èÆÀ¤Ç¤­¤Þ¤¹¡£ »ÄÇ°¤Ê¤¬¤é¡¢C¥Ó¥å¡¼¤ÏDBMS¤Ç¤Ï¤Û¤È¤ó¤É¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ¤½¤Î¥á¥¿¥Ç¡¼¥¿¤Î¾®¤µ¤¤¤¬½ÅÍפÊÉôʬ¤Î·ë²Ì¥»¥Ã¥È¤òÌ᤹¤¿¤á¤Ë¡¢ÆÃÊ̤ʥ᥽¥Ã¥É(¥«¥¿¥í¥°¥á¥½¥Ã¥É)¤ò»ÈÍѤǤ­¤Þ¤¹¡£ (TBR) column_info foreign_key_info primary_key_info table_info statistics_info =begin original All catalog methods accept arguments in order to restrict the result sets. Passing C to an optional argument does not constrain the search for that argument. However, an empty string ('') is treated as a regular search criteria and will only match an empty value. =end original ¤¹¤Ù¤Æ¤Î¥«¥¿¥í¥°¥á¥½¥Ã¥É¤Ï¡¢·ë²Ì¥»¥Ã¥È¤òÀ©¸Â¤¹¤ë¤¿¤á¤Ë°ú¿ô¤ò¼õ¤±Æþ¤ì¤Þ¤¹¡£ ¥ª¥×¥·¥ç¥ó¤Î°ú¿ô¤ËC¤òÅϤ·¤Æ¤â¡¢¤½¤Î°ú¿ô¤Î¸¡º÷¤ÏÀ©¸Â¤µ¤ì¤Þ¤»¤ó¡£ ¤¿¤À¤·¡¢¶õ¤Îʸ»úÎó('')¤ÏÄ̾ï¤Î¸¡º÷´ð½à¤È¤·¤Æ°·¤ï¤ì¡¢¶õ¤ÎÃͤˤΤ߰ìÃפ·¤Þ¤¹¡£ (TBR) =begin original B: SQL/CLI and ODBC differ in the handling of empty strings. An empty string will not restrict the result set in SQL/CLI. =end original B<Ãí>:SQL/CLI¤ÈODBC¤Ç¤Ï¡¢¶õ¤Îʸ»úÎó¤Î½èÍý¤¬°Û¤Ê¤ê¤Þ¤¹¡£ ¶õ¤Îʸ»úÎó¤Ï¡¢SQL/CLI¤Î·ë²Ì¥»¥Ã¥È¤òÀ©¸Â¤·¤Þ¤»¤ó¡£ (TBR) =begin original Most arguments in the catalog methods accept only I, e.g. the arguments of C. Such arguments are treated as a literal string, i.e. the case is significant and quote characters are taken literally. =end original ¥«¥¿¥í¥°¥á¥½¥Ã¥É¤Î¤Û¤È¤ó¤É¤Î°ú¿ô¤Ï¡¢I<Ä̾ï¤ÎÃÍ>¤Î¤ß¤ò¼õ¤±Æþ¤ì¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢C¤Î°ú¿ô¤Ê¤É¤Ç¤¹¡£ ¤³¤Î¤è¤¦¤Ê°ú¿ô¤Ï¥ê¥Æ¥é¥ëʸ»úÎó¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ ¤Ä¤Þ¤ê¡¢Âçʸ»ú¤È¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¡¢°úÍÑÉä¤Ïʸ»úÄ̤ê¤Ë²ò¼á¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Some arguments in the catalog methods accept I (strings containing '_' and/or '%'), e.g. the C<$table> argument of C. Passing '%' is equivalent to leaving the argument C. =end original C¤ÎC<$table>°ú¿ô¤Ê¤É¡¢¥«¥¿¥í¥°¥á¥½¥Ã¥É¤Î°ìÉô¤Î°ú¿ô¤Ï¡¢I(¡Ö_¡×¤Þ¤¿¤Ï¡Ö%¡×¤ò´Þ¤àʸ»úÎó)¤ò¼õ¤±Æþ¤ì¤Þ¤¹¡£ ¡Ö%¡×¤òÅϤ¹¤³¤È¤Ï¡¢°ú¿ôC¤ò»Ä¤¹¤³¤È¤ÈƱ¤¸¤Ç¤¹¡£ (TBR) =begin original B: The underscore ('_') is valid and often used in SQL identifiers. Passing such a value to a search pattern argument may return more rows than expected! To include pattern characters as literals, they must be preceded by an escape character which can be achieved with =end original B<Ãí°Õ»ö¹à>:¥¢¥ó¥À¡¼¥¹¥³¥¢('_')¤ÏÍ­¸ú¤Ç¤¢¤ê¡¢SQL¼±Ê̻ҤǤ褯»ÈÍѤµ¤ì¤Þ¤¹¡£ ¤³¤Î¤è¤¦¤ÊÃͤò¸¡º÷¥Ñ¥¿¡¼¥ó°ú¿ô¤ËÅϤ¹¤È¡¢Í½ÁÛ¤è¤ê¤â¿¤¯¤Î¹Ô¤¬ÊÖ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹!¥Ñ¥¿¡¼¥óʸ»ú¤ò¥ê¥Æ¥é¥ë¤È¤·¤Æ´Þ¤á¤ë¤Ë¤Ï¡¢¥Ñ¥¿¡¼¥óʸ»ú¤ÎÁ°¤Ë¥¨¥¹¥±¡¼¥×ʸ»ú¤òÉÕ¤±¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤Ï (TBR) $esc = $dbh->get_info( 14 ); # SQL_SEARCH_PATTERN_ESCAPE $search_pattern =~ s/([_%])/$esc$1/g; =begin original The ODBC and SQL/CLI specifications define a way to change the default behaviour described above: All arguments (except I) are treated as I if the C attribute is set to C. I are very similar to I, i.e. their body (the string within the quotes) is interpreted literally. I are compared in UPPERCASE. =end original ODBC¤ª¤è¤ÓSQL/CLI¤Î»ÅÍͤǤϡ¢Á°½Ò¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤òÊѹ¹¤¹¤ëÊýË¡¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ C°À­¤¬C¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤¹¤Ù¤Æ¤Î°ú¿ô(I¤ò½ü¤¯)¤ÏI¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹¡£ I¤ÏI¤ÈÈó¾ï¤Ë¤è¤¯»÷¤Æ¤¤¤Þ¤¹¡£ ¤Ä¤Þ¤ê¡¢ËÜʸ(°úÍÑÉä¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó)¤Ïʸ»ú¤É¤ª¤ê¤Ë²ò¼á¤µ¤ì¤Þ¤¹¡£ I¤ÏÂçʸ»ú¤ÇÈæ³Ó¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original The DBI (currently) does not support the C attribute, i.e. it behaves like an ODBC driver where C is set to C. =end original DBI¤Ï(¸½ºß)C°À­¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£ ¤Ä¤Þ¤ê¡¢C¤¬C¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëODBC¥É¥é¥¤¥Ð¤Î¤è¤¦¤ËÆ°ºî¤·¤Þ¤¹¡£ (TBR) =head2 Transactions (¥È¥é¥ó¥¶¥¯¥·¥ç¥ó) =begin original Transactions are a fundamental part of any robust database system. They protect against errors and database corruption by ensuring that sets of related changes to the database take place in atomic (indivisible, all-or-nothing) units. =end original ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ï¤¹¤Ù¤Æ¤Î·øÏ´¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹¥·¥¹¥Æ¥à¤Î´ðËÜŪ¤ÊÉôʬ¤Ç¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤Î´ØÏ¢¤¹¤ë°ìÏ¢¤ÎÊѹ¹¤¬¡¢¥¢¥È¥ß¥Ã¥¯¤Ê(ÆÈΩ¤·¤Æ¤¤¤Æ ¥ª¡¼¥ë¥ª¥¢¥Ê¥Ã¥·¥ó¥°¤Ê)ñ°Ì¤Ç¹Ô¤ï¤ì¤ë¤³¤ÈÊݾڤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥¨¥é¡¼¤È ¥Ç¡¼¥¿¥Ù¡¼¥¹¾ã³²¤«¤é¼é¤ê¤Þ¤¹¡£ =begin original This section applies to databases that support transactions and where C is off. See L for details of using C with various types of databases. =end original ¤³¤ÎÀá¤Ï¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥µ¥Ý¡¼¥È¤·¡¢C ¤¬¥ª¥Õ¤Ë ¤Ê¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤¢¤Æ¤Ï¤Þ¤ê¤Þ¤¹¡£ ³Æ¼ï¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÂФ¹¤ë C ¤Î»È¤¤Êý¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original The recommended way to implement robust transactions in Perl applications is to use C and S> (which is very fast, unlike S>). For example: =end original Perl ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç·øÏ´¤Ê¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¼Â¸½¤¹¤ë¤¿¤á¤Î¤ª´«¤á¤ÎÊýË¡¤Ï¡¢ C ¤È S> ¤ò»È¤¦¤³¤È¤Ç¤¹ (¤³¤ì¤Ï S> ¤È°ã¤Ã¤Æ¤È¤Æ¤â®¤¯Æ°ºî¤·¤Þ¤¹)¡£ Î㤨¤Ð: =begin original $dbh->{AutoCommit} = 0; # enable transactions, if possible $dbh->{RaiseError} = 1; eval { foo(...) # do lots of work here bar(...) # including inserts baz(...) # and updates $dbh->commit; # commit the changes if we get this far }; if ($@) { warn "Transaction aborted because $@"; # now rollback to undo the incomplete changes # but do it in an eval{} as it may also fail eval { $dbh->rollback }; # add other application on-error-clean-up code here } =end original $dbh->{AutoCommit} = 0; # ²Äǽ¤Ç¤¢¤ì¤Ð¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÍ­¸ú¤Ë¤·¤Þ¤¹ $dbh->{RaiseError} = 1; eval { foo(...) # INSERT ¤ä UPDATE ¤ò´Þ¤à bar(...) # ¿¤¯¤Î½èÍý¤ò baz(...) # ¤³¤³¤Ç¤·¤Þ¤¹ $dbh->commit; # ¤³¤³¤Þ¤ÇÍ褿¤é¥³¥ß¥Ã¥È¤·¤Þ¤¹ }; if ($@) { warn "Transaction aborted because $@"; # ¤³¤³¤ÇÉÔ´°Á´¤ÊÊѹ¹¤ò¸µ¤ËÌ᤹¤¿¤á¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤Þ¤¹ # ¤·¤«¤·¤³¤ì¤â¼ºÇÔ¤¹¤ë¤³¤È¤¬¤¢¤ë¤Î¤Ç eval{} ¤ÎÃæ¤Ç¹Ô¤¤¤Þ¤¹ eval { $dbh->rollback }; # ¾¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¸åÊÒÉÕ¤±¤Î½èÍý¤ò¤³¤³¤ËÆþ¤ì¤Þ¤¹ } =begin original If the C attribute is not set, then DBI calls would need to be manually checked for errors, typically like this: =end original C °À­¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢DBI ¸Æ¤Ó½Ð¤·¤Ï¼êÆ°¤Ç¥¨¥é¡¼¤Î ¥Á¥§¥Ã¥¯¤ò¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ Ä̾ï¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Þ¤¹: $h->method(@args) or die $h->errstr; =begin original With C set, the DBI will automatically C if any DBI method call on that handle (or a child handle) fails, so you don't have to test the return value of each method call. See L for more details. =end original C ¤òÀßÄꤹ¤ë¤È¡¢¤½¤Î¥Ï¥ó¥É¥ë(¤Þ¤¿¤Ï¤½¤Î»Ò¶¡¤Î¥Ï¥ó¥É¥ë)¤Ç ¸Æ¤Ó½Ð¤µ¤ì¤ë DBI ¥á¥½¥Ã¥É¤¬¼ºÇÔ¤¹¤ë¤È¡¢DBI ¤Ï¼«Æ°Åª¤Ë die ¤·¤Þ¤¹¡£ ¤½¤Î¤¿¤á³Æ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ÎÌá¤êÃͤò¤¤¤Á¤¤¤Á¥Á¥§¥Ã¥¯¤¹¤ëɬÍפ¬ ¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =begin original A major advantage of the C approach is that the transaction will be properly rolled back if I code (not just DBI calls) in the inner application dies for any reason. The major advantage of using the C<$h-E{RaiseError}> attribute is that all DBI calls will be checked automatically. Both techniques are strongly recommended. =end original C ¤Ë¤è¤ëÊýË¡¤ÎÂ礭¤ÊÍøÅÀ¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥óÆâÉô¤Î¤¤¤«¤Ê¤ëÍýͳ¤Ç¡¢ (DBI¸Æ¤Ó½Ð¤·¤Ë¸Â¤é¤º)¤É¤Î¤è¤¦¤Ê½èÍý¤Ç die ¤·¤Æ¤â¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤¬ ŬÀÚ¤Ë¥í¡¼¥ë¥Ð¥Ã¥¯¤µ¤ì¤ë¤³¤È¤Ë¤¢¤ê¤Þ¤¹¡£ $h->{RaiseError} °À­¤ò»È¤¦Â礭¤ÊÍøÅÀ¤Ï¡¢¤¹¤Ù¤Æ¤Î DBI ¸Æ¤Ó½Ð¤·¤¬¼«Æ°Åª¤Ë ¥Á¥§¥Ã¥¯¤µ¤ì¤ë¤³¤È¤Ë¤¢¤ê¤Þ¤¹¡£ ¤É¤Á¤é¤Î¥Æ¥¯¥Ë¥Ã¥¯¤â¶¯¤¯¤ª´«¤á¤·¤Þ¤¹¡£ =begin original After calling C or C many drivers will not let you fetch from a previously active C statements. =end original C ¤ä C ¤ò¸Æ¤Ó½Ð¤·¤¿¸å¡¢Â¿¤¯¤Î¥É¥é¥¤¥Ð¤ÏƱ¤¸ ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤Î»Ò¶¡¤Ç°ÊÁ°¤Ï¥¢¥¯¥Æ¥£¥Ö¤À¤Ã¤¿ C ʸ¤Î¤¿¤á¤Ë»È¤¦¤³¤È¤Ç¤¹¡£ =begin original See L and L for other important information about transactions. =end original ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ë´Ø¤¹¤ë¤½¤Î¾¤Î½ÅÍפʾðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤È L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 Handling BLOB / LONG / Memo Fields (BLOB / LONG / Memo¥Õ¥£¡¼¥ë¥É¤ò°·¤¦) =begin original Many databases support "blob" (binary large objects), "long", or similar datatypes for holding very long strings or large amounts of binary data in a single field. Some databases support variable length long values over 2,000,000,000 bytes in length. =end original ¿¤¯¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï°ì¤Ä¤Î¥Õ¥£¡¼¥ë¥É¤Ë¤È¤Æ¤âŤ¤Ê¸»úÎó¤ä¡¢µðÂç¤Ê ¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤òÊÝ»ý¤¹¤ë¤¿¤á¤Ë¡¢"blob" (binary large objects¡áµðÂç¤Ê¥Ð¥¤¥Ê¥ê ¥ª¥Ö¥¸¥§¥¯¥È), "long" ¤Þ¤¿¤ÏƱ¤¸¤è¤¦¤Ê¥Ç¡¼¥¿·¿¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤è¤Ã¤Æ¤Ï¡¢2,000,000,000 ¥Ð¥¤¥È¤ò±Û¤¨¤ë¤è¤¦¤ÊŤµ¤Î²ÄÊÑŤÎÃͤ⠥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£ =begin original Since values of that size can't usually be held in memory, and because databases can't usually know in advance the length of the longest long that will be returned from a C ʸ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ëºÇÂçŤò¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ï Á°¤â¤Ã¤Æ¤ï¤«¤é¤Ê¤¤¤³¤È¤«¤é¡¢ÆÃÊ̤ÊÁàºî¤¬É¬Íפˤʤê¤Þ¤¹¡£ =begin original In this situation, the value of the C<$h-E{LongReadLen}> attribute is used to determine how much buffer space to allocate when fetching such fields. The C<$h-E{LongTruncOk}> attribute is used to determine how to behave if a fetched value can't fit into the buffer. =end original ¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¡¢¤½¤Î¤è¤¦¤Ê¥Õ¥£¡¼¥ë¥É¤ò¼è¤ê½Ð¤¹¤È¤­¤Ë¡¢¤É¤ì¤¯¤é¤¤¤Î ¥Ð¥Ã¥Õ¥¡¥¹¥Ú¡¼¥¹¤ò³ÎÊݤ¹¤ë¤«¤ò·è¤á¤ë¤¿¤á¤Ë¡¢C<$h-E{LongReadLen}> °À­¤Î Ãͤ¬»È¤ï¤ì¤Þ¤¹¡£ C<$h-E{LongTruncOk}> °À­¤Ï¡¢¼è¤ê½Ð¤·¤¿Ãͤ¬¥Ð¥Ã¥Õ¥¡¤Ë Æþ¤ê¤­¤é¤Ê¤«¤Ã¤¿¤È¤­¤Ë¤É¤Î¤è¤¦¤Ë¿¶¤ëÉñ¤¦¤«¤ò·èÄꤹ¤ë¤Î¤Ë»È¤ï¤ì¤Þ¤¹¡£ =begin original See the description of L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤Îµ­½Ò¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original When trying to insert long or binary values, placeholders should be used since there are often limits on the maximum size of an C statement and the L method generally can't cope with binary data. See L. =end original Ť¤Ãͤä¥Ð¥¤¥Ê¥ê¤ÎÃͤòÁÞÆþ¤¹¤ë¤È¤­¡¢C ʸ¤ÎÂ礭¤µ¤Ë¤Ï ¤è¤¯¸ÂÅÙ¤¬¤¢¤ê¡¢L ¥á¥½¥Ã¥É¤ÏÄ̾ï¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ËÂнè¤Ç¤­¤Ê¤¤¤Î¤Ç¡¢ ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head2 Simple Examples (´Êñ¤ÊÎã) =begin original Here's a complete example program to select and fetch some data: =end original ¥Ç¡¼¥¿¤ò¤¤¤¯¤Ä¤«ÁªÂò(select)¤·¡¢¼è¤ê½Ð¤¹(fetch)°ìÄ̤귤ä¿¥×¥í¥°¥é¥àÎã¤ò °Ê²¼¤Ë¼¨¤·¤Þ¤¹: my $data_source = "dbi::DriverName:db_name"; my $dbh = DBI->connect($data_source, $user, $password) or die "Can't connect to $data_source: $DBI::errstr"; my $sth = $dbh->prepare( q{ SELECT name, phone FROM mytelbook }) or die "Can't prepare statement: $DBI::errstr"; my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr"; print "Query will return $sth->{NUM_OF_FIELDS} fields.\n\n"; print "Field names: @{ $sth->{NAME} }\n"; while (($name, $phone) = $sth->fetchrow_array) { print "$name: $phone\n"; } # check for problems which may have terminated the fetch early die $sth->errstr if $sth->err; $dbh->disconnect; =begin original Here's a complete example program to insert some data from a file. (This example uses C to avoid needing to check each call). =end original ¥Õ¥¡¥¤¥ë¤«¤é¥Ç¡¼¥¿¤òÁÞÆþ¤¹¤ë°ìÄ̤귤ä¿¥×¥í¥°¥é¥àÎã¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£ (¤³¤ÎÎã¤Ç¤Ï³Æ¸Æ¤Ó½Ð¤·¤Ç¥Á¥§¥Ã¥¯¤¹¤ëɬÍפò¤Ê¤¯¤¹¤¿¤á¤Ë¡¢C ¤ò »È¤Ã¤Æ¤¤¤Þ¤¹)¡£ my $dbh = DBI->connect("dbi:DriverName:db_name", $user, $password, { RaiseError => 1, AutoCommit => 0 }); my $sth = $dbh->prepare( q{ INSERT INTO table (name, phone) VALUES (?, ?) }); open FH, ") { chomp; my ($name, $phone) = split /,/; $sth->execute($name, $phone); } close FH; $dbh->commit; $dbh->disconnect; =begin original Here's how to convert fetched NULLs (undefined values) into empty strings: =end original ¤³¤ì¤Ï¼è¤ê½Ð¤·¤¿ NULL(̤ÄêµÁÃÍ)¤ò¶õʸ»úÎó¤ËÊÑ´¹¤¹¤ëÊýË¡¤Ç¤¹: while($row = $sth->fetchrow_arrayref) { # this is a fast and simple way to deal with nulls: foreach (@$row) { $_ = '' unless defined } print "@$row\n"; } =begin original The C style quoting used in these examples avoids clashing with quotes that may be used in the SQL statement. Use the double-quote like C operator if you want to interpolate variables into the string. See L for more details. =end original SQLʸ¤Ç»È¤ï¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¥¯¥©¡¼¥È¤ÎÂбþ¤¬²õ¤ì¤Ê¤¤¤è¤¦¤Ë¡¢ ¤³¤ì¤éÎã¤Ç¤Ï C ·Á¼°¤Î¥¯¥©¡¼¥È¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ ʸ»úÎóÃæ¤ÎÊÑ¿ô¤ò²ò¼á¤·¤ÆÍߤ·¤¤¤È¤­¤Ë¤Ï¡¢C ±é»»»Ò¤Î¤è¤¦¤Ê ¥À¥Ö¥ë¡¦¥¯¥©¡¼¥È¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ ¾ÜºÙ¤Ï L ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ =head2 Threads and Thread Safety (¥¹¥ì¥Ã¥É¤È¥¹¥ì¥Ã¥É¥»¡¼¥ÕÀ­) =begin original Perl 5.7 and later support a new threading model called iThreads. (The old "5.005 style" threads are not supported by the DBI.) =end original Perl 5.7°Ê¹ß¤Ç¤Ï¡¢iThread¤È¸Æ¤Ð¤ì¤ë¿·¤·¤¤¥¹¥ì¥Ã¥É²½¥â¥Ç¥ë¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹(¸Å¤¤¡Ö5.005¥¹¥¿¥¤¥ë¡×¤Î¥¹¥ì¥Ã¥É¤ÏDBI¤Ç¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó)¡£ (TBR) =begin original In the iThreads model each thread has it's own copy of the perl interpreter. When a new thread is created the original perl interpreter is 'cloned' to create a new copy for the new thread. =end original iThread¥â¥Ç¥ë¤Ç¤Ï¡¢³Æ¥¹¥ì¥Ã¥É¤Ïperl¥¤¥ó¥¿¥×¥ê¥¿¤ÎÆȼ«¤Î¥³¥Ô¡¼¤ò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£ ¿·¤·¤¤¥¹¥ì¥Ã¥É¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢¸µ¤Îperl¥¤¥ó¥¿¥×¥ê¥¿¤¬¡ÖÊ£À½¡×¤µ¤ì¡¢¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î¿·¤·¤¤¥³¥Ô¡¼¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original If the DBI and drivers are loaded and handles created before the thread is created then it will get a cloned copy of the DBI, the drivers and the handles. =end original DBI¤È¥É¥é¥¤¥Ð¤¬¥í¡¼¥É¤µ¤ì¡¢¥¹¥ì¥Ã¥É¤¬ºîÀ®¤µ¤ì¤ëÁ°¤Ë¥Ï¥ó¥É¥ë¤¬ºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ï¡¢DBI¡¢¥É¥é¥¤¥Ð¡¢¥Ï¥ó¥É¥ë¤Î¥¯¥í¡¼¥ó¥³¥Ô¡¼¤¬¼èÆÀ¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original However, the internal pointer data within the handles will refer to the DBI and drivers in the original interpreter. Using those handles in the new interpreter thread is not safe, so the DBI detects this and croaks on any method call using handles that don't belong to the current thread (except for DESTROY). =end original ¤¿¤À¤·¡¢¥Ï¥ó¥É¥ëÆâ¤ÎÆâÉô¥Ý¥¤¥ó¥¿¥Ç¡¼¥¿¤Ï¡¢¸µ¤Î¥¤¥ó¥¿¥×¥ê¥¿Æâ¤ÎDBI¤ª¤è¤Ó¥É¥é¥¤¥Ð¤ò»²¾È¤·¤Þ¤¹¡£ ¿·¤·¤¤¥¤¥ó¥¿¥×¥ê¥¿¥¹¥ì¥Ã¥É¤Ç¤³¤ì¤é¤Î¥Ï¥ó¥É¥ë¤ò»ÈÍѤ¹¤ë¤³¤È¤Ï°ÂÁ´¤Ç¤Ï¤Ê¤¤¤¿¤á¡¢DBI¤Ï¤³¤ì¤ò¸¡½Ð¤·¡¢¸½ºß¤Î¥¹¥ì¥Ã¥É¤Ë°¤·¤Æ¤¤¤Ê¤¤¥Ï¥ó¥É¥ë(DESTROY¤ò½ü¤¯)¤ò»ÈÍѤ¹¤ë¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ò¸¡½Ð¤·¤Þ¤¹¡£ (TBR) =begin original Because of this (possibly temporary) restriction, newly created threads must make their own connections to the database. Handles can't be shared across threads. =end original ¤³¤Î(¤ª¤½¤é¤¯°ì»þŪ¤Ê)À©¸Â¤Î¤¿¤á¡¢¿·¤·¤¯ºîÀ®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤ÎÆȼ«¤ÎÀܳ¤òºîÀ®¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¥Ï¥ó¥É¥ë¤Ï¥¹¥ì¥Ã¥É´Ö¤Ç¶¦Í­¤Ç¤­¤Þ¤»¤ó¡£ (TBR) =begin original But BEWARE, some underlying database APIs (the code the DBD driver uses to talk to the database, often supplied by the database vendor) are not thread safe. If it's not thread safe, then allowing more than one thread to enter the code at the same time may cause subtle/serious problems. In some cases allowing more than one thread to enter the code, even if I at the same time, can cause problems. You have been warned. =end original ¤·¤«¤·Ãí°Õ¤·¤Æ¤Û¤·¤¤¤Î¤Ç¤¹¤¬¡¢´ðÈפȤʤë¥Ç¡¼¥¿¥Ù¡¼¥¹API(DBD¥É¥é¥¤¥Ð¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÈÄÌ¿®¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¥³¡¼¥É¤Ç¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ù¥ó¥À¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë¤³¤È¤¬Â¿¤¤¤â¤Î)¤ÎÃæ¤Ë¤Ï¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤Ê¤¤¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£ ¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤Ê¤¤¾ì¹ç¡¢Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬Æ±»þ¤Ë¥³¡¼¥É¤òÆþÎϤǤ­¤ë¤è¤¦¤Ë¤¹¤ë¤È¡¢Èù̯¤ÊÌäÂê¤ä¿¼¹ï¤ÊÌäÂ꤬ȯÀ¸¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ï¡¢Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬¥³¡¼¥É¤òÆþÎϤǤ­¤ë¤è¤¦¤Ë¤¹¤ë¤È¡¢Æ±»þ¤Ë<¤·¤Ê¤¤>¾ì¹ç¤Ç¤â¡¢ÌäÂ꤬ȯÀ¸¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ·Ù¹ð¤µ¤ì¤Þ¤·¤¿¡£ (TBR) =begin original Using DBI with perl threads is not yet recommended for production environments. For more information see L =end original perl¥¹¥ì¥Ã¥É¤ÇDBI¤ò»ÈÍѤ¹¤ë¤³¤È¤Ï¡¢ËÜÈִĶ­¤Ç¤Ï¤Þ¤À¿ä¾©¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original Note: There is a bug in perl 5.8.2 when configured with threads and debugging enabled (bug #24463) which causes a DBI test to fail. =end original Ãí:perl 5.8.2¤Ë¤Ï¡¢¥¹¥ì¥Ã¥É¤È¥Ç¥Ð¥Ã¥°¤òÍ­¸ú¤Ë¤·¤ÆÀßÄꤷ¤¿¾ì¹ç¤Ë¡¢DBI¥Æ¥¹¥È¤¬¼ºÇÔ¤¹¤ë¥Ð¥°(¥Ð¥°#24463)¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head2 Signal Handling and Canceling Operations (¥·¥°¥Ê¥ë¤Î°·¤¤¤È¥­¥ã¥ó¥»¥ëÁàºî) =begin original [The following only applies to systems with unix-like signal handling. I'd welcome additions for other systems, especially Windows.] =end original [°Ê²¼¤ÏUnix¥é¥¤¥¯¤Ê¥·¥°¥Ê¥ë½èÍý¤ò¹Ô¤¦¥·¥¹¥Æ¥à¤Ë¤Î¤ßŬÍѤµ¤ì¤Þ¤¹¡£ ¾¤Î¥·¥¹¥Æ¥à¡¢ÆäËWindows¤Ç¤ÎÄɲäò´¿·Þ¤·¤Þ¤¹¡£ ] (TBR) =begin original The first thing to say is that signal handling in Perl versions less than 5.8 is I safe. There is always a small risk of Perl crashing and/or core dumping when, or after, handling a signal because the signal could arrive and be handled while internal data structures are being changed. If the signal handling code used those same internal data structures it could cause all manner of subtle and not-so-subtle problems. The risk was reduced with 5.4.4 but was still present in all perls up through 5.8.0. =end original ºÇ½é¤Ë¸À¤¦¤Ù¤­¤³¤È¤Ï¡¢5.8¤è¤êÁ°¤ÎPerl¥Ð¡¼¥¸¥ç¥ó¤Ç¤Î¥·¥°¥Ê¥ë½èÍý¤Ï°ÂÁ´¤Ç¤Ï¤Ê¤¤¤È¤¤¤¦¤³¤È¤Ç¤¹¡£ ÆâÉô¥Ç¡¼¥¿¹½Â¤¤¬Êѹ¹¤µ¤ì¤Æ¤¤¤ë´Ö¤Ë¥·¥°¥Ê¥ë¤¬ÅþÃ夷¤Æ½èÍý¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢¥·¥°¥Ê¥ë¤ò½èÍý¤¹¤ë¤È¤­¡¢¤Þ¤¿¤Ï½èÍý¤·¤¿¸å¤Ë¡¢Perl¤¬¥¯¥é¥Ã¥·¥å¤·¤¿¤ê¡¢¥³¥¢¥À¥ó¥×¤·¤¿¤ê¤¹¤ë¾®¤µ¤Ê¥ê¥¹¥¯¤¬¾ï¤Ë¤¢¤ê¤Þ¤¹¡£ ¥·¥°¥Ê¥ë½èÍý¥³¡¼¥É¤¬Æ±¤¸ÆâÉô¥Ç¡¼¥¿¹½Â¤¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¡¢¤¢¤é¤æ¤ë¼ïÎà¤ÎÈù̯¤ÊÌäÂê¤ä¤½¤ì¤Û¤ÉÈù̯¤Ç¤Ï¤Ê¤¤ÌäÂ꤬ȯÀ¸¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤Î¥ê¥¹¥¯¤Ï5.4.4ǯ¤Ë¤Ï¸º¾¯¤·¤¿¤¬¡¢5.8.0ǯ¤Þ¤Ç¤ÏÁ´¥Ú¥ë¥ë¤Ë°ÍÁ³¤È¤·¤Æ¸ºß¤·¤Æ¤¤¤¿¡£ (TBR) =begin original Beginning in perl 5.8.0 perl implements 'safe' signal handling if your system has the POSIX sigaction() routine. Now when a signal is delivered perl just makes a note of it but does I run the %SIG handler. The handling is 'deferred' until a 'safe' moment. =end original perl 5.8.0°Ê¹ß¤Ç¤Ï¡¢¥·¥¹¥Æ¥à¤ËPOSIX sigaction()¥ë¡¼¥Á¥ó¤¬¤¢¤ì¤Ð¡¢perl¤Ï¡Ö°ÂÁ´¤Ê¡×¥·¥°¥Ê¥ë½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£ ¸½ºß¤Ç¤Ï¡¢¥·¥°¥Ê¥ë¤¬ÇÛ¿®¤µ¤ì¤ë¤Èperl¤Ï¤½¤ì¤òµ­Ï¿¤¹¤ë¤À¤±¤Ç¤¹¤¬¡¢»ä¤Ï%SIG¥Ï¥ó¥É¥é¤ò¼Â¹Ô¤·¤Þ¤»¤ó¡£ ½èÍý¤Ï¡Ö°ÂÁ´¤Ê¡×½Ö´Ö¤Þ¤Ç¡Ö±ä´ü¡×¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Although this change made signal handling safe, it also lead to a problem with signals being deferred for longer than you'd like. If a signal arrived while executing a system call, such as waiting for data on a network connection, the signal is noted and then the system call that was executing returns with an EINTR error code to indicate that it was interrupted. All fine so far. =end original ¤³¤ÎÊѹ¹¤Ë¤è¤Ã¤Æ¥·¥°¥Ê¥ë½èÍý¤Ï°ÂÁ´¤Ë¤Ê¤ê¤Þ¤·¤¿¤¬¡¢¥·¥°¥Ê¥ë¤¬É¬Íװʾå¤ËÃٱ䤵¤ì¤ë¤È¤¤¤¦ÌäÂê¤âȯÀ¸¤·¤Þ¤¹¡£ ¥Í¥Ã¥È¥ï¡¼¥¯Àܳ¤Ç¥Ç¡¼¥¿¤òÂÔµ¡¤·¤Æ¤¤¤ë¤È¤­¤Ê¤É¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¼Â¹ÔÃæ¤Ë¥·¥°¥Ê¥ë¤¬ÅþÃ夹¤ë¤È¡¢¤½¤Î¥·¥°¥Ê¥ë¤¬µ­Ï¿¤µ¤ì¡¢¼Â¹ÔÃæ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢ÃæÃǤµ¤ì¤¿¤³¤È¤ò¼¨¤¹EINTR¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£ º£¤Î¤È¤³¤íÂç¾æÉפǤ¹¡£ (TBR) =begin original The problem comes when the code that made the system call sees the EINTR code and decides it's going to call it again. Perl doesn't do that, but database code sometimes does. If that happens then the signal handler doesn't get called until later. Maybe much later. =end original ÌäÂê¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¹Ô¤Ã¤¿¥³¡¼¥É¤¬EINTR¥³¡¼¥É¤ò¸«¤Æ¡¢¤½¤ì¤òºÆÅٸƤӽФ¹¤³¤È¤ò·èÄꤷ¤¿¤È¤­¤ËȯÀ¸¤·¤Þ¤¹¡£ Perl¤Ï¤½¤¦¤·¤Þ¤»¤ó¤¬¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥³¡¼¥É¤Ï»þ¡¹¤½¤¦¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ ¤½¤¦¤Ê¤Ã¤¿¾ì¹ç¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ï¸å¤Ë¤Ê¤ë¤Þ¤Ç¸Æ¤Ó½Ð¤µ¤ì¤Þ¤»¤ó¡£ ¤ª¤½¤é¤¯¤â¤Ã¤È¸å¤Ë¤Ê¤ë¤Ç¤·¤ç¤¦¡£ (TBR) =begin original Fortunately there are ways around this which we'll discuss below. Unfortunately they make signals unsafe again. =end original ¹¬¤¤¤Ê¤³¤È¤Ë¡¢¤³¤ì¤ò²óÈò¤¹¤ëÊýË¡¤¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤Ë¤Ä¤¤¤Æ¤Ï¸å¤ÇÀâÌÀ¤·¤Þ¤¹¡£ »ÄÇ°¤Ê¤¬¤é¡¢¤½¤ì¤é¤Ï¿®¹æ¤òºÆ¤Ó´í¸±¤Ê¤â¤Î¤Ë¤·¤Þ¤¹¡£ (TBR) =begin original The two most common uses of signals in relation to the DBI are for canceling operations when the user types Ctrl-C (interrupt), and for implementing a timeout using C and C<$SIG{ALRM}>. =end original DBI ¤Ë´ØÏ¢¤·¤ÆºÇ¤â°ìÈÌŪ¤Ë»È¤ï¤ì¤ë¥·¥°¥Ê¥ë¤ÎÆó¤Ä¤Ï¡¢Ctrl-C(ÃæÃÇ)¤ò ²¡¤·¤¿¤È¤­¤Î¥­¥ã¥ó¥»¥ëÁàºî¤È¡¢C ¤È C<$SIG{ALRM}> ¤ò»È¤Ã¤Æ¼Â¸½¤µ¤ì¤ë ¥¿¥¤¥à¥¢¥¦¥È¤Ç¤¹¡£ =over 4 =item Cancel (¥­¥ã¥ó¥»¥ë) =begin original The DBI provides a C method for statement handles. The C method should abort the current operation and is designed to be called from a signal handler. For example: =end original DBI ¤Ï C ¥á¥½¥Ã¥É¤òʸ¥Ï¥ó¥É¥ë¤ËÍÑ°Õ¤·¤Æ¤¤¤Þ¤¹¡£ C ¥á¥½¥Ã¥É¤Ï¤½¤Î»þÅÀ¤ÎÁàºî¤òÃæÃǤµ¤»¤Ê¤±¤ì¤Ð¤¤¤±¤Þ¤»¤ó; ¤½¤·¤Æ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤«¤é¸Æ¤Ð¤ì¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ Î㤨¤Ð: $SIG{INT} = sub { $sth->cancel }; =begin original However, few drivers implement this (the DBI provides a default method that just returns C) and, even if implemented, there is still a possibility that the statement handle, and even the parent database handle, will not be usable afterwards. =end original ¤·¤«¤·¡¢¤³¤ì¤ò¼ÂÁõ¤·¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤Ï¤Û¤È¤ó¤É¤Ê¤¯(DBI ¤Ï C ¤ò ÊÖ¤¹¤À¤±¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥á¥½¥Ã¥É¤òÄ󶡤·¤Æ¤¤¤Þ¤¹)¡¢¤¿¤È¤¨ ¼ÂÁõ¤µ¤ì¤Æ¤¤¤¿¤È¤·¤Æ¤â¡¢Ê¸¥Ï¥ó¥É¥ë¡¢¤µ¤é¤Ë¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ï ¿Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ï¥ó¥É¥ë¤¬¡¢¤½¤ì°Ê¹ß¡¢»È¤¨¤Ê¤¯¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ =begin original If C returns true, then it has successfully invoked the database engine's own cancel function. If it returns false, then C failed. If it returns C, then the database driver does not have cancel implemented - very few do. =end original C ¤¬¿¿¤òÊÖ¤»¤Ð¡¢¤½¤ì¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤½¤Î¤â¤Î¤Î ¥­¥ã¥ó¥»¥ëµ¡Ç½¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤ËÀ®¸ù¤·¤Æ¤¤¤Þ¤¹¡£ µ¶¤òÊÖ¤»¤Ð¡¢C ¤Ï¼ºÇÔ¤·¤Æ¤¤¤Þ¤¹¡£ C ¤òÊÖ¤»¤Ð¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¥¨¥ó¥¸¥ó¤Ï¥­¥ã¥ó¥»¥ë¤ò¼ÂÁõ¤·¤Æ¤¤¤Þ¤»¤ó - ¤á¤Ã¤¿¤Ë¤¢¤ê¤Þ¤»¤ó¤¬¡£ =item Timeout (¥¿¥¤¥à¥¢¥¦¥È) =begin original The traditional way to implement a timeout is to set C<$SIG{ALRM}> to refer to some code that will be executed when an ALRM signal arrives and then to call alarm($seconds) to schedule an ALRM signal to be delivered $seconds in the future. For example: =end original ¥¿¥¤¥à¥¢¥¦¥È¤ò¼ÂÁõ¤¹¤ë½¾Íè¤ÎÊýË¡¤Ï¡¢C<$SIG{ALRM}>¤òÀßÄꤷ¤Æ¡¢ALRM¿®¹æ¤¬ÅþÃ夷¤¿¤È¤­¤Ë¼Â¹Ô¤µ¤ì¤ë¥³¡¼¥É¤ò»²¾È¤·¡¢¼¡¤Ë¥¢¥é¡¼¥à($seconds)¤ò¸Æ¤Ó½Ð¤·¤Æ¡¢ALRM¿®¹æ¤¬¾­Íè$ÉôÖÇÛ¿®¤µ¤ì¤ë¤è¤¦¤Ë¥¹¥±¥¸¥å¡¼¥ë¤¹¤ë¤³¤È¤Ç¤¹¡£ ¼¡¤ËÎã¤ò¼¨¤·¤Þ¤¹¡£ (TBR) eval { local $SIG{ALRM} = sub { die "TIMEOUT\n" }; # N.B. \n required eval { alarm($seconds); ... code to execute with timeout here (which may die) ... }; # outer eval catches alarm that might fire JUST before this alarm(0) alarm(0); # cancel alarm (if code ran fast) die "$@" if $@; }; if ( $@ eq "TIMEOUT\n" ) { ... } elsif ($@) { ... } # some other error =begin original The first (outer) eval is used to avoid the unlikely but possible chance that the "code to execute" dies and the alarm fires before it is cancelled. Without the outer eval, if this happened your program will die if you have no ALRM handler or a non-local alarm handler will be called. =end original ºÇ½é¤Î(³°Éô)ɾ²Á¤Ï¡¢¡Ö¼Â¹Ô¤¹¤ë¥³¡¼¥É¡×¤¬¾ÃÌǤ·¡¢¤½¤ì¤¬¥­¥ã¥ó¥»¥ë¤µ¤ì¤ëÁ°¤Ë¥¢¥é¡¼¥à¤¬È¯À¸¤¹¤ë²ÄǽÀ­¤ò²óÈò¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ ³°Éôɾ²Á¤¬¤Ê¤¤¾ì¹ç¡¢¤³¤ì¤¬È¯À¸¤·¤¿¾ì¹ç¡¢ALRM¥Ï¥ó¥É¥é¤¬¤Ê¤¤¾ì¹ç¤Ë¥×¥í¥°¥é¥à¤¬¾ÃÌǤ¹¤ë¤«¡¢Èó¥í¡¼¥«¥ë¥¢¥é¡¼¥à¥Ï¥ó¥É¥é¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Unfortunately, as described above, this won't always work as expected, depending on your perl version and the underlying database code. =end original »ÄÇ°¤Ê¤¬¤é¡¢¾åµ­¤ÇÀâÌÀ¤·¤¿¤è¤¦¤Ë¡¢perl¤Î¥Ð¡¼¥¸¥ç¥ó¤È´ðÁäȤʤë¥Ç¡¼¥¿¥Ù¡¼¥¹¥³¡¼¥É¤Ë¤è¤Ã¤Æ¤Ï¡¢¤³¤ì¤¬¾ï¤Ë´üÂÔÄ̤ê¤ËÆ°ºî¤¹¤ë¤È¤Ï¸Â¤ê¤Þ¤»¤ó¡£ (TBR) =begin original With Oracle for instance (DBD::Oracle), if the system which hosts the database is down the DBI->connect() call will hang for several minutes before returning an error. =end original Î㤨¤ÐOracle(DBD::Oracle)¤Ç¤Ï¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò¥Û¥¹¥È¤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à¤¬¥À¥¦¥ó¤·¤¿¾ì¹ç¡¢DBI->connect()¥³¡¼¥ë¤Ï¥¨¥é¡¼¤òÊÖ¤¹Á°¤Ë¿ôʬ´Ö¥Ï¥ó¥°¤·¤Þ¤¹¡£ (TBR) =back =begin original The solution on these systems is to use the C routine to gain low level access to how the signal handler is installed. =end original ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¤Ç¤Î²ò·èºö¤Ï¡¢C¤Î¥ë¡¼¥Á¥ó¤ò»ÈÍѤ·¤Æ¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Î¥¤¥ó¥¹¥È¡¼¥ëÊýË¡¤ËÄã¥ì¥Ù¥ë¤Ç¥¢¥¯¥»¥¹¤¹¤ë¤³¤È¤Ç¤¹¡£ (TBR) =begin original The code would look something like this (for the DBD-Oracle connect()): =end original ¥³¡¼¥É¤Ï°Ê²¼¤Î¤è¤¦¤Ê´¶¤¸¤Ë¤Ê¤ê¤Þ¤¹ (DBD-Oracle connect() ¤Î¾ì¹ç): use POSIX qw(:signal_h); my $mask = POSIX::SigSet->new( SIGALRM ); # signals to mask in the handler my $action = POSIX::SigAction->new( sub { die "connect timeout\n" }, # the handler code ref $mask, # not using (perl 5.8.2 and later) 'safe' switch or sa_flags ); my $oldaction = POSIX::SigAction->new(); sigaction( SIGALRM, $action, $oldaction ); my $dbh; eval { eval { alarm(5); # seconds before time out $dbh = DBI->connect("dbi:Oracle:$dsn" ... ); }; alarm(0); # cancel alarm (if connect worked fast) die "$@\n" if $@; # connect died }; sigaction( SIGALRM, $oldaction ); # restore original signal handler if ( $@ ) { if ($@ eq "connect timeout\n") {...} else { # connect died } } =begin original See previous example for the reasoning around the double eval. =end original 2 ½Å eval ¤Î°ÕÌ£¤Ë¤Ä¤¤¤Æ¤ÏÁ°½Ò¤ÎÎã¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Similar techniques can be used for canceling statement execution. =end original ƱÍͤΥƥ¯¥Ë¥Ã¥¯¤Ïʸ¤Î¼Â¹Ô¤Î¥­¥ã¥ó¥»¥ë¤Ë¤â»È¤¨¤Þ¤¹¡£ =begin original Unfortunately, this solution is somewhat messy, and it does I work with perl versions less than perl 5.8 where C appears to be broken. =end original »ÄÇ°¤Ê¤¬¤é¡¢¤³¤Î²ò·èºö¤Ï¿¾¯Ìñ²ð¤Ç¤¢¤ê¡¢C¤¬²õ¤ì¤Æ¤¤¤ë¤è¤¦¤Ë¸«¤¨¤ëperl 5.8¤è¤ê¤âÁ°¤Îperl¥Ð¡¼¥¸¥ç¥ó¤Ç¤ÏÆ°ºî¤·¤Þ¤»¤ó¡£ (TBR) =begin original For a cleaner implementation that works across perl versions, see Lincoln Baxter's Sys::SigAction module at L. The documentation for Sys::SigAction includes an longer discussion of this problem, and a DBD::Oracle test script. =end original Perl¥Ð¡¼¥¸¥ç¥ó´Ö¤ÇÆ°ºî¤¹¤ë¤è¤ê¥¯¥ê¡¼¥ó¤Ê¼ÂÁõ¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤Ë¤¢¤ëLincoln Baxter¤ÎSys::SigAction¥â¥¸¥å¡¼¥ë¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ Sys::SigAction¤Îʸ½ñ¤Ë¤Ï¡¢¤³¤ÎÌäÂê¤Ë´Ø¤¹¤ë¤è¤êŤ¤ÀâÌÀ¤È¡¢DBD::Oracle¥Æ¥¹¥È¥¹¥¯¥ê¥×¥È¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ (TBR) =begin original Be sure to read all the signal handling sections of the L manual. =end original L ¥Þ¥Ë¥å¥¢¥ë¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥ê¥ó¥°¤Î¾Ï¤òÁ´¤ÆÆɤà¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original And finally, two more points to keep firmly in mind. Firstly, remember that what we've done here is essentially revert to old style I handling of these signals. So do as little as possible in the handler. Ideally just die(). Secondly, the handles in use at the time the signal is handled may not be safe to use afterwards. =end original ¤½¤·¤ÆºÇ¸å¤Ë¡¢¤·¤Ã¤«¤ê¤È¿´¤Ëα¤á¤Æ¤ª¤¯¤Ù¤­2¤Ä¤Î¥Ý¥¤¥ó¥È¤¬¤¢¤ê¤Þ¤¹¡£ ¤Þ¤º¡¢¤³¤³¤Ç¹Ô¤Ã¤¿¤³¤È¤Ï¡¢´ðËÜŪ¤Ë¤³¤ì¤é¤Î¥·¥°¥Ê¥ë¤Î¸Å¤¤¥¹¥¿¥¤¥ë¤ÎI½èÍý¤ËÌ᤹¤³¤È¤Ç¤¢¤ë¤³¤È¤ò³Ð¤¨¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£ ¤½¤Î¤¿¤á¡¢¥Ï¥ó¥É¥é¤Ç¤Ï¤Ç¤­¤ë¤À¤±¾¯¤Ê¤¯¤·¤Æ¤¯¤À¤µ¤¤¡£ ÍýÁÛŪ¤Ë¤Ï¡¢die()¤À¤±¤Ç¤¹¡£ ¼¡¤Ë¡¢¥·¥°¥Ê¥ë¤¬½èÍý¤µ¤ì¤ë¤È¤­¤Ë»ÈÍѤµ¤ì¤Æ¤¤¤ë¥Ï¥ó¥É¥ë¤Ï¡¢¤½¤Î¸å»ÈÍѤ¹¤ë¤Ë¤Ï°ÂÁ´¤Ç¤Ï¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head2 Subclassing the DBI (DBI ¤Î¥µ¥Ö¥¯¥é¥¹²½) =begin original DBI can be subclassed and extended just like any other object oriented module. Before we talk about how to do that, it's important to be clear about the various DBI classes and how they work together. =end original DBI¤Ï¡¢Â¾¤Î¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥â¥¸¥å¡¼¥ë¤ÈƱÍͤ˥µ¥Ö¥¯¥é¥¹²½¤ª¤è¤Ó³ÈÄ¥¤Ç¤­¤Þ¤¹¡£ ¤½¤ÎÊýË¡¤Ë¤Ä¤¤¤ÆÀâÌÀ¤¹¤ëÁ°¤Ë¡¢¤µ¤Þ¤¶¤Þ¤ÊDBI¥¯¥é¥¹¤È¤½¤ì¤é¤¬¤É¤Î¤è¤¦¤ËÏ¢·È¤¹¤ë¤«¤òÌÀ³Î¤Ë¤¹¤ë¤³¤È¤¬½ÅÍפǤ¹¡£ (TBR) =begin original By default C<$dbh = DBI-Econnect(...)> returns a $dbh blessed into the C class. And the C<$dbh-Eprepare> method returns an $sth blessed into the C class (actually it simply changes the last four characters of the calling handle class to be C<::st>). =end original ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢C<$dbh=DBI-Econnect(.)>¤Ï¡¢C¥¯¥é¥¹¤Ë$dbh¤òÊÖ¤·¤Þ¤¹¡£ ¤Þ¤¿¡¢C<$dbh-Eprepare>¥á¥½¥Ã¥É¤Ï¡¢C¥¯¥é¥¹¤Ë$s¤òÊÖ¤·¤Þ¤¹(¼ÂºÝ¤Ë¤Ï¡¢¸Æ¤Ó½Ð¤·¥Ï¥ó¥É¥ë¥¯¥é¥¹¤ÎºÇ¸å¤Î4ʸ»ú¤òC<::st>¤ËÊѹ¹¤¹¤ë¤À¤±¤Ç¤¹)¡£ (TBR) =begin original The leading 'C' is known as the 'root class' and the extra 'C<::db>' or 'C<::st>' are the 'handle type suffixes'. If you want to subclass the DBI you'll need to put your overriding methods into the appropriate classes. For example, if you want to use a root class of C and override the do(), prepare() and execute() methods, then your do() and prepare() methods should be in the C class and the execute() method should be in the C class. =end original ÀèƬ¤Î¡ÖC¡×¤Ï¡Ö¥ë¡¼¥È¥¯¥é¥¹¡×¤È¸Æ¤Ð¤ì¡¢ÄɲäΡÖC<::db>¡×¤Þ¤¿¤Ï¡ÖC<::st>¡×¤Ï¡Ö¥Ï¥ó¥É¥ë¥¿¥¤¥×¤ÎÀÜÈø¼­¡×¤Ç¤¹¡£ DBI¤ò¥µ¥Ö¥¯¥é¥¹²½¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥ª¡¼¥Ð¡¼¥é¥¤¥É¥á¥½¥Ã¥É¤òŬÀڤʥ¯¥é¥¹¤ËÇÛÃÖ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢C¤Î¥ë¡¼¥È¥¯¥é¥¹¤ò»ÈÍѤ·¡¢do()¡¢prepare()¤ª¤è¤Óexecute()¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë¾ì¹ç¤Ï¡¢do()¤ª¤è¤Óprepare()¥á¥½¥Ã¥É¤òC¥¯¥é¥¹¤Ë¡¢execute()¥á¥½¥Ã¥É¤òC¥¯¥é¥¹¤ËÇÛÃÖ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original To setup the inheritance hierarchy the @ISA variable in C should include C and the @ISA variable in C should include C. The C root class itself isn't currently used for anything visible and so, apart from setting @ISA to include C, it can be left empty. =end original ·Ñ¾µ³¬ÁؤòÀßÄꤹ¤ë¤Ë¤Ï¡¢C¤Î@ISAÊÑ¿ô¤ËC¤ò´Þ¤á¡¢C¤Î@ISAÊÑ¿ô¤ËC¤ò´Þ¤á¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ C¥ë¡¼¥È¥¯¥é¥¹¼«ÂΤϸ½ºß¡¢É½¼¨¤µ¤ì¤ë¤â¤Î¤Ë¤Ï»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤¤¿¤á¡¢C¤ò´Þ¤á¤ë¤è¤¦¤Ë@ISA¤òÀßÄꤹ¤ë°Ê³°¤Ï¡¢¶õ¤Î¤Þ¤Þ¤Ë¤·¤Æ¤ª¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =begin original So, having put your overriding methods into the right classes, and setup the inheritance hierarchy, how do you get the DBI to use them? You have two choices, either a static method call using the name of your subclass: =end original ¥ª¡¼¥Ð¡¼¥é¥¤¥É¥á¥½¥Ã¥É¤òŬÀڤʥ¯¥é¥¹¤ËÇÛÃÖ¤·¡¢·Ñ¾µ³¬ÁؤòÀßÄꤷ¤¿¸å¡¢DBI¤Ë¤½¤ì¤é¤ò»ÈÍѤµ¤»¤ë¤Ë¤Ï¤É¤¦¤¹¤ì¤Ð¤è¤¤¤Î¤Ç¤·¤ç¤¦¤«¡£ 2¤Ä¤ÎÁªÂò»è¤¬¤¢¤ê¤Þ¤¹¡£ ¥µ¥Ö¥¯¥é¥¹¤Î̾Á°¤ò»ÈÍѤ·¤¿ÀÅŪ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤Ç¤¹¡£ (TBR) $dbh = MySubDBI->connect(...); =begin original or specifying a C attribute: =end original ¤Þ¤¿¤Ï C °À­¤ò»ØÄꤷ¤Æ: $dbh = DBI->connect(..., { RootClass => 'MySubDBI' }); =begin original If both forms are used then the attribute takes precedence. =end original ξÊý¤Î·Á¼°¤¬»È¤ï¤ì¤ë¤È¡¢Â°À­¤¬Í¥À褵¤ì¤Þ¤¹¡£ =begin original The only differences between the two are that using an explicit RootClass attribute will a) make the DBI automatically attempt to load a module by that name if the class doesn't exist, and b) won't call your MySubDBI::connect() method, if you have one. =end original 2¤Ä¤Î´Ö¤ÎÍ£°ì¤Î°ã¤¤¤Ï¡¢ÌÀ¼¨Åª¤ÊRootClass°À­¤ò»ÈÍѤ¹¤ë¤È¡¢a)¥¯¥é¥¹¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤ËDBI¤¬¼«Æ°Åª¤Ë¤½¤Î̾Á°¤Ç¥â¥¸¥å¡¼¥ë¤ò¥í¡¼¥É¤·¤è¤¦¤È¤¹¤ë¤³¤È¡¢¤ª¤è¤Ób)MySubDBI::connect()¥á¥½¥Ã¥É¤¬¤¢¤ë¾ì¹ç¤Ë¤½¤ì¤ò¸Æ¤Ó½Ð¤µ¤Ê¤¤¤³¤È¤Ç¤¹¡£ (TBR) =begin original When subclassing is being used then, after a successful new connect, the DBI->connect method automatically calls: =end original ¥µ¥Ö¥¯¥é¥¹²½¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¿·¤·¤¤Àܳ¤¬À®¸ù¤¹¤ë¤È¡¢DBI->connect¥á¥½¥Ã¥É¤Ï¼«Æ°Åª¤Ë¼¡¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£ (TBR) $dbh->connected($dsn, $user, $pass, \%attr); =begin original The default method does nothing. The call is made just to simplify any post-connection setup that your subclass may want to perform. The parameters are the same as passed to DBI->connect. If your subclass supplies a connected method, it should be part of the MySubDBI::db package. =end original ¥Ç¥Õ¥©¥ë¥È¤Î¥á¥½¥Ã¥É¤Ï²¿¤â¤·¤Þ¤»¤ó¡£ ¤³¤Î¸Æ¤Ó½Ð¤·¤Ï¡¢¥µ¥Ö¥¯¥é¥¹¤¬¼Â¹Ô¤¹¤ëÀܳ¸å¤Î¥»¥Ã¥È¥¢¥Ã¥×¤ò´Êñ¤Ë¤¹¤ë¤¿¤á¤Ë¹Ô¤ï¤ì¤Þ¤¹¡£ ¥Ñ¥é¥á¡¼¥¿¤Ï¡¢DBI->connect¤ËÅϤµ¤ì¤ë¤â¤Î¤ÈƱ¤¸¤Ç¤¹¡£ ¥µ¥Ö¥¯¥é¥¹¤¬Àܳ¤µ¤ì¤¿¥á¥½¥Ã¥É¤òÄ󶡤¹¤ë¾ì¹ç¡¢¤½¤ì¤ÏMySubDBI::db¥Ñ¥Ã¥±¡¼¥¸¤Î°ìÉô¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =begin original One more thing to note: you must let the DBI do the handle creation. If you want to override the connect() method in your *::dr class then it must still call SUPER::connect to get a $dbh to work with. Similarly, an overridden prepare() method in *::db must still call SUPER::prepare to get a $sth. If you try to create your own handles using bless() then you'll find the DBI will reject them with an "is not a DBI handle (has no magic)" error. =end original ¤â¤¦1¤ÄÃí°Õ¤¹¤Ù¤­¤³¤È¤Ï¡¢¥Ï¥ó¥É¥ë¤ÎºîÀ®¤òDBI¤Ë¹Ô¤ï¤»¤ëɬÍפ¬¤¢¤ë¤³¤È¤Ç¤¹¡£ *::dr¥¯¥é¥¹¤Îconnect()¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë¾ì¹ç¤Ï¡¢$dbh¤òÁàºî¤¹¤ë¤¿¤á¤ËSUPER::connect¤ò¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ ƱÍͤˡ¢*::db¤Î¥ª¡¼¥Ð¡¼¥é¥¤¥É¤µ¤ì¤¿prepare()¥á¥½¥Ã¥É¤Ï¡¢$sth¤ò¼èÆÀ¤¹¤ë¤¿¤á¤ËSUPER::prepare¤ò¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ bless()¤ò»ÈÍѤ·¤ÆÆȼ«¤Î¥Ï¥ó¥É¥ë¤òºîÀ®¤·¤è¤¦¤È¤¹¤ë¤È¡¢DBI¤¬¡Öis not a DBI handle(has no magic)¡×¥¨¥é¡¼¤ÇµñÈݤ¹¤ë¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£ (TBR) =begin original Here's a brief example of a DBI subclass. A more thorough example can be found in F in the DBI distribution. =end original DBI¥µ¥Ö¥¯¥é¥¹¤Î´Êñ¤ÊÎã¤ò¼¡¤Ë¼¨¤·¤Þ¤¹¡£ ¤è¤ê¾ÜºÙ¤ÊÎã¤Ï¡¢DBI¥Ç¥£¥¹¥È¥ê¥Ó¥å¡¼¥·¥ç¥ó¤ÎF¤Ë¤¢¤ê¤Þ¤¹¡£ (TBR) package MySubDBI; use strict; use DBI; use vars qw(@ISA); @ISA = qw(DBI); package MySubDBI::db; use vars qw(@ISA); @ISA = qw(DBI::db); sub prepare { my ($dbh, @args) = @_; my $sth = $dbh->SUPER::prepare(@args) or return; $sth->{private_mysubdbi_info} = { foo => 'bar' }; return $sth; } package MySubDBI::st; use vars qw(@ISA); @ISA = qw(DBI::st); sub fetch { my ($sth, @args) = @_; my $row = $sth->SUPER::fetch(@args) or return; do_something_magical_with_row_data($row) or return $sth->set_err(1234, "The magic failed", undef, "fetch"); return $row; } =begin original When calling a SUPER::method that returns a handle, be careful to check the return value before trying to do other things with it in your overridden method. This is especially important if you want to set a hash attribute on the handle, as Perl's autovivification will bite you by (in)conveniently creating an unblessed hashref, which your method will then return with usually baffling results later on like the error "dbih_getcom handle HASH(0xa4451a8) is not a DBI handle (has no magic". It's best to check right after the call and return undef immediately on error, just like DBI would and just like the example above. =end original ¥Ï¥ó¥É¥ë¤òÊÖ¤¹SU PER::¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¾ì¹ç¡¢¥ª¡¼¥Ð¡¼¥é¥¤¥É¤µ¤ì¤¿¥á¥½¥Ã¥É¤Ç¾¤Î½èÍý¤ò»î¤ß¤ëÁ°¤Ë¡¢Ìá¤êÃͤò¥Á¥§¥Ã¥¯¤¹¤ë¤è¤¦¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ ¥Ï¥ó¥É¥ë¤Ë¥Ï¥Ã¥·¥å°À­¤òÀßÄꤷ¤¿¤¤¾ì¹ç¡¢¤³¤ì¤ÏÆä˽ÅÍפǤ¹¡£ ¤Ê¤¼¤Ê¤é¡¢Perl¤Îautovivification¤Ï¡¢(in)ÅÔ¹ç¤Î¤è¤¤¤³¤È¤Ë¡¢·Ã¤Þ¤ì¤Ê¤¤hashref¤òºîÀ®¤¹¤ë¤³¤È¤Ç¡¢¤¢¤Ê¤¿¤ò¿©¤¤Êª¤Ë¤·¡¢¤¢¤Ê¤¿¤Î¥á¥½¥Ã¥É¤Ï¡¢¸å¤Ç¥¨¥é¡¼¡Ödbih_getcom handle HASH(0xa4451a8)is not a DBI handle(has no magic)¡×¤Î¤è¤¦¤ÊÄ̾ïÉԲIJò¤Ê·ë²Ì¤òÊÖ¤¹¤«¤é¤Ç¤¹¡£ ¸Æ¤Ó½Ð¤·¤Îľ¸å¤Ë¥Á¥§¥Ã¥¯¤·¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤é¤¹¤°¤Ëundef¤òÊÖ¤¹¤Î¤¬ºÇÁ±¤Ç¤¹¡£ ¤³¤ì¤Ï¡¢DBI¤Î¾ì¹ç¤ÈƱ¤¸¤Ç¡¢¾åµ­¤ÎÎã¤ÈƱ¤¸¤Ç¤¹¡£ (TBR) =begin original If your method needs to record an error it should call the set_err() method with the error code and error string, as shown in the example above. The error code and error string will be recorded in the handle and available via C<$h-Eerr> and C<$DBI::errstr> etc. The set_err() method always returns an undef or empty list as appropriate. Since your method should nearly always return an undef or empty list as soon as an error is detected it's handy to simply return what set_err() returns, as shown in the example above. =end original ¥á¥½¥Ã¥É¤¬¥¨¥é¡¼¤òµ­Ï¿¤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ï¡¢¾åµ­¤ÎÎã¤Ë¼¨¤¹¤è¤¦¤Ë¡¢¥¨¥é¡¼¥³¡¼¥É¤È¥¨¥é¡¼Ê¸»úÎó¤ò»ØÄꤷ¤Æset_err()¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ ¥¨¥é¡¼¥³¡¼¥É¤È¥¨¥é¡¼Ê¸»úÎó¤Ï¥Ï¥ó¥É¥ë¤Ëµ­Ï¿¤µ¤ì¡¢C<$h-Eerr>¤ª¤è¤ÓC<$DBI::errstr>¤Ê¤É¤ò²ð¤·¤Æ»ÈÍѤǤ­¤Þ¤¹¡£ set_err()¥á¥½¥Ã¥É¤Ï¡¢¾ï¤Ëundef¤Þ¤¿¤Ï¶õ¤Î¥ê¥¹¥È¤òŬÀÚ¤ËÊÖ¤·¤Þ¤¹¡£ ¥á¥½¥Ã¥É¤Ï¡¢¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤ë¤È¤¹¤°¤Ëundef¤Þ¤¿¤Ï¶õ¤Î¥ê¥¹¥È¤òÊÖ¤¹¤Î¤Ç¡¢¾åµ­¤ÎÎã¤Ë¼¨¤¹¤è¤¦¤Ë¡¢set_err()¤¬ÊÖ¤¹¤â¤Î¤òñ½ã¤ËÊÖ¤¹¤ÈÊØÍø¤Ç¤¹¡£ (TBR) =begin original If the handle has C, C, or C etc. set then the set_err() method will honour them. This means that if C is set then set_err() won't return in the normal way but will 'throw an exception' that can be caught with an C block. =end original ¥Ï¥ó¥É¥ë¤ËC¡¢C¡¢¤Þ¤¿¤ÏC¤Ê¤É¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢set_err()¥á¥½¥Ã¥É¤Ï¤½¤ì¤é¤òº½Å¤·¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢C¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢set_err()¤ÏÄ̾ï¤ÎÊýË¡¤Ç¤ÏÊÖ¤µ¤º¡¢C¥Ö¥í¥Ã¥¯¤ÇÊ᪤Ǥ­¤ë¡ÖÎã³°¤ò¥¹¥í¡¼¤¹¤ë¡×¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ (TBR) =begin original You can stash private data into DBI handles via C<$h-E{private_..._*}>. See the entry under L for info and important caveats. =end original C<$h-E{private_._*}>¤ò»ÈÍѤ·¤Æ¡¢¥×¥é¥¤¥Ù¡¼¥È¥Ç¡¼¥¿¤òDBI¥Ï¥ó¥É¥ë¤Ë³ÊǼ¤Ç¤­¤Þ¤¹¡£ ¾ðÊ󤪤è¤Ó½ÅÍפʷٹð¤Ë¤Ä¤¤¤Æ¤Ï¡¢L¤Î¥¨¥ó¥È¥ê¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head1 TRACING (¥È¥ì¡¼¥¹) =begin original The DBI has a powerful tracing mechanism built in. It enables you to see what's going on 'behind the scenes', both within the DBI and the drivers you're using. =end original DBI¤Ë¤Ï¡¢¶¯ÎϤʥȥ졼¥¹¥á¥«¥Ë¥º¥à¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢DBIÆ⤪¤è¤Ó»ÈÍѤ·¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤ÎξÊý¤Ç¡¢¡ÖÉñÂæ΢¡×¤Ç²¿¤¬µ¯¤³¤Ã¤Æ¤¤¤ë¤«¤ò³Îǧ¤Ç¤­¤Þ¤¹¡£ (TBR) =head2 Trace Settings (¥È¥ì¡¼¥¹ÀßÄê) =begin original Which details are written to the trace output is controlled by a combination of a I, an integer from 0 to 15, and a set of I that are either on or off. Together these are known as the I and are stored together in a single integer. For normal use you only need to set the trace level, and generally only to a value between 1 and 4. =end original ¥È¥ì¡¼¥¹½ÐÎϤ˽ñ¤­¹þ¤Þ¤ì¤ë¾ÜºÙ¤Ï¡¢I<¥È¥ì¡¼¥¹¥ì¥Ù¥ë>¡¢0¡Á15¤ÎÀ°¿ô¡¢¤ª¤è¤Ó¥ª¥ó¤Þ¤¿¤Ï¥ª¥Õ¤ÎI<¥È¥ì¡¼¥¹¥Õ¥é¥°>¤Î¥»¥Ã¥È¤ÎÁȤ߹ç¤ï¤»¤Ë¤è¤Ã¤ÆÀ©¸æ¤µ¤ì¤Þ¤¹¡£ ¤³¤ì¤é¤ÏI<¥È¥ì¡¼¥¹ÀßÄê>¤È¸Æ¤Ð¤ì¡¢1¤Ä¤ÎÀ°¿ô¤Ë¤Þ¤È¤á¤Æ³ÊǼ¤µ¤ì¤Þ¤¹¡£ Ä̾ï¤Î»ÈÍѤǤϡ¢¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤òÀßÄꤹ¤ëɬÍפ¬¤¢¤ë¤À¤±¤Ç¡¢Ä̾ï¤Ï1¡Á4¤ÎÃͤΤߤǤ¹¡£ (TBR) =begin original Each handle has it's own trace settings, and so does the DBI. When you call a method the DBI merges the handles settings into its own for the duration of the call: the trace flags of the handle are OR'd into the trace flags of the DBI, and if the handle has a higher trace level then the DBI trace level is raised to match it. The previous DBI trace settings are restored when the called method returns. =end original ³Æ¥Ï¥ó¥É¥ë¤Ë¤ÏÆȼ«¤Î¥È¥ì¡¼¥¹ÀßÄ꤬¤¢¤ê¡¢DBI¤âƱÍͤǤ¹¡£ ¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤¹¤ë¤È¡¢DBI¤Ï¥³¡¼¥ëÃæ¤Ë¥Ï¥ó¥É¥ëÀßÄê¤òÆȼ«¤ÎÀßÄê¤Ë¥Þ¡¼¥¸¤·¤Þ¤¹¡£ ¥Ï¥ó¥É¥ë¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤ÏDBI¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤ËOR¤µ¤ì¡¢¥Ï¥ó¥É¥ë¤Î¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤ÎÊý¤¬¹â¤¤¾ì¹ç¤Ï¡¢¤½¤ì¤Ë¹ç¤ï¤»¤ÆDBI¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤¬¾å¤²¤é¤ì¤Þ¤¹¡£ ¥³¡¼¥ë¤µ¤ì¤¿¥á¥½¥Ã¥É¤¬Ìá¤ë¤È¡¢°ÊÁ°¤ÎDBI¥È¥ì¡¼¥¹ÀßÄ꤬Éü¸µ¤µ¤ì¤Þ¤¹¡£ (TBR) =head2 Trace Levels (¥È¥ì¡¼¥¹¥ì¥Ù¥ë) =begin original Trace I are as follows: =end original ¥È¥ì¡¼¥¹ I<¥ì¥Ù¥ë> ¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹: =begin original 0 - Trace disabled. 1 - Trace top-level DBI method calls returning with results or errors. 2 - As above, adding tracing of top-level method entry with parameters. 3 - As above, adding some high-level information from the driver and some internal information from the DBI. 4 - As above, adding more detailed information from the driver. This is the first level to trace all the rows being fetched. 5 to 15 - As above but with more and more internal information. =end original 0 - ¥È¥ì¡¼¥¹Ìµ¸ú 1 - ¥È¥Ã¥×¥ì¥Ù¥ë DBI ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤ÎÌá¤ê¤ò·ë²Ì¤Þ¤¿¤Ï¥¨¥é¡¼¤È°ì½ï¤Ë¥È¥ì¡¼¥¹ 2 - ²Ã¤¨¤Æ¥È¥Ã¥×¥ì¥Ù¥ë¥á¥½¥Ã¥É¤Î¥¨¥ó¥È¥ê¤ò¥Ñ¥é¥á¡¼¥¿¤È°ì½ï¤Ë¥È¥ì¡¼¥¹ 3 - ²Ã¤¨¤Æ¥É¥é¥¤¥Ð¤«¤é¤Î¤¤¤¯¤Ä¤«¤Î¥Ï¥¤¥ì¥Ù¥ë¤Ê¾ðÊó¤È DBI¤«¤é¤Î¤¤¤¯¤Ä¤«¤ÎÆâÉô¾ðÊó¤òÄɲᣠ4 - ²Ã¤¨¤Æ¥É¥é¥¤¥Ð¤«¤é¤Î¤µ¤é¤Ë¾ÜºÙ¤Ê¾ðÊó¤òÄɲᣠ¤³¤ì¤Ï¥Õ¥§¥Ã¥Á¤µ¤ì¤ëÁ´¤Æ¤Î¹Ô¤ò¥È¥ì¡¼¥¹¤¹¤ëºÇ½é¤Î¥ì¥Ù¥ë¤Ç¤¹¡£ 5 ¤«¤é 15 - ¾åµ­¤ÈƱÍÍ¡£¤·¤«¤·Â礭¤¯¤Ê¤ë¤Ë½¾¤Ã¤Æ¤µ¤é¤ËÆâÉô¤Î¾ðÊó¡£ =begin original Trace level 1 is best for a simple overview of what's happening. Trace levels 2 thru 4 a good choice for general purpose tracing. Levels 5 and above are best reserved for investigating a specific problem, when you need to see "inside" the driver and DBI. =end original ¥È¥ì¡¼¥¹¥ì¥Ù¥ë 1 ¤¬²¿¤¬µ¯¤³¤Ã¤¿¤Î¤«¤Îñ½ã¤Ê³µÍפΤ¿¤á¤ËºÇ¤â¸þ¤¤¤Æ¤¤¤Þ¤¹¡£ ¥È¥ì¡¼¥¹¥ì¥Ù¥ë 2 ¤«¤é 4 ¤Ï¥È¥ì¡¼¥¹¤Î°ìÈÌŪ¤ÊÌÜŪ¤Ë¤Ï¤è¤¤ÁªÂò¤Ç¤¹¡£ ¥ì¥Ù¥ë 5 °Ê¾å¤Ï¡¢DBI¤È¥É¥é¥¤¥Ð¤Î¡ÖÆâÉô¡×¤ò¸«¤ëɬÍפ¬¤¢¤ë¤È¤­¡¢ ÆÃÄê¤ÎÌäÂê¤òÄ´¤Ù¤ë¤¿¤á¤ËͽÌ󤵤ì¤Æ¤¤¤Þ¤¹¡£ =begin original The trace output is detailed and typically very useful. Much of the trace output is formatted using the L function, so strings in the trace output may be edited and truncated by that function. =end original ¥È¥ì¡¼¥¹½ÐÎϤϤȤƤâ¾ÜºÙ¤Ç¡¢ÉáÄ̤ȤƤâÌò¤ËΩ¤Á¤Þ¤¹¡£ ¥È¥ì¡¼¥¹½ÐÎϤο¤¯¤¬ L ´Ø¿ô¤ò»È¤Ã¤Æ·Á¼°¤òÀ°¤¨¤Æ¤¤¤Þ¤¹¡£ ¤³¤Î¤¿¤á¥È¥ì¡¼¥¹½ÐÎϤǤÎʸ»úÎó¤Ï¤³¤Î´Ø¿ô¤Ë¤è¤Ã¤ÆÊÔ½¸¤µ¤ì¡¢ ÀÚ¤ê¼Î¤Æ¤é¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£¡£ =head2 Trace Flags (¥È¥ì¡¼¥¹¥Õ¥é¥°) =begin original Trace I are used to enable tracing of specific activities within the DBI and drivers. The DBI defines some trace flags and drivers can define others. DBI trace flag names begin with a capital letter and driver specific names begin with a lowercase letter, as usual. =end original ¥È¥ì¡¼¥¹ I<¥Õ¥é¥°> ¤Ï DBI ¤È¥É¥é¥¤¥Ð¤ÎÆâÉô¤ÎÆÃÄê¤Îµ¡Ç½¤Î¥È¥ì¡¼¥¹¤ò Í­¸ú¤Ë¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ DBI ¤¬¤¤¤¯¤Ä¤«¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤òÄêµÁ¤·¡¢¥É¥é¥¤¥Ð¤â¤¤¤¯¤Ä¤«ÄêµÁ¤·¤Þ¤¹¡£ Ä̾ïÄ̤ꡢDBI ¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°Ì¾¤ÏÂçʸ»ú¤Ç»Ï¤Þ¤ê¡¢¥É¥é¥¤¥Ð¸ÇÍ­¤Î̾Á°¤Ï ¾®Ê¸»ú¤Ç»Ï¤Þ¤ê¤Þ¤¹¡£ =begin original Currently the DBI only defines two trace flags: =end original ¸½ºß¤Î¤È¤³¤í DBI ¤ÏÆó¤Ä¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤Î¤ß¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹: =begin original ALL - turn on all DBI and driver flags (not recommended) SQL - trace SQL statements executed (not yet implemented in DBI but implemented in some DBDs) =end original ALL - Á´¤Æ¤Î DBI ¤È¥É¥é¥¤¥Ð¤Î¥Õ¥é¥°¤òÍ­¸ú¤Ë¤¹¤ë (´«¤á¤Þ¤»¤ó) SQL - ¼Â¹Ô¤µ¤ì¤¿ SQL ʸ¤ò¥È¥ì¡¼¥¹¤¹¤ë (¤Þ¤À DBI ¤Ë¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¤¬°ìÉô¤Î DBD ¤Ç¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤¹) =begin original The L and L methods are used to convert trace flag names into the corresponding integer bit flags. =end original L ¥á¥½¥Ã¥É¤È L ¥á¥½¥Ã¥É¤Ï ¥È¥ì¡¼¥¹¥Õ¥é¥°Ì¾¤òÂбþ¤¹¤ëÀ°¿ô¥Ó¥Ã¥È¥Õ¥é¥°¤ËÊÑ´¹¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ =head2 Enabling Trace (¥È¥ì¡¼¥¹¤òÍ­¸ú¤Ë¤¹¤ë) =begin original The C<$h-Etrace> method sets the trace settings for a handle and Ctrace> does the same for the DBI. =end original C<$h-Etrace> ¥á¥½¥Ã¥É¤Ï¥Ï¥ó¥É¥ë¤Î¤¿¤á¤Î¥È¥ì¡¼¥¹ÀßÄê¤òÀßÄꤷ¡¢ Ctrace> ¤Ï DBI ¤Î¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£ =begin original In addition to the L method, you can enable the same trace information, and direct the output to a file, by setting the C environment variable before starting Perl. See L for more information. =end original L ¥á¥½¥Ã¥É¤Ë²Ã¤¨¤Æ¡¢Perl ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë´Ä¶­ÊÑ¿ô C ¤ò ÀßÄꤹ¤ì¤Ð¡¢Æ±¤¸¥È¥ì¡¼¥¹¾ðÊó¤òÍ­¸ú¤Ë¤·¡¢¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original Finally, you can set, or get, the trace settings for a handle using the C attribute. =end original ºÇ¸å¤Ë¡¢¥Ï¥ó¥É¥ë¤Î¥È¥ì¡¼¥¹ÀßÄê¤Ï C °À­¤ò»È¤Ã¤Æ ÀßÄꡦ¼èÆÀ¤Ç¤­¤Þ¤¹¡£ =begin original All of those methods use parse_trace_flags() and so allow you set both the trace level and multiple trace flags by using a string containing the trace level and/or flag names separated by vertical bar ("C<|>") or comma ("C<,>") characters. For example: =end original ¤³¤ì¤éÁ´¤Æ¤Î¥á¥½¥Ã¥É¤Ï parse_trace_flags() ¤ò»È¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢ ¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤È¥Õ¥é¥°Ì¾¤ò½ÄËÀ ("C<|>") ¤Þ¤¿¤Ï¥«¥ó¥Þ ("C<,>") ʸ»ú¤Ç ¶èÀڤä¿Ê¸»úÎó¤ò»È¤¦¤³¤È¤Ç¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤ÈÊ£¿ô¤Î¥È¥ì¡¼¥¹¥Õ¥é¥°¤ÎƱ»þ¤Ë ÀßÄê¤Ç¤­¤Þ¤¹¡£ Î㤨¤Ð: local $h->{TraceLevel} = "3|SQL|foo"; =head2 Trace Output (¥È¥ì¡¼¥¹½ÐÎÏ) =begin original Initially trace output is written to C. Both the C<$h-Etrace> and Ctrace> methods take an optional $trace_file parameter, which may be either the name of a file to be opened by DBI in append mode, or a reference to an existing writable (possibly layered) filehandle. If $trace_file is a filename, and can be opened in append mode, or $trace_file is a writable filehandle, then I trace output (currently including that from other handles) is redirected to that file. A warning is generated if $trace_file can't be opened or is not writable. =end original ºÇ½é¤Ë¡¢¥È¥ì¡¼¥¹½ÐÎϤÏC¤Ë½ñ¤­¹þ¤Þ¤ì¤Þ¤¹¡£ C<$h-Etrace>¤ª¤è¤ÓCtrace>¥á¥½¥Ã¥É¤Ï¡¢¥ª¥×¥·¥ç¥ó¤Î$trace_file¥Ñ¥é¥á¡¼¥¿¤ò¼è¤ê¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢Äɲå⡼¥É¤ÇDBI¤Ë¤è¤Ã¤Æ³«¤«¤ì¤ë¥Õ¥¡¥¤¥ë¤Î̾Á°¡¢¤Þ¤¿¤Ï´û¸¤Î½ñ¤­¹þ¤ß²Äǽ¤Ê(¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ï³¬Áز½¤µ¤ì¤¿)¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ø¤Î»²¾È¤Ç¤¹¡£ $trace_file¤¬¥Õ¥¡¥¤¥ë̾¤Ç¤¢¤ê¡¢Äɲå⡼¥É¤Ç³«¤¯¤³¤È¤¬¤Ç¤­¤ë¾ì¹ç¡¢¤Þ¤¿¤Ï$trace_file¤¬½ñ¤­¹þ¤ß²Äǽ¤Ê¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ç¤¢¤ë¾ì¹ç¡¢I¥È¥ì¡¼¥¹½ÐÎÏ(¸½ºß¡¢Â¾¤Î¥Ï¥ó¥É¥ë¤«¤é¤Î½ÐÎϤò´Þ¤à)¤Ï¤½¤Î¥Õ¥¡¥¤¥ë¤Ë¥ê¥À¥¤¥ì¥¯¥È¤µ¤ì¤Þ¤¹¡£ $trace_file¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Ê¤¤¾ì¹ç¡¢¤Þ¤¿¤Ï$trace_file¤¬½ñ¤­¹þ¤ß²Äǽ¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢·Ù¹ð¤¬À¸À®¤µ¤ì¤Þ¤¹¡£ (TBR) =begin original Further calls to trace() without $trace_file do not alter where the trace output is sent. If $trace_file is undefined, then trace output is sent to C and, if the prior trace was opened with $trace_file as a filename, the previous trace file is closed; if $trace_file was a filehandle, the filehandle is B closed. =end original $trace_file¤ò»ØÄꤻ¤º¤Ëtrace()¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¥È¥ì¡¼¥¹½ÐÎϤÎÁ÷¿®Àè¤ÏÊѹ¹¤µ¤ì¤Þ¤»¤ó¡£ $trace_file¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¥È¥ì¡¼¥¹½ÐÎϤÏC¤ËÁ÷¿®¤µ¤ì¤Þ¤¹¡£ Á°¤Î¥È¥ì¡¼¥¹¤¬¥Õ¥¡¥¤¥ë̾¤È¤·¤Æ$trace_file¤ò»ØÄꤷ¤Æ³«¤«¤ì¤¿¾ì¹ç¡¢Á°¤Î¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤ÏÊĤ¸¤é¤ì¤Þ¤¹¡£ $trace_file¤¬¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¾ì¹ç¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ÏÊĤ¸¤é¤ì¤Þ¤»¤ó¡£ (TBR) =begin original B: If $trace_file is specified as a filehandle, the filehandle should not be closed until all DBI operations are completed, or the application has reset the trace file via another call to C that changes the trace file. =end original B<Ãí>:$trace_file¤¬¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¤·¤Æ»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤¹¤Ù¤Æ¤ÎDBIÁàºî¤¬´°Î»¤¹¤ë¤Þ¤Ç¡¢¤Þ¤¿¤Ï¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤òÊѹ¹¤¹¤ëC¤ÎÊ̤θƤӽФ·¤Ë¤è¤Ã¤Æ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥ê¥»¥Ã¥È¤¹¤ë¤Þ¤Ç¡¢¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤òÊĤ¸¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ (TBR) =head2 Tracing to Layered Filehandles (ÁؤΤ¢¤ë¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ø¤Î¥È¥ì¡¼¥¹) =begin original B: =end original B<Ãí°Õ>: =over 4 =item * Tied filehandles are not currently supported, as tie operations are not available to the PerlIO methods used by the DBI. =item * PerlIO layer support requires Perl version 5.8 or higher. =back =begin original As of version 5.8, Perl provides the ability to layer various "disciplines" on an open filehandle via the L module. =end original ¥Ð¡¼¥¸¥ç¥ó 5.8 ¤«¤é¡¢Perl ¤Ï³«¤¤¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤ËÂФ·¤Æ L ¥â¥¸¥å¡¼¥ë¤òÄ̤·¤ÆÍÍ¡¹¤Ê¡Ö¥Ç¥£¥·¥×¥ê¥ó¡×¤òÀѤ߽Ťͤ뵡ǽ¤ò Ä󶡤·¤Æ¤¤¤Þ¤¹¡£ =begin original A simple example of using PerlIO layers is to use a scalar as the output: =end original PerlIO Áؤò»È¤Ã¤¿´Êñ¤ÊÎã¤Ï¥¹¥«¥é¤ò½ÐÎϤȤ·¤Æ»È¤¤¤Þ¤¹: my $scalar = ''; open( my $fh, "+>:scalar", \$scalar ); $dbh->trace( 2, $fh ); =begin original Now all trace output is simply appended to $scalar. =end original ¤³¤³¤ÇÁ´¤Æ¤Î¥È¥ì¡¼¥¹½ÐÎϤÏñ½ã¤Ë $scalar ¤ËÄɲ䵤ì¤Þ¤¹¡£ =begin original A more complex application of tracing to a layered filehandle is the use of a custom layer (IL I). Consider an application with the following logger module: =end original ¥ì¥¤¥ä²½¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ø¤Î¥È¥ì¡¼¥¹¤Î¤è¤êÊ£»¨¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¥«¥¹¥¿¥à¥ì¥¤¥ä¤Î»ÈÍѤǤ¹(I<»²¾È>LI<¥«¥¹¥¿¥àPerlIO¥ì¥¤¥ä¤ÎºîÀ®¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï>)¡£ ¼¡¤Î¥í¥¬¡¼¥â¥¸¥å¡¼¥ë¤ò»ý¤Ä¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¹Í¤¨¤Æ¤ß¤Þ¤¹¡£ (TBR) package MyFancyLogger; sub new { my $self = {}; my $fh; open $fh, '>', 'fancylog.log'; $self->{_fh} = $fh; $self->{_buf} = ''; return bless $self, shift; } sub log { my $self = shift; return unless exists $self->{_fh}; my $fh = $self->{_fh}; $self->{_buf} .= shift; # # DBI feeds us pieces at a time, so accumulate a complete line # before outputing # print $fh "At ", scalar localtime(), ':', $self->{_buf}, "\n" and $self->{_buf} = '' if $self->{_buf}=~tr/\n//; } sub close { my $self = shift; return unless exists $self->{_fh}; my $fh = $self->{_fh}; print $fh "At ", scalar localtime(), ':', $self->{_buf}, "\n" and $self->{_buf} = '' if $self->{_buf}; close $fh; delete $self->{_fh}; } 1; =begin original To redirect DBI traces to this logger requires creating a package for the layer: =end original DBI ¥È¥ì¡¼¥¹¤ò¤³¤Î¥í¥¬¡¼¤Ë¥ê¥À¥¤¥ì¥¯¥È¤¹¤ë¤Ë¤Ï¡¢ÁؤΤ¿¤á¤Î¥Ñ¥Ã¥±¡¼¥¸¤òºî¤ë ɬÍפ¬¤¢¤ê¤Þ¤¹: package PerlIO::via::MyFancyLogLayer; sub PUSHED { my ($class,$mode,$fh) = @_; my $logger; return bless \$logger,$class; } sub OPEN { my ($self, $path, $mode, $fh) = @_; # # $path is actually our logger object # $$self = $path; return 1; } sub WRITE { my ($self, $buf, $fh) = @_; $$self->log($buf); return length($buf); } sub CLOSE { my $self = shift; $$self->close(); return 0; } 1; =begin original The application can then cause DBI traces to be routed to the logger using =end original ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¼¡¤Î¥³¥Þ¥ó¥É¤ò»ÈÍѤ·¤Æ¡¢DBI¥È¥ì¡¼¥¹¤ò¥í¥¬¡¼¤Ë¥ë¡¼¥Æ¥£¥ó¥°¤Ç¤­¤Þ¤¹¡£ (TBR) use PerlIO::via::MyFancyLogLayer; open my $fh, '>:via(MyFancyLogLayer)', MyFancyLogger->new(); $dbh->trace('SQL', $fh); =begin original Now all trace output will be processed by MyFancyLogger's log() method. =end original ¤³¤³¤ÇÁ´¤Æ¤Î¥È¥ì¡¼¥¹½ÐÎÏ¤Ï MyFancyLogger ¤Î log() ¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ ½èÍý¤µ¤ì¤Þ¤¹¡£ =head2 Trace Content (¥È¥ì¡¼¥¹¤ÎÆâÍÆ) =begin original Many of the values embedded in trace output are formatted using the neat() utility function. This means they may be quoted, sanitized, and possibly truncated if longer than C<$DBI::neat_maxlen>. See L for more details. =end original ¥È¥ì¡¼¥¹½ÐÎϤ˴ޤޤì¤Æ¤¤¤ëÃͤο¤¯¤Ï neat() ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô¤ò»È¤Ã¤Æ ¥Õ¥©¡¼¥Þ¥Ã¥È¤µ¤ì¤Þ¤¹¡£ ¤Ä¤Þ¤ê¡¢¥¯¥©¡¼¥È¤µ¤ì¡¢¥µ¥Ë¥¿¥¤¥º¤µ¤ì¡¢C<$DBI::neat_maxlen> ¤è¤êŤ¤¾ì¹ç¤Ï ÀÚ¤êµÍ¤á¤é¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ ¤µ¤é¤Ê¤ë¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 Tracing Tips (¥È¥ì¡¼¥¹¤Î¾®µ») =begin original You can add tracing to your own application code using the L method. =end original L ¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ¼«¿È¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¥È¥ì¡¼¥¹¤ò ÄɲäǤ­¤Þ¤¹¡£ =begin original It can sometimes be handy to compare trace files from two different runs of the same script. However using a tool like C on the original log output doesn't work well because the trace file is full of object addresses that may differ on each run. =end original Ʊ¤¸¥¹¥¯¥ê¥×¥È¤Î2¤Ä¤Î°Û¤Ê¤ë¼Â¹Ô¤«¤é¤Î¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤òÈæ³Ó¤¹¤ë¤ÈÊØÍø¤Ê¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡£ ¤·¤«¤·¡¢¸µ¤Î¥í¥°½ÐÎϤËC¤Î¤è¤¦¤Ê¥Ä¡¼¥ë¤ò»ÈÍѤ¹¤ë¤È¡¢¥È¥ì¡¼¥¹¥Õ¥¡¥¤¥ë¤¬¼Â¹Ô¤´¤È¤Ë°Û¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È¥¢¥É¥ì¥¹¤Ç¤¤¤Ã¤Ñ¤¤¤Ë¤Ê¤ë¤¿¤á¡¢¤¦¤Þ¤¯µ¡Ç½¤·¤Þ¤»¤ó¡£ (TBR) =begin original The DBI includes a handy utility called dbilogstrip that can be used to 'normalize' the log content. It can be used as a filter like this: =end original DBI¤Ë¤Ï¡¢¥í¥°¤ÎÆâÍƤò¡ÖÀµµ¬²½¡×¤¹¤ë¤¿¤á¤Ë»ÈÍѤǤ­¤ëdbilogstrip¤È¸Æ¤Ð¤ì¤ëÊØÍø¤Ê¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥Õ¥£¥ë¥¿¤È¤·¤Æ»ÈÍѤǤ­¤Þ¤¹: (TBR) DBI_TRACE=2 perl yourscript.pl ...args1... 2>&1 | dbilogstrip > dbitrace1.log DBI_TRACE=2 perl yourscript.pl ...args2... 2>&1 | dbilogstrip > dbitrace2.log diff -u dbitrace1.log dbitrace2.log =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head1 DBI ENVIRONMENT VARIABLES (DBI ´Ä¶­ÊÑ¿ô) =begin original The DBI module recognizes a number of environment variables, but most of them should not be used most of the time. It is better to be explicit about what you are doing to avoid the need for environment variables, especially in a web serving system where web servers are stingy about which environment variables are available. =end original DBI¥â¥¸¥å¡¼¥ë¤Ï¿¿ô¤Î´Ä¶­ÊÑ¿ô¤òǧ¼±¤·¤Þ¤¹¤¬¡¢¤½¤Î¤Û¤È¤ó¤É¤Ï¤Û¤È¤ó¤É¤Î¾ì¹ç¤Ë»ÈÍѤµ¤ì¤ë¤Ù¤­¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ Æäˡ¢Web¥µ¡¼¥Ð¡¼¤¬¤É¤Î´Ä¶­ÊÑ¿ô¤¬»ÈÍѲÄǽ¤Ç¤¢¤ë¤«¤Ë´Ø¤·¤Æ¸·Ì©¤Ç¤¢¤ëWeb¥µ¡¼¥Ó¥¹¥·¥¹¥Æ¥à¤Ç¤Ï¡¢´Ä¶­ÊÑ¿ô¤ÎɬÍ×À­¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¡¢²¿¤ò¹Ô¤Ã¤Æ¤¤¤ë¤«¤òÌÀ¼¨Åª¤Ë¼¨¤¹¤³¤È¤ò¤ªÁ¦¤á¤·¤Þ¤¹¡£ (TBR) =head2 DBI_DSN =begin original The DBI_DSN environment variable is used by DBI->connect if you do not specify a data source when you issue the connect. It should have a format such as "dbi:Driver:databasename". =end original DBI_DSN´Ä¶­ÊÑ¿ô¤Ï¡¢Àܳ¤òȯ¹Ô¤¹¤ë¤È¤­¤Ë¥Ç¡¼¥¿¥½¡¼¥¹¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¤Ë¡¢DBI->connect¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£ ¤³¤ÎÊÑ¿ô¤Ï¡¢"dbi:Driver:databasename"¤Î¤è¤¦¤Ê·Á¼°¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ (TBR) =head2 DBI_DRIVER =begin original The DBI_DRIVER environment variable is used to fill in the database driver name in DBI->connect if the data source string starts "dbi::" (thereby omitting the driver). If DBI_DSN omits the driver name, DBI_DRIVER can fill the gap. =end original DBI_DRIVER´Ä¶­ÊÑ¿ô¤Ï¡¢¥Ç¡¼¥¿¥½¡¼¥¹Ê¸»úÎ󤬡Ödbi::¡×¤Ç»Ï¤Þ¤ë¾ì¹ç¤Ë¡¢DBI->connect¤Ç¥Ç¡¼¥¿¥Ù¡¼¥¹¥É¥é¥¤¥Ð̾¤òÆþÎϤ¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹(¤³¤ì¤Ë¤è¤ê¡¢¥É¥é¥¤¥Ð¤¬¾Êά¤µ¤ì¤Þ¤¹)¡£ DBI_DSN¤Ç¥É¥é¥¤¥Ð̾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Ï¡¢DBI_DRIVER¤Ç¥®¥ã¥Ã¥×¤òËä¤á¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =head2 DBI_AUTOPROXY =begin original The DBI_AUTOPROXY environment variable takes a string value that starts "dbi:Proxy:" and is typically followed by "hostname=...;port=...". It is used to alter the behaviour of DBI->connect. For full details, see DBI::Proxy documentation. =end original DBI_AUTOPROXY´Ä¶­ÊÑ¿ô¤Ï¡¢"dbi:Proxy:"¤Ç»Ï¤Þ¤ëʸ»úÎóÃͤò¼è¤ê¡¢Ä̾ï¤Ï"hostname=.;port=."¤¬Â³¤­¤Þ¤¹¡£ ¤³¤ì¤Ï¡¢DBI->connect¤ÎÆ°ºî¤òÊѹ¹¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤Þ¤¹¡£ ¾ÜºÙ¤Ï¡¢DBI::Proxy¤Îʸ½ñ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 DBI_USER =begin original The DBI_USER environment variable takes a string value that is used as the user name if the DBI->connect call is given undef (as distinct from an empty string) as the username argument. Be wary of the security implications of using this. =end original DBI_USER´Ä¶­ÊÑ¿ô¤Ï¡¢DBI->connect¸Æ¤Ó½Ð¤·¤Ëusername°ú¿ô¤È¤·¤Æundef(¶õ¤Îʸ»úÎó¤È¤ÏÊ̤Î)¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¡¢¥æ¡¼¥¶Ì¾¤È¤·¤Æ»ÈÍѤµ¤ì¤ëʸ»úÎóÃͤò¼è¤ê¤Þ¤¹¡£ ¤³¤ì¤ò»ÈÍѤ¹¤ë¤³¤È¤Ë¤è¤ë¥»¥­¥å¥ê¥Æ¥£¤Ø¤Î±Æ¶Á¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 DBI_PASS =begin original The DBI_PASS environment variable takes a string value that is used as the password if the DBI->connect call is given undef (as distinct from an empty string) as the password argument. Be extra wary of the security implications of using this. =end original DBI_PASS´Ä¶­ÊÑ¿ô¤Ï¡¢DBI->Àܳ¸Æ¤Ó½Ð¤·¤¬¥Ñ¥¹¥ï¡¼¥É°ú¿ô¤È¤·¤Æundef(¶õ¤Îʸ»úÎó¤È¤Ï°Û¤Ê¤ë)¤ò»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¡¢¥Ñ¥¹¥ï¡¼¥É¤È¤·¤Æ»ÈÍѤµ¤ì¤ëʸ»úÎóÃͤò¼è¤ê¤Þ¤¹¡£ ¤³¤ì¤ò»ÈÍѤ¹¤ë¤³¤È¤Ë¤è¤ë¥»¥­¥å¥ê¥Æ¥£¤Ø¤Î±Æ¶Á¤Ë¤ÏÆäËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =head2 DBI_DBNAME (obsolete) =begin original The DBI_DBNAME environment variable takes a string value that is used only when the obsolescent style of DBI->connect (with driver name as fourth parameter) is used, and when no value is provided for the first (database name) argument. =end original DBI_DBNAME´Ä¶­ÊÑ¿ô¤Ï¡¢µì¼°¤ÎDBI->connect(4ÈÖÌܤΥѥé¥á¡¼¥¿¤È¤·¤Æ¥É¥é¥¤¥Ð̾¤ò»ÈÍÑ)¤¬»ÈÍѤµ¤ì¡¢ºÇ½é¤Î(¥Ç¡¼¥¿¥Ù¡¼¥¹Ì¾)°ú¿ô¤ËÃͤ¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Î¤ß»ÈÍѤµ¤ì¤ëʸ»úÎóÃͤò¼è¤ê¤Þ¤¹¡£ (TBR) =head2 DBI_TRACE =begin original The DBI_TRACE environment variable specifies the global default trace settings for the DBI at startup. Can also be used to direct trace output to a file. When the DBI is loaded it does: =end original DBI_TRACE´Ä¶­ÊÑ¿ô¤Ï¡¢µ¯Æ°»þ¤ÎDBI¤Î¥°¥í¡¼¥Ð¥ë¥Ç¥Õ¥©¥ë¥È¥È¥ì¡¼¥¹ÀßÄê¤ò»ØÄꤷ¤Þ¤¹¡£ ¥È¥ì¡¼¥¹½ÐÎϤò¥Õ¥¡¥¤¥ë¤ËÁ÷¤ë¤¿¤á¤Ë¤â»ÈÍѤǤ­¤Þ¤¹¡£ DBI¤¬¥í¡¼¥É¤µ¤ì¤ë¤È¡¢¼¡¤Î½èÍý¤¬¹Ô¤ï¤ì¤Þ¤¹¡£ (TBR) DBI->trace(split /=/, $ENV{DBI_TRACE}, 2) if $ENV{DBI_TRACE}; =begin original So if C contains an "C<=>" character then what follows it is used as the name of the file to append the trace to. =end original ¤·¤¿¤¬¤Ã¤Æ¡¢C¤Ë¡ÖC<=>¡×ʸ»ú¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤½¤Î¸å¤Ë³¤¯Ê¸»ú¤¬¥È¥ì¡¼¥¹¤òÄɲ乤ë¥Õ¥¡¥¤¥ë¤Î̾Á°¤È¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£ (TBR) =begin original output appended to that file. If the name begins with a number followed by an equal sign (C<=>), then the number and the equal sign are stripped off from the name, and the number is used to set the trace level. For example: =end original ½ÐÎϤϤ³¤Î¥Õ¥¡¥¤¥ë¤ËÄɲ䵤ì¤Þ¤¹¡£ ¤â¤·¥Õ¥¡¥¤¥ë̾¤¬¿ô»ú¤Ç»Ï¤Þ¤ê¡¢¸å¤í¤ËÅù¹æ(C<=>)¤¬¤Ä¤¤¤Æ¤¤¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢ ¿ô»ú¤ÈÅù¹æ¤Ï̾Á°¤«¤éÀÚ¤êÎ¥¤µ¤ì¡¢¿ô»ú¤Ï¥È¥ì¡¼¥¹¥ì¥Ù¥ë¤òÀßÄꤹ¤ë¤Î¤Ë »È¤ï¤ì¤Þ¤¹¡£ Î㤨¤Ð: DBI_TRACE=1=dbitrace.log perl your_test_script.pl =begin original On Unix-like systems using a Bourne-like shell, you can do this easily on the command line: =end original unix ¤Î¤è¤¦¤Ê¥·¥¹¥Æ¥à¤Ç Bourne ¤Î¤è¤¦¤Ê¥·¥§¥ë¤ò»È¤Ã¤Æ¤¤¤ì¤Ð¡¢¤³¤ì¤ò ¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ç´Êñ¤Ë¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹: DBI_TRACE=2 perl your_test_script.pl =begin original See L for more information. =end original ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 PERL_DBI_DEBUG (obsolete) =begin original An old variable that should no longer be used; equivalent to DBI_TRACE. =end original ¤â¤Ï¤ä»È¤¦¤Ù¤­¤Ç¤Ï¤Ê¤¤¸Å¤¤ÊÑ¿ô¤Ç¤¹; DBI_TRACE ¤ÈÅù²Á¤Ç¤¹¡£ =head2 DBI_PROFILE =begin original The DBI_PROFILE environment variable can be used to enable profiling of DBI method calls. See L for more information. =end original DBI_PROFILE ´Ä¶­ÊÑ¿ô¤Ï DBI ¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¤Î¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¤ò Í­¸ú¤Ë¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹¡£ ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head2 DBI_PUREPERL =begin original The DBI_PUREPERL environment variable can be used to enable the use of DBI::PurePerl. See L for more information. =end original DBI_PUREPERL ´Ä¶­ÊÑ¿ô¤Ï DBI::PurePerl ¤Î»ÈÍѤòÍ­¸ú¤Ë¤¹¤ë¤¿¤á¤Ë »È¤ï¤ì¤Þ¤¹¡£ ¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head1 WARNING AND ERROR MESSAGES (·Ù¹ð¤È¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸) =head2 Fatal Errors (Ã×̿Ū¥¨¥é¡¼) =over 4 =item Can't call method "prepare" without a package or object reference =begin original The C<$dbh> handle you're using to call C is probably undefined because the preceding C failed. You should always check the return status of DBI methods, or use the L attribute. =end original ¤ª¤½¤é¤¯°ÊÁ°¤Î C ¤¬¼ºÇÔ¤·¤¿¤¿¤á¤Ë¡¢C ¸Æ¤Ó½Ð¤·¤Ë»È¤Ã¤¿ C<$dbh> ¥Ï¥ó¥É¥ë¤¬Ì¤ÄêµÁ¤Ç¤¹¡£ DBI ¥á¥½¥Ã¥É¤ÎÌá¤ê¥¹¥Æ¡¼¥¿¥¹¤ò¾ï¤Ë¥Á¥§¥Ã¥¯¤¹¤ë¤«¡¢L °À­¤ò »È¤ï¤Ê¤±¤ì¤Ð¤ê¤Þ¤»¤ó¡£ =item Can't call method "execute" without a package or object reference =begin original The C<$sth> handle you're using to call C is probably undefined because the preceding C failed. You should always check the return status of DBI methods, or use the L attribute. =end original ¤ª¤½¤é¤¯°ÊÁ°¤Î C ¥á¥½¥Ã¥É¤¬¼ºÇÔ¤·¤¿¤¿¤á¤Ë¡¢C ¸Æ¤Ó½Ð¤·¤Ë »È¤Ã¤¿ C<$sth> ¥Ï¥ó¥É¥ë¤¬Ì¤ÄêµÁ¤Ç¤¹¡£ DBI ¥á¥½¥Ã¥É¤ÎÌá¤ê¥¹¥Æ¡¼¥¿¥¹¤ò¾ï¤Ë¥Á¥§¥Ã¥¯¤¹¤ë¤«¡¢L °À­¤ò »È¤ï¤Ê¤±¤ì¤Ð¤ê¤Þ¤»¤ó¡£ =item DBI/DBD internal version mismatch =begin original The DBD driver module was built with a different version of DBI than the one currently being used. You should rebuild the DBD module under the current version of DBI. =end original DBD ¥É¥é¥¤¥Ð¥â¥¸¥å¡¼¥ë¤¬¡¢¸½ºß»È¤Ã¤Æ¤¤¤ë DBI ¤È¤Ï°Û¤Ê¤ë¥Ð¡¼¥¸¥ç¥ó¤Ç ¥Ó¥ë¥É¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ¸½ºß¤Î¥Ð¡¼¥¸¥ç¥ó¤Î DBI ¤Î¤â¤È¤Ç DBD ¥â¥¸¥å¡¼¥ë¤ò ¥ê¥Ó¥ë¥É¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ =begin original (Some rare platforms require "static linking". On those platforms, there may be an old DBI or DBD driver version actually embedded in the Perl executable being used.) =end original (¤Þ¤ì¤Ë¤Ç¤¹¤¬¡¢¤¤¤¯¤Ä¤«¥×¥é¥Ã¥È¥Û¡¼¥à¤Ï¡ÖÀÅŪ¥ê¥ó¥¯¡×(static linking) ¤ò Í׵ᤷ¤Þ¤¹¡£ ¸Å¤¤ DBI ¤â¤·¤¯¤Ï DBD ¥É¥é¥¤¥Ð¤¬¡¢»È¤ï¤ì¤Æ¤¤¤ë Perl ¤Î¼Â¹Ô²Äǽ¥Õ¥¡¥¤¥ë¤Ë ¼ÂºÝ¤ËËä¤á¹þ¤Þ¤ì¤Æ¤¤¤ë¤Î¤«¤â¤·¤ì¤Þ¤»¤ó¡£) =item DBD driver has not implemented the AutoCommit attribute =begin original The DBD driver implementation is incomplete. Consult the author. =end original DBD ¥É¥é¥¤¥Ð¤Î¼ÂÁõ¤¬´°Á´¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ ºî¼Ô¤Ëʹ¤¤¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£ =item Can't [sg]et %s->{%s}: unrecognised attribute =begin original You attempted to set or get an unknown attribute of a handle. Make sure you have spelled the attribute name correctly; case is significant (e.g., "Autocommit" is not the same as "AutoCommit"). =end original ¥Ï¥ó¥É¥ë¤ÎÉÔÌÀ¤Ê°À­¤òÀßÄê¤Þ¤¿¤Ï¼èÆÀ¤·¤è¤¦¤È¤·¤Þ¤·¤¿¡£ °À­¤Î̾Á°¤¬Àµ¤·¤¤¤«¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤; Âçʸ»ú¡¿¾®Ê¸»ú¤Ï°ÕÌ£¤¬¤¢¤ê¤Þ¤¹ (Î㤨¤Ð "Autocommit" ¤Ï "AutoCommit" ¤ÈƱ¤¸¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó)¡£ =back =head1 Pure-Perl DBI (¥Ô¥å¥¢ Perl ¤Î DBI) =begin original A pure-perl emulation of the DBI is included in the distribution for people using pure-perl drivers who, for whatever reason, can't install the compiled DBI. See L. =end original ¤Ê¤ó¤é¤«¤ÎÍýͳ¤Ë¤è¤Ã¤Æ¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿ DBI ¤ò¥¤¥ó¥¹¥È¡¼¥ë¤Ç¤­¤Ê¤¤¤¿¤á¤Ë ¥Ô¥å¥¢ Perl ¥É¥é¥¤¥Ð¤ò»È¤¦¿Í¡¹¤Î¤¿¤á¤Ë¡¢DBI ¤Î ¥Ô¥å¥¢ Perl ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤¬¤³¤ÎÇÛÉۤ˴ޤޤì¤Æ¤¤¤Þ¤¹¡£ L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head1 SEE ALSO =head2 Driver and Database Documentation (¥É¥é¥¤¥Ð¤È¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥É¥­¥å¥á¥ó¥È) =begin original Refer to the documentation for the DBD driver that you are using. =end original »È¤Ã¤Æ¤¤¤ë DBD ¥É¥é¥¤¥Ð¤Î¥É¥­¥å¥á¥ó¥È¤ò¤´Í÷²¼¤µ¤¤¡£ =begin original Refer to the SQL Language Reference Manual for the database engine that you are using. =end original »È¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥¨¥ó¥¸¥ó¤Î¤¿¤á¤Î SQL ¸À¸ì ¥ê¥Õ¥¡¥ì¥ó¥¹¥Þ¥Ë¥å¥¢¥ë¤ò¤´Í÷²¼¤µ¤¤¡£ =head2 ODBC and SQL/CLI Standards Reference Information (ODBC ¤È SQL/CLI ɸ½à¤Î»²¾È¾ðÊó) =begin original More detailed information about the semantics of certain DBI methods that are based on ODBC and SQL/CLI standards is available on-line via microsoft.com, for ODBC, and www.jtc1sc32.org for the SQL/CLI standard: =end original ODBC¤ª¤è¤ÓSQL/CLIɸ½à¤Ë´ð¤Å¤¯ÆÃÄê¤ÎDBI¥á¥½¥Ã¥É¤Î¥»¥Þ¥ó¥Æ¥£¥¯¥¹¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢microsoft.com(ODBC¤Î¾ì¹ç)¤ª¤è¤Ówww.jtc1sc32.org(SQL/CLIɸ½à¤Î¾ì¹ç)¤«¤é¥ª¥ó¥é¥¤¥ó¤ÇÆþ¼ê¤Ç¤­¤Þ¤¹¡£ (TBR) DBI method ODBC function SQL/CLI Working Draft ---------- ------------- --------------------- column_info SQLColumns Page 124 foreign_key_info SQLForeignKeys Page 163 get_info SQLGetInfo Page 214 primary_key_info SQLPrimaryKeys Page 254 table_info SQLTables Page 294 type_info SQLGetTypeInfo Page 239 statistics_info SQLStatistics =begin original To find documentation on the ODBC function you can use the MSDN search facility at: =end original ODBC´Ø¿ô¤Ë´Ø¤¹¤ëʸ½ñ¤ò¸¡º÷¤¹¤ë¤Ë¤Ï¡¢¼¡¤ÎMSDN¸¡º÷µ¡Ç½¤ò»ÈÍѤ·¤Þ¤¹¡£ (TBR) http://msdn.microsoft.com/Search =begin original and search for something like C<"SQLColumns returns">. =end original ¤½¤·¤Æ C<"SQLColumns returns"> ¤Î¤è¤¦¤Ê·Á¤Ç¸¡º÷¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original And for SQL/CLI standard information on SQLColumns you'd read page 124 of the (very large) SQL/CLI Working Draft available from: =end original SQLColumns¤Ë´Ø¤¹¤ëSQL/CLI¤Îɸ½à¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï¡¢¼¡¤ÎWeb¥µ¥¤¥È¤ÇÆþ¼ê²Äǽ¤Ê(Èó¾ï¤ËÂ絬ÌϤÊ)SQL/CLI Working Draft¤Î124¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) http://jtc1sc32.org/doc/N0701-0750/32N0744T.pdf =head2 Standards Reference Information (ɸ½à¤Î»²¾È¾ðÊó) =begin original A hyperlinked, browsable version of the BNF syntax for SQL92 (plus Oracle 7 SQL and PL/SQL) is available here: =end original SQL92 (plus Oracle 7 SQL and PL/SQL) ¤Î BNF ʸˡ¤Î ¥Ï¥¤¥Ñ¡¼¥ê¥ó¥¯ÉÕ¤­¤Ç¥Ö¥é¥¦¥º²Äǽ¤ÊÈǤϰʲ¼¤ÇÍøÍѲÄǽ¤Ç¤¹: http://cui.unige.ch/db-research/Enseignement/analyseinfo/SQL92/BNFindex.html =begin original A BNF syntax for SQL3 is available here: =end original SQL3 ¤Î BNF ʸˡ¤Ï°Ê²¼¤ÇÍøÍѲÄǽ¤Ç¤¹: http://www.sqlstandards.org/SC32/WG3/Progression_Documents/Informal_working_drafts/iso-9075-2-1999.bnf =begin original The following links provide further useful information about SQL. Some of these are rather dated now but may still be useful. =end original °Ê²¼¤Î¥ê¥ó¥¯¤Ï SQL ¤Ë´Ø¤¹¤ë¤µ¤é¤ËÍ­ÍѤʾðÊó¤òÄ󶡤·¤Þ¤¹¡£ ¤³¤ì¤é¤Î°ìÉô¤Ï¤ä¤ä»þ´Ö¤¬·Ð¤Ã¤Æ¤¤¤Þ¤¹¤¬º£¤Ç¤âÍ­ÍѤǤ¹¡£ http://www.jcc.com/SQLPages/jccs_sql.htm http://www.contrib.andrew.cmu.edu/~shadow/sql.html http://www.altavista.com/query?q=sql+tutorial =head2 Books and Articles (½ñÀҤȵ­»ö) =begin original Programming the Perl DBI, by Alligator Descartes and Tim Bunce. L =end original Programming the Perl DBI, by Alligator Descartes and Tim Bunce. L (ÌõÃí: ÆþÌçPerl DBI) =begin original Programming Perl 3rd Ed. by Larry Wall, Tom Christiansen & Jon Orwant. L =end original Programming Perl 3rd Ed. by Larry Wall, Tom Christiansen & Jon Orwant. L (ÌõÃí: ¥×¥í¥°¥é¥ß¥ó¥° Perl) =begin original Learning Perl by Randal Schwartz. L =end original Learning Perl by Randal Schwartz. L (ÌõÃí: ½é¤á¤Æ¤ÎPerl) =begin original Details of many other books related to perl can be found at L =end original ¤½¤Î¾¤Î perl ¤Ë´Ø¤¹¤ë¿¤¯¤ÎËÜ¤Î¾ÜºÙ¤Ï L ¤Ë¤¢¤ê¤Þ¤¹¡£ =head2 Perl Modules (Perl ¥â¥¸¥å¡¼¥ë) =begin original Index of DBI related modules available from CPAN: =end original CPAN ¤«¤éÍøÍѲÄǽ¤Ê DBI ´ØÏ¢¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹: http://search.cpan.org/search?mode=module&query=DBIx%3A%3A http://search.cpan.org/search?mode=doc&query=DBI =begin original For a good comparison of RDBMS-OO mappers and some OO-RDBMS mappers (including Class::DBI, Alzabo, and DBIx::RecordSet in the former category and Tangram and SPOPS in the latter) see the Perl Object-Oriented Persistence project pages at: =end original RDBMS-OO ¥Þ¥Ã¥Ñ¡¼¤È OO-RDBMS ¥Þ¥Ã¥Ñ¡¼(Á°¼Ô¤Ï Class::DBI, Alzabo, DBIx::RecordSet¡¢¸å¼Ô¤Ï Tangram ¤È SPOPS)¤ÎÎɤ¤Èæ³Ó¤Ë¤Ä¤¤¤Æ¤Ï °Ê²¼¤Î Perl Object-Oriented Persistence ¥×¥í¥¸¥§¥¯¥È¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤: http://poop.sourceforge.net =begin original A similar page for Java toolkits can be found at: =end original Java ¥Ä¡¼¥ë¥­¥Ã¥È¤Î¤¿¤á¤Î»÷¤¿¤è¤¦¤Ê¥Ú¡¼¥¸¤Ï°Ê²¼¤Ë¤¢¤ê¤Þ¤¹: http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison =head2 Mailing List (¥á¡¼¥ê¥ó¥°¥ê¥¹¥È) =begin original The I mailing list is the primary means of communication among users of the DBI and its related modules. For details send email to: =end original I ¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Ï DBI ¤È¤½¤Î´ØÏ¢¤¹¤ë¥â¥¸¥å¡¼¥ë¤ÎÍøÍѼԤΠ¥³¥ß¥å¥Ë¥±¡¼¥·¥ç¥ó¤òÂè°ì¤ÎÌÜŪ¤È¤·¤Æ¤¤¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï²¼µ­¤Î¥¢¥É¥ì¥¹¤Ë¥á¡¼¥ë¤òÁ÷¤Ã¤Æ¤¯¤À¤µ¤¤: dbi-users-help@perl.org =begin original There are typically between 700 and 900 messages per month. You have to subscribe in order to be able to post. However you can opt for a 'post-only' subscription. =end original Ä̾ï 1 ¥ö·î¤Ë 700 ¤«¤é 900 ¤Î¥á¥Ã¥»¡¼¥¸¤¬¤¢¤ê¤Þ¤¹¡£ Åê¹Æ¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ë¤¿¤á¤Ë¤Ï²ÃÆþ¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ ¤·¤«¤·¥ª¥×¥·¥ç¥ó¤Ç¡ÖÅê¹Æ¤Î¤ß¡×(post-only)¤Î»²²Ã¤òÁªÂò¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ =begin original Mailing list archives (of variable quality) are held at: =end original (ÍÍ¡¹¤ÊÉʼÁ¤Î) ¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤Î¥¢¡¼¥«¥¤¥Ö¤Ï°Ê²¼¤Î¥µ¥¤¥È¤Ë¤¢¤ê¤Þ¤¹: http://groups.google.com/groups?group=perl.dbi.users http://www.xray.mpe.mpg.de/mailing-lists/dbi/ http://www.mail-archive.com/dbi-users%40perl.org/ =head2 Assorted Related WWW Links (ÍÍ¡¹¤Ê´Ø·¸¤¹¤ë WWW ¥ê¥ó¥¯) =begin original The DBI "Home Page": =end original DBI "¥Û¡¼¥à¥Ú¡¼¥¸": http://dbi.perl.org/ =begin original Other DBI related links: =end original ¤½¤Î¾¤ÎDBI´ØÏ¢¤Î¥ê¥ó¥¯: http://tegan.deltanet.com/~phlip/DBUIdoc.html http://dc.pm.org/perl_db.html http://wdvl.com/Authoring/DB/Intro/toc.html http://www.hotwired.com/webmonkey/backend/tutorials/tutorial1.html http://bumppo.net/lists/macperl/1999/06/msg00197.html http://gmax.oltrelinux.com/dbirecipes.html =begin original Other database related links: =end original ¤½¤Î¾¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹´ØÏ¢¤Î¥ê¥ó¥¯: http://www.jcc.com/sql_stnd.html http://cuiwww.unige.ch/OSG/info/FreeDB/FreeDB.home.html http://www.connectionstrings.com/ =begin original Security, especially the "SQL Injection" attack: =end original ¥»¥­¥å¥ê¥Æ¥£¡¢ÆäˡÖSQL ¥¤¥ó¥¸¥§¥¯¥·¥ç¥ó¡×¹¶·â: http://www.ngssoftware.com/research/papers.html http://www.ngssoftware.com/papers/advanced_sql_injection.pdf http://www.ngssoftware.com/papers/more_advanced_sql_injection.pdf http://www.esecurityplanet.com/trends/article.php/2243461 http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf http://www.imperva.com/application_defense_center/white_papers/blind_sql_server_injection.html http://online.securityfocus.com/infocus/1644 =begin original Commercial and Data Warehouse Links =end original ¾¦ÍѤª¤è¤Ó¥Ç¡¼¥¿¥¦¥§¥¢¥Ï¥¦¥¹¤Î¥ê¥ó¥¯: http://www.dwinfocenter.org http://www.datawarehouse.com http://www.datamining.org http://www.olapcouncil.org http://www.idwa.org http://www.knowledgecenters.org/dwcenter.asp =begin original Recommended Perl Programming Links =end original ¿ä¾©¤µ¤ì¤ë Perl ¥×¥í¥°¥é¥ß¥ó¥°¤Î¥ê¥ó¥¯ http://language.perl.com/style/ =head2 FAQ =begin original See L =end original L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =head1 AUTHORS =begin original DBI by Tim Bunce, L =end original DBI ¤Ï Tim Bunce, L =begin original This pod text by Tim Bunce, J. Douglas Dunlop, Jonathan Leffler and others. Perl by Larry Wall and the C. =end original ¤³¤Î pod ʸ½ñ¤Ï Tim Bunce, J. Douglas Dunlop, Jonathan Leffler ¤ª¤è¤Ó ¤½¤Î¾¤Î¿Í¤¿¤Á¡£ Perl ¤Ï Larry Wall ¤ª¤è¤Ó the C¡£ =head1 COPYRIGHT =begin original The DBI module is Copyright (c) 1994-2009 Tim Bunce. Ireland. All rights reserved. =end original DBI¥â¥¸¥å¡¼¥ë¤Ï¡¢Copyright(c)1994-2009 Tim Bunce.Ireland.All rights reserved. (TBR) =begin original You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl 5.10.0 README file. =end original Perl 5.10.0 README¥Õ¥¡¥¤¥ë¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ë¤è¤¦¤Ë¡¢GNU General Public License¤Þ¤¿¤ÏArtistic License¤Î¤¤¤º¤ì¤«¤Î¾ò·ï¤Ë´ð¤Å¤¤¤ÆÇÛÉۤǤ­¤Þ¤¹¡£ (TBR) =head1 SUPPORT / WARRANTY (¥µ¥Ý¡¼¥È / ÊݾÚ) =begin original The DBI is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND. =end original DBI ¤Ï¥ª¡¼¥×¥ó¥½¡¼¥¹¥½¥Õ¥È¥¦¥§¥¢¤Ç¤¹¡£ ¤¤¤«¤Ê¤ëÊݾڤ⤪¤³¤Ê¤¤¤Þ¤»¤ó¡£ =head2 Support (¥µ¥Ý¡¼¥È) =begin original My consulting company, Data Plan Services, offers annual and multi-annual support contracts for the DBI. These provide sustained support for DBI development, and sustained value for you in return. Contact me for details. =end original »ä¤Î¥³¥ó¥µ¥ë¥¿¥ó¥È²ñ¼Ò¤Ç¤¢¤ë Data Plan Services ¤Ï DBI ¤ËÂФ¹¤ë°ìǯ¤ª¤è¤Ó Ê£¿ôǯ¤Î¥µ¥Ý¡¼¥È·ÀÌó¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤é¤Ï DBI ³«È¯¤ËÂФ¹¤ë»ý³Ū¤Ê¥µ¥Ý¡¼¥È¤òÄ󶡤·¡¢¤¢¤Ê¤¿¤Ë»ý³Ū¤Ê ²ÁÃͤòÄ󶡤·¤Þ¤¹¡£ ¾Ü¤·¤¯¤Ï»ä¤ËÏ¢Íí¤ò¼è¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =head2 Sponsor Enhancements (¥¹¥Ý¥ó¥µ¡¼³ÈÄ¥) =begin original The DBI Roadmap is available at L =end original DBI ¥í¡¼¥É¥Þ¥Ã¥×¤Ï L ¤Ë ¤¢¤ê¤Þ¤¹¡£ =begin original If your company would benefit from a specific new DBI feature, please consider sponsoring its development. Work is performed rapidly, and usually on a fixed-price payment-on-delivery basis. Contact me for details. =end original ¤¢¤Ê¤¿¤Î²ñ¼Ò¤¬ÆÃÄê¤Î¿·¤·¤¤DBIµ¡Ç½¤Î²¸·Ã¤ò¼õ¤±¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢¤½¤Î³«È¯¤ò»Ù±ç¤¹¤ë¤³¤È¤ò¸¡Æ¤¤·¤Æ¤¯¤À¤µ¤¤¡£ ºî¶È¤Ï¿×®¤Ë¹Ô¤ï¤ì¡¢Ä̾ï¤Ï¸ÇÄê²Á³Ê¤ÎÃåʧ¤¤¥Ù¡¼¥¹¤Ç¹Ô¤ï¤ì¤Þ¤¹¡£ ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï»ä¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£ (TBR) =begin original Using such targeted financing allows you to contribute to DBI development, and rapidly get something specific and valuable in return. =end original ¤³¤Î¤è¤¦¤ÊÂоݤò¹Ê¤Ã¤¿Í»»ñ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢DBI¤Î³«È¯¤Ë¹×¸¥¤·¡¢¤½¤Î¸«ÊÖ¤ê¤È¤·¤ÆÆÃÄê¤Î²ÁÃͤΤ¢¤ë¤â¤Î¤ò¿×®¤ËÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ (TBR) =head1 ACKNOWLEDGEMENTS =begin original I would like to acknowledge the valuable contributions of the many people I have worked with on the DBI project, especially in the early years (1992-1994). In no particular order: Kevin Stock, Buzz Moschetti, Kurt Andersen, Ted Lemon, William Hails, Garth Kennedy, Michael Peppler, Neil S. Briscoe, Jeff Urlwin, David J. Hughes, Jeff Stander, Forrest D Whitcher, Larry Wall, Jeff Fried, Roy Johnson, Paul Hudson, Georg Rehfeld, Steve Sizemore, Ron Pool, Jon Meek, Tom Christiansen, Steve Baumgarten, Randal Schwartz, and a whole lot more. =end original DBI¥×¥í¥¸¥§¥¯¥È¤Ç¡¢¤È¤ê¤ï¤±ºÇ½é¤Î¤³¤í(1992-1994)¤Ë¡¢Â¿Âç¤Ê¹×¸¥¤·¤Æ¤¯¤ì¤¿ ¿¤¯¤Î¿Í¤Ë´¶¼Õ¤·¤Þ¤¹¡£ ½çÉÔƱ¤Ç¡¢Kevin Stock, Buzz Moschetti, Kurt Andersen, Ted Lemon, William Hails, Garth Kennedy, Michael Peppler, Neil S. Briscoe, Jeff Urlwin, David J. Hughes, Jeff Stander, Forrest D Whitcher, Larry Wall, Jeff Fried, Roy Johnson, Paul Hudson, Georg Rehfeld, Steve Sizemore, Ron Pool, Jon Meek, Tom Christiansen, Steve Baumgarten, Randal Schwartz ¾¤Î¿¤¯¤Î¤ß¤Ê¤µ¤ó¡£ =begin original Then, of course, there are the poor souls who have struggled through untold and undocumented obstacles to actually implement DBI drivers. Among their ranks are Jochen Wiedmann, Alligator Descartes, Jonathan Leffler, Jeff Urlwin, Michael Peppler, Henrik Tougaard, Edwin Pratomo, Davide Migliavacca, Jan Pazdziora, Peter Haworth, Edmund Mergl, Steve Williams, Thomas Lowery, and Phlip Plumlee. Without them, the DBI would not be the practical reality it is today. I'm also especially grateful to Alligator Descartes for starting work on the first edition of the "Programming the Perl DBI" book and letting me jump on board. =end original ¤½¤·¤Æ¤â¤Á¤í¤ó¡¢DBI ¥É¥é¥¤¥Ð¼ÂÁõ¤Ø¤Î¸ì¤é¤ì¤Ê¤¤¤½¤·¤Æʸ½ñ²½¤µ¤ì¤Æ¤¤¤Ê¤¤ ¾ã³²¤È³ëÆ£¤·¡¢¤ä¤ê¤È¤²¤¿°¥¤ì¤Ê¿Í¡¹¤Ë¤â¡£ ½çÈÖ¤ò¤Ä¤±¤ë¤È¡¢Jochen Wiedmann, Alligator Descartes, Jonathan Leffler, Jeff Urlwin, Michael Peppler, Henrik Tougaard, Edwin Pratomo, Davide Migliavacca, Jan Pazdziora, Peter Haworth, Edmund Mergl, Steve Williams, Thomas Lowery, Phlip Plumlee¡£ Èà¤é̵¤·¤Ë¤Ï DBI ¤Ïº£Æü¤Î¤è¤¦¤Ê¼ÂºÝ¤Î¥ê¥¢¥ê¥Æ¥¤¤ò¤â¤¿¤Ê¤«¤Ã¤¿¤Ç¤·¤ç¤¦¡£ ¤Þ¤¿ËÜ "Programming the Perl DBI" Âè°ìÈǤò»Ï¤á¡¢»²²Ã¤µ¤»¤Æ¤¯¤ì¤¿ Alligator Descartes ¤Ë¤âÆä˴¶¼Õ¤·¤Þ¤¹¡£ =begin original The DBI and DBD::Oracle were originally developed while I was Technical Director (CTO) of Ingeneering in the UK (L) (formerly known as the Paul Ingram Group). So I'd especially like to thank Paul for his generosity and vision in supporting this work for many years. =end original DBI ¤È DBD::Oracle ¤Ï¤â¤È¤â¤È»ä¤¬¥¤¥®¥ê¥¹¤Î (°ÊÁ°¤Ï Paul Ingram Group ¤È¤·¤Æ ÃΤé¤ì¤Æ¤¤¤¿) Ingeneering ¤Î CTO ¤Ç¤¢¤Ã¤¿´Ö¤Ë³«È¯¤µ¤ì¤Þ¤·¤¿¡£ ¤½¤ì¤Ç¡¢Ä¹Ç¯¤Ë¤ï¤¿¤Ã¤Æ¤³¤Îºî¶È¤ò»Ù¤¨¤Æ¤¯¤ì¤¿´²Â礵¤ÈÀ踫À­¤ËÂФ·¤Æ¡¢ ÆÃ¤Ë Paul ¤Ë´¶¼Õ¤·¤¿¤¤¤È»×¤¤¤Þ¤¹¡£ =begin original A couple of specific DBI features have been sponsored by enlightened companies: =end original Æó¤Ä¤Î DBI µ¡Ç½¤Ï·¼È¯Åª¤Ê´ë¶È¤Ë¤è¤ê¥¹¥Ý¥ó¥µ¡¼¤µ¤ì¤Þ¤·¤¿: =begin original The development of the swap_inner_handle() method was sponsored by BizRate.com (L) =end original swap_inner_handle() ¥á¥½¥Ã¥É¤Î³«È¯¤Ï BizRate.com (L) ¤Î¥¹¥Ý¥ó¥µ¡¼¤Ë¤è¤ë¤â¤Î¤Ç¤¹¡£ =begin original The development of DBD::Gofer and related modules was sponsored by Shopzilla.com (L), where I currently work. =end original DBD::Gofer ¤ª¤è¤Ó´ØÏ¢¤¹¤ë¥â¥¸¥å¡¼¥ë¤Î³«È¯¤Ï»ä¤¬¸½ºßƯ¤¤¤Æ¤¤¤ë Shopzilla.com (L) ¤Î¥¹¥Ý¥ó¥µ¡¼¤Ë¤è¤ë¤â¤Î¤Ç¤¹¡£ =head1 CONTRIBUTING (´óÍ¿¤¹¤ë) =begin original As you can see above, many people have contributed to the DBI and drivers in many ways over many years. =end original ¾å½Ò¤·¤¿¤è¤¦¤Ë¡¢Â¿¤¯¤Î¿Í¡¹¤¬Ä¹Ç¯¤Ë¤ï¤¿¤Ã¤ÆÍÍ¡¹¤ÊÊýË¡¤Ç DBI ¤È ¥É¥é¥¤¥Ð¤Ë´óÍ¿¤·¤Æ¤­¤Þ¤·¤¿¡£ =begin original If you'd like to help then see L and L =end original ¤â¤·½õ¤±¤è¤¦¤È»×¤Ã¤¿¤Ê¤é¡¢L ¤È L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =begin original If you'd like the DBI to do something new or different then a good way to make that happen is to do it yourself and send me a patch to the source code that shows the changes. (But read "Speak before you patch" below.) =end original DBI ¤ËÂФ·¤Æ²¿¤«¿·¤·¤¤¤«°Û¤Ê¤Ã¤¿¤³¤È¤ò¤·¤è¤¦¤È»×¤Ã¤¿¤é¡¢¼«Ê¬¤Ç¤½¤ì¤ò ¹Ô¤Ã¤Æ¡¢Êѹ¹ÅÀ¤¬Ê¬¤«¤ë¥½¡¼¥¹¥³¡¼¥É¤Î¥Ñ¥Ã¥Á¤òÁ÷¤Ã¤Æ¤¯¤À¤µ¤¤¡£ (¤·¤«¤·¸å½Ò¤¹¤ë L ¤òÆɤó¤Ç¤¯¤À¤µ¤¤¡£) =head2 Browsing the source code repository (¥½¡¼¥¹¥³¡¼¥É¥ì¥Ý¥¸¥È¥ê¤ò¸«¤ë) =begin original Use http://svn.perl.org/modules/dbi/trunk (basic) or http://svn.perl.org/viewcvs/modules/ (more useful) =end original http://svn.perl.org/modules/dbi/trunk (´ðËÜ) ¤« http://svn.perl.org/viewcvs/modules/ (¤è¤êÍ­ÍÑ) ¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =head2 How to create a patch using Subversion (Subversion ¤ò»È¤Ã¤Æ¥Ñ¥Ã¥Á¤òºî¤ëÊýË¡) =begin original The DBI source code is maintained using Subversion (a replacement for CVS, see L). To access the source you'll need to install a Subversion client. Then, to get the source code, do: =end original DBI ¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï Subversion (CVS ¤ÎÂåÂØʪ¤Ç¤¹; L ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤) ¤ò»È¤Ã¤Æ Êݼ餵¤ì¤Æ¤¤¤Þ¤¹¡£ ¥½¡¼¥¹¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Ë¤Ï¡¢Subversion ¥¯¥é¥¤¥¢¥ó¥È¤ò ¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤½¤ì¤«¤é¡¢¥½¡¼¥¹¥³¡¼¥É¤ò¼èÆÀ¤¹¤ë¤Ë¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤Þ¤¹: svn checkout http://svn.perl.org/modules/dbi/trunk =begin original If it prompts for a username and password use your perl.org account if you have one, else just 'guest' and 'guest'. The source code will be in a new subdirectory called C. =end original ¥æ¡¼¥¶¡¼Ì¾¤È¥Ñ¥¹¥ï¡¼¥É¤òʹ¤«¤ì¤¿¤é¡¢¤â¤· perl.org ¤Î¥¢¥«¥¦¥ó¥È¤¬¤¢¤ì¤Ð ¤½¤ì¤ò¡¢¤µ¤â¤Ê¤±¤ì¤Ðñ¤Ë 'guest' ¤È 'guest' ¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£ ¥½¡¼¥¹¥³¡¼¥É¤Ï C ¤È¸Æ¤Ð¤ì¤ë¿·¤·¤¤¥Ç¥£¥ì¥¯¥È¥ê¤Î²¼¤Ë¤¢¤ê¤Þ¤¹¡£ =begin original To keep informed about changes to the source you can send an empty email to svn-commit-modules-dbi-subscribe@perl.org after which you'll get an email with the change log message and diff of each change checked-in to the source. =end original To keep informed about changes to the source you can send an empty email to svn-commit-modules-dbi-subscribe@perl.org after which you'll get an email with the change log message and diff of each change checked-in to the source. (TBR) =begin original After making your changes you can generate a patch file, but before you do, make sure your source is still up to date using: =end original After making your changes you can generate a patch file, but before you do, make sure your source is still up to date using: (TBR) svn update =begin original If you get any conflicts reported you'll need to fix them first. Then generate the patch file from within the C directory using: =end original If you get any conflicts reported you'll need to fix them first. Then generate the patch file from within the C directory using: (TBR) svn diff > foo.patch =begin original Read the patch file, as a sanity check, and then email it to dbi-dev@perl.org. =end original ¥µ¥Ë¥Æ¥£¥Á¥§¥Ã¥¯¤È¤·¤Æ¥Ñ¥Ã¥Á¥Õ¥¡¥¤¥ë¤òÆɤó¤Ç¤«¤é¡¢ dbi-dev@perl.org ¤Ë ¥á¡¼¥ë¤òÁ÷¤Ã¤Æ¤¯¤À¤µ¤¤¡£ =head2 How to create a patch without Subversion (Subversion ¤Ê¤·¤Ç¥Ñ¥Ã¥Á¤òºî¤ëÊýË¡) =begin original Unpack a fresh copy of the distribution: =end original ºÇ¿·ÈǤΥǥ£¥¹¥È¥ê¥Ó¥å¡¼¥·¥ç¥ó¤òŸ³«¤·¤Þ¤¹: tar xfz DBI-1.40.tar.gz =begin original Rename the newly created top level directory: =end original ¿·¤·¤¯ºî¤Ã¤¿¥È¥Ã¥×¥ì¥Ù¥ë¥Ç¥£¥ì¥¯¥È¥ê¤Ë̾Á°¤òÊѤ¨¤Þ¤¹: mv DBI-1.40 DBI-1.40.your_foo =begin original Edit the contents of DBI-1.40.your_foo/* till it does what you want. =end original ɬÍפʤÀ¤± DBI-1.40.your_foo/* ¤ÎÆâÍƤòÊѹ¹¤·¤Þ¤¹¡£ =begin original Test your changes and then remove all temporary files: =end original Êѹ¹¤ò¥Æ¥¹¥È¤·¤Æ¡¢Á´¤Æ¤Î°ì»þ¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Þ¤¹: make test && make distclean =begin original Go back to the directory you originally unpacked the distribution: =end original ºÇ½é¤Ë¥Ç¥£¥¹¥È¥ê¥Ó¥å¡¼¥·¥ç¥ó¤òŸ³«¤·¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ËÌá¤ê¤Þ¤¹: cd .. =begin original Unpack I copy of the original distribution you started with: =end original ¸µ¤Î¥Ç¥£¥¹¥È¥ê¥Ó¥å¡¼¥·¥ç¥ó¤ò I<¤â¤¦°ìÅÙ> Ÿ³«¤·¤Þ¤¹: tar xfz DBI-1.40.tar.gz =begin original Then create a patch file by performing a recursive C on the two top level directories: =end original Æó¤Ä¤Î¥È¥Ã¥×¥ì¥Ù¥ë¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤ÆºÆµ¢Åª¤Ë C ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç ¥Ñ¥Ã¥Á¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Þ¤¹: diff -r -u DBI-1.40 DBI-1.40.your_foo > DBI-1.40.your_foo.patch =head2 Speak before you patch (¥Ñ¥Ã¥Á¤¹¤ëÁ°¤ËÏ䷤Ƥߤë) =begin original For anything non-trivial or possibly controversial it's a good idea to discuss (on dbi-dev@perl.org) the changes you propose before actually spending time working on them. Otherwise you run the risk of them being rejected because they don't fit into some larger plans you may not be aware of. =end original ÉáÄ̤Ǥʤ¤¡¢¤¢¤ë¤¤¤ÏµÄÏÀ¤Î;ÃϤ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¤â¤Î¤Ä¤¤¤Æ¤Ï¡¢ ¼ÂºÝ¤Ëºî¶È¤Ë»þ´Ö¤òÈñ¤ä¤¹Á°¤Ë¹Í¤¨¤Æ¤¤¤ëÊѹ¹¤Ë¤Ä¤¤¤Æ (dbi-dev@perl.org ¤Ç)µÄÏÀ¤¹¤ë¤Î¤Ï¤è¤¤¹Í¤¨¤Ç¤¹¡£ ¤µ¤â¤Ê¤±¤ì¤Ð¡¢¤¢¤Ê¤¿¤¬µ¤ÉÕ¤¤¤Æ¤¤¤Ê¤«¤Ã¤¿¤è¤êÂ礭¤Ê·×²è¤Ë¹ç¤ï¤Ê¤¤¤È¤¤¤¦Íýͳ¤Ç µñÈݤµ¤ì¤ë¥ê¥¹¥¯¤¬¤¢¤ê¤Þ¤¹¡£ =head1 TRANSLATIONS (ËÝÌõ) =begin original A German translation of this manual (possibly slightly out of date) is available, thanks to O'Reilly, at: =end original ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤Î¥É¥¤¥Ä¸ìÈǤ¬(¤Á¤ç¤Ã¤È¸Å¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¤¬)°Ê²¼¤Î¥µ¥¤¥È¤Ë ¤¢¤ê¤Þ¤¹; O'Reilly ¤Ë´¶¼Õ¤·¤Þ¤¹: http://www.oreilly.de/catalog/perldbiger/ =begin original Some other translations: =end original ¤½¤Î¾¤ÎËÝÌõ: http://cronopio.net/perl/ - Spanish http://member.nifty.ne.jp/hippo2000/dbimemo.htm - Japanese =head1 TRAINING (¥È¥ì¡¼¥Ë¥ó¥°) =begin original References to DBI related training resources. No recommendation implied. =end original DBI¤Ë´ØÏ¢¤·¤¿¥È¥ì¡¼¥Ë¥ó¥°¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¹¡£ ²¿¤é¿ä¾©¤¹¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ http://www.treepax.co.uk/ http://www.keller.com/dbweb/ =begin original (If you offer professional DBI related training services, please send me your details so I can add them here.) =end original (¤â¤·¤¢¤Ê¤¿¤¬¥×¥í¥Õ¥§¥Ã¥·¥ç¥Ê¥ë¤Ê DBI ´Ø·¸¤Î¥È¥ì¡¼¥Ë¥ó¥°¥µ¡¼¥Ó¥¹¤ò Ä󶡤·¤Æ¤¤¤ë¤Ê¤é¡¢¾ÜºÙ¤ò¥á¡¼¥ë¤·¤Æ¤â¤é¤¨¤ì¤Ð¤³¤³¤ËÄɲä·¤Þ¤¹¡£) =head1 OTHER RELATED WORK AND PERL MODULES (¤½¤Î¾¤Î´Ø·¸¤¹¤ëºîÉÊ¤È Perl ¥â¥¸¥å¡¼¥ë) =over 4 =item Apache::DBI by E.Mergl@bawue.de =begin original To be used with the Apache daemon together with an embedded Perl interpreter like C. Establishes a database connection which remains open for the lifetime of the HTTP daemon. This way the CGI connect and disconnect for every database access becomes superfluous. =end original C ¤Î¤è¤¦¤ÊËä¤á¹þ¤ß·¿ perl ¥¤¥ó¥¿¥×¥ê¥¿¤È¤È¤â¤Ë Apache ¥Ç¡¼¥â¥ó¤Ç »È¤ï¤ì¤Þ¤¹¡£ http ¥Ç¡¼¥â¥ó¤¬À¸¤­¤Æ¤¤¤ë´Ö¤º¤Ã¤È³«¤«¤ì¤ë¥Ç¡¼¥¿¥Ù¡¼¥¹Àܳ¤ò³ÎΩ¤·¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê CGI ¤¬¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¥¢¥¯¥»¥¹¤¹¤ëÅÙ¤ËÀܳ¡¢ÀÚÃǤ¹¤ë¤³¤È¤¬ÉÔɬÍ×¤Ë ¤Ê¤ê¤Þ¤¹¡£ =item SQL Parser =begin original See also the L module, SQL parser and engine. =end original SQL ¥Ñ¡¼¥µ¤È¥¨¥ó¥¸¥ó¤Ç¤¢¤ë L ¥â¥¸¥å¡¼¥ë¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ =back =cut =begin meta Translated: Àî¹ç¹§Åµ (1.19) Updated: SHIRAKATA Kentaro (1.612) Status: stalled =end meta