One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
vo
/
perl
/
mod
/
DBI-1.13
/
blib
/
man3
/
View File Name :
DBI.3
.rn '' }` ''' $RCSfile$$Revision$$Date$ ''' ''' $Log$ ''' .de Sh .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp .if t .sp .5v .if n .sp .. .de Ip .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .de Vb .ft CW .nf .ne \\$1 .. .de Ve .ft R .fi .. ''' ''' ''' Set up \*(-- to give an unbreakable dash; ''' string Tr holds user defined translation string. ''' Bell System Logo is used as a dummy character. ''' .tr \(*W-|\(bv\*(Tr .ie n \{\ .ds -- \(*W- .ds PI pi .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch .ds L" "" .ds R" "" ''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of ''' \*(L" and \*(R", except that they are used on ".xx" lines, ''' such as .IP and .SH, which do another additional levels of ''' double-quote interpretation .ds M" """ .ds S" """ .ds N" """"" .ds T" """"" .ds L' ' .ds R' ' .ds M' ' .ds S' ' .ds N' ' .ds T' ' 'br\} .el\{\ .ds -- \(em\| .tr \*(Tr .ds L" `` .ds R" '' .ds M" `` .ds S" '' .ds N" `` .ds T" '' .ds L' ` .ds R' ' .ds M' ` .ds S' ' .ds N' ` .ds T' ' .ds PI \(*p 'br\} .\" If the F register is turned on, we'll generate .\" index entries out stderr for the following things: .\" TH Title .\" SH Header .\" Sh Subsection .\" Ip Item .\" X<> Xref (embedded .\" Of course, you have to process the output yourself .\" in some meaninful fashion. .if \nF \{ .de IX .tm Index:\\$1\t\\n%\t"\\$2" .. .nr % 0 .rr F .\} .TH DBI 3 "perl 5.005, patch 03" "12/Jul/1999" "User Contributed Perl Documentation" .UC .if n .hy 0 .if n .na .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .de CQ \" put $1 in typewriter font .ft CW 'if n "\c 'if t \\&\\$1\c 'if n \\&\\$1\c 'if n \&" \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7 '.ft R .. .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2 . \" AM - accent mark definitions .bd B 3 . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds ? ? . ds ! ! . ds / . ds q .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10' . ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' . ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#] .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u' .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u' .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#] .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E .ds oe o\h'-(\w'o'u*4/10)'e .ds Oe O\h'-(\w'O'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds v \h'-1'\o'\(aa\(ga' . ds _ \h'-1'^ . ds . \h'-1'. . ds 3 3 . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE . ds oe oe . ds Oe OE .\} .rm #[ #] #H #V #F C .SH "NAME" DBI \- Database independent interface for Perl .SH "SYNOPSIS" .PP .Vb 1 \& use DBI; .Ve .Vb 2 \& @driver_names = DBI->available_drivers; \& @data_sources = DBI->data_sources($driver_name); .Ve .Vb 1 \& $dbh = DBI->connect($data_source, $username, $auth, \e%attr); .Ve .Vb 3 \& $rv = $dbh->do($statement); \& $rv = $dbh->do($statement, \e%attr); \& $rv = $dbh->do($statement, \e%attr, @bind_values); .Ve .Vb 3 \& $ary_ref = $dbh->selectall_arrayref($statement); \& @row_ary = $dbh->selectrow_array($statement); \& $ary_ref = $dbh->selectcol_arrayref($statement); .Ve .Vb 2 \& $sth = $dbh->prepare($statement); \& $sth = $dbh->prepare_cached($statement); .Ve .Vb 3 \& $rv = $sth->bind_param($p_num, $bind_value); \& $rv = $sth->bind_param($p_num, $bind_value, $bind_type); \& $rv = $sth->bind_param($p_num, $bind_value, \e%attr); .Ve .Vb 2 \& $rv = $sth->execute; \& $rv = $sth->execute(@bind_values); .Ve .Vb 2 \& $rc = $sth->bind_col($col_num, \e$col_variable); \& $rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind); .Ve .Vb 3 \& @row_ary = $sth->fetchrow_array; \& $ary_ref = $sth->fetchrow_arrayref; \& $hash_ref = $sth->fetchrow_hashref; .Ve .Vb 1 \& $ary_ref = $sth->fetchall_arrayref; .Ve .Vb 1 \& $rv = $sth->rows; .Ve .Vb 2 \& $rc = $dbh->commit; \& $rc = $dbh->rollback; .Ve .Vb 1 \& $sql = $dbh->quote($string); .Ve .Vb 3 \& $rc = $h->err; \& $str = $h->errstr; \& $rv = $h->state; .Ve .Vb 1 \& $rc = $dbh->disconnect; .Ve .Sh "\s-1NOTE\s0" This is the \s-1DBI\s0 specification that corresponds to the \s-1DBI\s0 version 1.13 ($Date: 1999/07/12 02:02:33 $). .PP The \s-1DBI\s0 specification is evolving at a steady pace so it's important to check that you have the latest copy. The \s-1RECENT\s0 \s-1CHANGES\s0 section below has a summary of user-visible changes and the \fIChanges\fR file supplied with the \s-1DBI\s0 holds more detailed change information. .PP Note also that whenever the \s-1DBI\s0 changes the drivers take some time to catch up. Recent versions of the \s-1DBI\s0 have added new features (marked *\s-1NEW\s0* in the text) that may not yet be supported by the drivers you use. Talk to the authors of those drivers if you need the features. .PP Please also read the \s-1DBI\s0 \s-1FAQ\s0 which is installed as a \s-1DBI::FAQ\s0 module so you can use perldoc to read it by executing the \f(CWperldoc DBI::FAQ\fR command. .PP Extensions to the \s-1DBI\s0 and other \s-1DBI\s0 related modules use the \f(CWDBIx::*\fR namespace. See the section on \fI/Naming Conventions and Name Space\fR and: .PP .Vb 1 \& http://www.perl.com/CPAN/modules/by-module/DBIx/ .Ve .Sh "\s-1RECENT\s0 \s-1CHANGES\s0 " A brief summary of significant user-visible changes in recent versions (if a recent version isn't mentioned it simply means that there were no significant user-visible changes in that version). .Ip "Between \s-1DBI\s0 1.00 and \s-1DBI\s0 1.09" 4 .Sp .Vb 1 \& Added $dbh->selectcol_arrayref($statement) method. .Ve .Vb 2 \& Connect now allows you to specify attribute settings within the DSN \& E.g., "dbi:Driver(RaiseError=>1,Taint=>1,AutoCommit=>0):dbname" .Ve .Vb 1 \& Added $h->{Taint}, $sth->{NAME_uc} and $sth->{NAME_lc} attributes. .Ve .SH "DESCRIPTION" The DBI is a database access module for the Perl Language. It defines a set of methods, variables and conventions that provide a consistent database interface independant of the actual database being used. .PP It is important to remember that the DBI is just an interface. A layer of \*(L'glue\*(R' between an application and one or more \fIDatabase Driver\fR modules. It is the driver modules which do the real work. The DBI provides a standard interface and framework for the drivers to operate within. .Sh "Architecture of a \s-1DBI\s0 Application" .PP .Vb 11 \& |<- 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 \& `-------' | |... \& `-' .Ve The \s-1API\s0 is the Application Perl-script (or Programming) Interface. The call interface and variables provided by \s-1DBI\s0 to perl scripts. The \s-1API\s0 is implemented by the \s-1DBI\s0 Perl extension. .PP The \s-1DBI\s0 \*(L'dispatches\*(R' the method calls to the appropriate Driver for actual execution. The \s-1DBI\s0 is also responsible for the dynamic loading of Drivers, error checking/handling and other duties. .PP The Drivers implement support for a given type of Engine (database). Drivers contain implementations of the \s-1DBI\s0 methods written using the private interface functions of the corresponding Engine. Only authors of sophisticated/multi-database applications or generic library functions need be concerned with Drivers. .Sh "Notation and Conventions" .PP .Vb 12 \& DBI static 'top-level' class name \& $dbh Database handle object \& $sth Statement handle object \& $drh Driver handle object (rarely seen or used in applications) \& $h Any of the $??h handle types above \& $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 \& \e%attr Reference to a hash of attribute values passed to methods .Ve Note that Perl will automatically destroy database and statement objects if all references to them are deleted. .Sh "Outline Usage" First you need to load the \s-1DBI\s0 module: .PP .Vb 1 \& use DBI; .Ve (also adding \f(CWuse strict;\fR is recommended). Then you need to the \f(CWconnect\fR entry elsewhere in this documentto your data source and get a \fIhandle\fR for that connection: .PP .Vb 2 \& $dbh = DBI->connect($dsn, $user, $password, \& { RaiseError => 1, AutoCommit => 0 }); .Ve Since connecting can be expensive you generally just connect at the start of your program and disconnect at the end. .PP Explicitly defining the required AutoCommit behaviour is strongly recommended and may become mandatory in a later version. .PP The \s-1DBI\s0 allows an application to `prepare\*(R' statements for later execution. A prepared statement is identified by a statement handle. We'll call the perl variable \f(CW$sth\fR. .PP Typical method call sequence for a select statement: .PP .Vb 4 \& prepare, \& execute, fetch, fetch, ... \& execute, fetch, fetch, ... \& execute, fetch, fetch, ... .Ve for example: .PP .Vb 1 \& $sth = $dbh->prepare("select foo, bar from table where baz=?"); .Ve .Vb 1 \& $sth->execute( $baz ); .Ve .Vb 3 \& while ( @row = $sth->fetchrow_array ) { \& print "@row\en"; \& } .Ve Typical method call sequence for a non-select statement: .PP .Vb 4 \& prepare, \& execute, \& execute, \& execute. .Ve for example: .PP .Vb 1 \& $sth = $dbh->prepare("insert into table(foo,bar,baz) values (?,?,?)"); .Ve .Vb 5 \& while(<CSV>) { \& chop; \& my ($foo,$bar,$baz) = split /,/; \& $sth->execute( $foo, $bar, $baz ); \& } .Ve The \f(CWdo()\fR method can be used for non repeated non-select statement (or with drivers that don't support placeholders): .PP .Vb 1 \& $rows_affected = $dbh->do("update your_table set foo = foo + 1"); .Ve To commit your changes to the database (when the \f(CWAutoCommit\fR entry elsewhere in this documentis off): .PP .Vb 1 \& $dbh->commit; # or call $dbh->rollback; to undo changes .Ve Finally, when you have finished working with the data source you should the \f(CWdisconnect\fR entry elsewhere in this documentfrom it: .PP .Vb 1 \& $dbh->disconnect; .Ve .Sh "General Interface Rules & Caveats" The \s-1DBI\s0 does not have a concept of a `current session\*(R'. Every session has a handle object (i.e., a \f(CW$dbh\fR) returned from the connect method and that handle object is used to invoke database related methods. .PP Most data is returned to the perl script as strings (null values are returned as undef). This allows arbitrary precision numeric data to be handled without loss of accuracy. Be aware that perl may not preserve the same accuracy when the string is used as a number. .PP Dates and times are returned as character strings in the native format of the corresponding Engine. Time Zone effects are Engine/Driver dependent. .PP Perl supports binary data in perl strings and the \s-1DBI\s0 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. .PP Character sets: Most databases which understand character sets have a default global charset and text stored in the database is, or should be, stored in that charset (if it's not then that's the fault of either the database or the application that inserted the data). When text is fetched it should be (automatically) converted to the charset of the client (presumably based on the locale). If a driver needs to set a flag to get that behaviour then it should do so. It should not require the application to do that. .PP Multiple \s-1SQL\s0 statements may not be combined in a single statement handle, e.g., a single \f(CW$sth\fR (though some drivers do support this). .PP Non-sequential record reads are not supported in this version of the \s-1DBI\s0. In other words, records can only be fetched in the order that the database returned them and once fetched they are forgotten. .PP Positioned updates and deletes are not directly supported by the \s-1DBI\s0. See the description of the CursorName attribute for an alternative. .PP 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 \s-1DBI\s0 \f(CWfunc\fR method. Private driver attributes are accessed just like standard attributes. .PP Many methods have an optional \e%attr parameter which can be used to pass information to the driver implementing the method. Except where specifically documented the \e%attr parameter can only be used to pass driver specific hints. In general you can ignore \e%attr parameters or pass it as undef. .Sh "Naming Conventions and Name Space" The \s-1DBI\s0 package and all packages below it \f(CWDBI::*\fR are reserved for use by the \s-1DBI\s0. Extensions and related modules use the \f(CWDBIx::\fR namespace. Package names beginning with \f(CWDBD::\fR are reserved for use by \s-1DBI\s0 database drivers. All environment variables used by the \s-1DBI\s0 or \s-1DBD\s0's begin with \*(L'\s-1DBI_\s0\*(R' or \*(L'\s-1DBD_\s0\*(R'. .PP The letter case used for attribute names is significant and plays an important part in the portability of \s-1DBI\s0 scripts. The case of the attribute name is used to signify who defined the meaning of that name and its values. .PP .Vb 5 \& Case of name Has a meaning defined by \& ------------ ------------------------ \& UPPER_CASE Standards, e.g., X/Open, SQL92 etc (portable) \& MixedCase DBI API (portable), underscores are not used. \& lower_case Driver or Engine specific (non-portable) .Ve 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., ora_ for Oracle, ing_ for Ingres etc). .PP Driver Specific Prefix Registry: .PP .Vb 14 \& ora_ DBD::Oracle \& ing_ DBD::Ingres \& odbc_ DBD::ODBC \& syb_ DBD::Sybase \& db2_ DBD::DB2 \& ix_ DBD::Informix \& f_ DBD::File \& csv_ DBD::CSV \& file_ DBD::TextFile \& xbase_ DBD::XBase \& solid_ DBD::Solid \& proxy_ DBD::Proxy \& msql_ DBD::mSQL \& mysql_ DBD::mysql .Ve .Sh "Placeholders and Bind Values" Some drivers support Placeholders and Bind Values. These drivers allow a database statement to contain placeholders, sometimes called parameter markers, that indicate values 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 \s-1SALES\s0 table: .PP .Vb 1 \& insert into sales (product_code, qty, price) values (?, ?, ?) .Ve or the following, to select the description for a product: .PP .Vb 1 \& select description from products where product_code = ? .Ve The \f(CW?\fR characters are the placeholders. The association of actual values with placeholders is known as binding and the values are referred to as bind values. .PP When using placeholders with the \s-1SQL\s0 \f(CWLIKE\fR qualifier you must remember that the placeholder substitutes for the whole string. So you should use \*(L"... \s-1LIKE\s0 ? ...\*(R" and include any wildcard characters in the value that you bind to the placeholder. .PP \fBNull Values\fR .PP Undefined values or \f(CWundef\fR can be used to indicate null values. However, care must be taken in the particular case of trying to use null values to qualify a select statement. Consider: .PP .Vb 1 \& select description from products where product_code = ? .Ve Binding an undef (\s-1NULL\s0) to the placeholder will \fInot\fR select rows which have a \s-1NULL\s0 product_code! Refer to the \s-1SQL\s0 manual for your database engine or any \s-1SQL\s0 book for the reasons for this. To explicitly select NULLs you have to say \*(L"where product_code is \s-1NULL\s0\*(R" and to make that general you have to say: .PP .Vb 1 \& ... WHERE (product_code = ? OR (? IS NULL AND product_code IS NULL)) .Ve and bind the same value to both placeholders. .PP \fBPerformance\fR .PP Without using placeholders, the insert statement above would have to contain the literal values to be inserted and it 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 execute 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: .PP .Vb 9 \& my $sth = $dbh->prepare(q{ \& INSERT INTO sales (product_code, qty, price) VALUES (?, ?, ?) \& }) || die $dbh->errstr; \& while (<>) { \& chop; \& my ($product_code, $qty, $price) = split /,/; \& $sth->execute($product_code, $qty, $price) || die $dbh->errstr; \& } \& $dbh->commit || die $dbh->errstr; .Ve See the \f(CWexecute\fR and \f(CWbind_param\fR entries elsewhere in this documentfor more details. .PP The \f(CWq{...}\fR style quoting used in this example avoids clashing with quotes that may be used in the \s-1SQL\s0 statement. Use the double-quote like \f(CWqq{...}\fR operator if you want to interpolate variables into the string. See the section on \fIQuote and Quote-like Operators\fR in the \fIperlop\fR manpage for more details. .PP See the \f(CWbind_column\fR entry elsewhere in this documentfor a related method used to associate perl variables with the \fIoutput\fR columns of a select statement. .Sh "\s-1SQL\s0 \- A Query Language" Most \s-1DBI\s0 drivers require applications to use a dialect of \s-1SQL\s0 (the Structured Query Language) to interact with the database engine. These links provide useful information and further links about \s-1SQL\s0, the first is a good tutorial with much useful information and many links: .PP .Vb 3 \& http://www.geocities.com/ResearchTriangle/Node/9672/sqltut.html \& http://www.jcc.com/sql_stnd.html \& http://www.contrib.andrew.cmu.edu/~shadow/sql.html .Ve The \s-1DBI\s0 itself does not mandate or require any particular language to be used. It is language independant. In \s-1ODBC\s0 terms the \s-1DBI\s0 is in \&'pass-thru\*(R' mode (individual drivers might not be). The only requirement is that queries and other statements must be expressed as a single string of letters passed as the first argument to the the \f(CWprepare\fR entry elsewhere in this documentmethod. .PP For an interesting diversion on the \fIreal\fR history of \s-1RDBMS\s0 and \s-1SQL\s0, from the people who made it happen, see .PP .Vb 1 \& http://ftp.digital.com/pub/DEC/SRC/technical-notes/SRC-1997-018-html/sqlr95.html .Ve Follow the \*(L"And the rest\*(R" and \*(L"Intergalactic dataspeak\*(R" links for the \s-1SQL\s0 history. .SH "THE DBI CLASS" .Sh "\s-1DBI\s0 Class Methods" .Ip "\fBconnect\fR" 4 .Sp .Vb 4 \& $dbh = DBI->connect($data_source, $username, $password) \& || die $DBI::errstr; \& $dbh = DBI->connect($data_source, $username, $password, \e%attr) \& || die $DBI::errstr; .Ve Establishes a database connection, or session, to the requested data_source. Returns a database handle object if the connect succeeds. Use \f(CW$dbh\fR\->disconnect to terminate the connection. .Sp If the connect fails (see below) it returns undef and sets \f(CW$DBI::err\fR and \f(CW$DBI::errstr\fR (it does \fInot\fR set $! etc). Generally you should test the return status of connect and print \f(CW$DBI::errstr\fR if it has failed. .Sp Multiple simultaneous connections to multiple databases through multiple drivers can be made via the \s-1DBI\s0. Simply make one connect call for each and keep a copy of each returned database handle. .Sp The \f(CW$data_source\fR value should begin with \*(L'dbi:driver_name:\*(R'. The driver_name part specifies the driver that will be used to make the connection (letter case is significant). .Sp As a convenience, if the \f(CW$data_source\fR parameter is undefined or empty the \s-1DBI\s0 will substitute the value of the environment variable \s-1DBI_DSN\s0. If just the driver_name part is empty (i.e., data_source prefix is \*(L'dbi::') the environment variable \s-1DBI_DRIVER\s0 is used. If neither variable is set then the connect dies. .Sp Examples of \f(CW$data_source\fR values: .Sp .Vb 3 \& dbi:DriverName:database_name \& dbi:DriverName:database_name@hostname:port \& dbi:DriverName:database=database_name;host=hostname;port=port .Ve There is \fIno standard\fR for the text following the driver name. Each driver is free to use whatever syntax it wants. The only requirement the \s-1DBI\s0 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. (Where a driver author needs to define a syntax for the data_source it is recommended that they follow the \s-1ODBC\s0 style, the last example above.) .Sp If the environment variable \s-1DBI_AUTOPROXY\s0 is defined (and the driver in \f(CW$data_source\fR is not \*(L'Proxy') then the connect request will automatically be changed to: .Sp .Vb 1 \& dbi:Proxy:$ENV{DBI_AUTOPROXY};dsn=$data_source .Ve and passed to the \s-1DBD::\s0Proxy module. \s-1DBI_AUTOPROXY\s0 would typically be \*(L"hostname=...;port=...\*(R". See the \fI\s-1DBD::\s0Proxy\fR manpage for more details. .Sp If \f(CW$username\fR or \f(CW$password\fR are \fIundefined\fR (rather than just empty) then the \s-1DBI\s0 will substitute the values of the \s-1DBI_USER\s0 and \s-1DBI_PASS\s0 environment variables respectively. The \s-1DBI\s0 will warn if the environment variables are not defined. The use of the environment for these values is not recommended for security reasons. The mechanism is primarily intended to simplify testing. .Sp \s-1DBI\s0\->connect automatically installs the driver if it has not been installed yet. Driver installation \fIalways\fR returns a valid driver handle or it \fIdies\fR with an error message which includes the string \&'install_driver\*(R' and the underlying problem. So, \s-1DBI\s0\->connect will die on a driver installation failure and will only return undef on a connect failure, for which \f(CW$DBI::errstr\fR will hold the error. .Sp The \f(CW$data_source\fR argument (with the \*(L'dbi:...:\*(R' prefix removed) and the \f(CW$username\fR and \f(CW$password\fR arguments are then passed to the driver for processing. The \s-1DBI\s0 does not define \fIany\fR interpretation for the contents of these fields. The driver is free to interpret the data_source, username and password fields in any way and supply whatever defaults are appropriate for the engine being accessed (Oracle, for example, uses the \s-1ORACLE_SID\s0 and \s-1TWO_TASK\s0 env vars if no data_source is specified). .Sp The AutoCommit and PrintError attributes for each connection default to \fIon\fR (see the \f(CWAutoCommit\fR and \f(CWPrintError\fR entries elsewhere in this documentfor more information). However, it is \fBstrongly recommended\fR that AutoCommit is \fIexplicitly\fR defined as required rather than rely on the default. Future versions of the \s-1DBI\s0 may issue a warning if AutoCommit is not explicitly defined. .Sp The \e%attr parameter can be used to alter the default settings of the PrintError, RaiseError, AutoCommit and other attributes. For example: .Sp .Vb 4 \& $dbh = DBI->connect($data_source, $user, $pass, { \& PrintError => 0, \& AutoCommit => 0 \& }); .Ve You can also define connection attribute values within the \f(CW$data_source\fR parameter. For example .Sp .Vb 1 \& dbi:DriverName(PrintError=>0,Taint=>1):... .Ve Individual attributes values specified in this way take precedence over any conflicting values specified via the \e%attrib parameter to \f(CWconnect()\fR. .Sp Portable applications should not assume that a single driver will be able to support multiple simultaneous sessions. Though most do. .Sp Where possible each session ($dbh) is independent from the transactions in other sessions. This is useful where you need to hold cursors open across transactions, e.g., use one session for your long lifespan cursors (typically read-only) and another for your short update transactions. .Sp For compatibility with old \s-1DBI\s0 scripts the driver can be specified by passing its name as the fourth argument to connect (instead of \e%attr): .Sp .Vb 1 \& $dbh = DBI->connect($data_source, $user, $pass, $driver); .Ve In this \*(L'old-style\*(R' form of connect the \f(CW$data_source\fR should not start with \*(L'dbi:driver_name:\*(R' and, even if it does, the embedded driver_name will be ignored. The \f(CW$dbh\fR\->{AutoCommit} attribute is \fIundefined\fR. The \f(CW$dbh\fR\->{PrintError} attribute is off. And the old \s-1DBI_DBNAME\s0 env var is checked if \s-1DBI_DSN\s0 is not defined. \fIThis \*(L'old-style\*(R' connect will be withdrawn in a future version\fR. .Ip "\fBconnect_cached\fR *\s-1NEW\s0*" 4 .Sp .Vb 4 \& $dbh = DBI->connect_cached($data_source, $username, $password) \& || die $DBI::errstr; \& $dbh = DBI->connect_cached($data_source, $username, $password, \e%attr) \& || die $DBI::errstr; .Ve Like the \f(CWconnect\fR entry elsewhere in this documentexcept that the database handle returned will be stored in a hash associated with the given parameters. If another call is made to connect_cached with the \fIsame parameter values\fR then the corresponding cached \f(CW$dbh\fR will be returned, without contacting the data source, so long as it is still \fIok\fR. If the cached database handle has been disconnected or the \fIping()\fR method fails then it will be replaced with a new connection. .Sp Note that the behaviour of this method differs in several respects from the behaviour of the presistent connections implemented by Apache::\s-1DBI\s0. .Sp This caching can be useful in some applications but it can also cause problems and should be used with care. The exact behaviour of this method \fIis liable to change\fR. If you intend to use it in any production applications your should discuss your needs in the dbi-users mailing list. .Sp The cache can be accessed (and cleared) via the the \f(CWCachedKids\fR entry elsewhere in this documentattribute. .Ip "\fBavailable_drivers\fR" 4 .Sp .Vb 2 \& @ary = DBI->available_drivers; \& @ary = DBI->available_drivers($quiet); .Ve Returns a list of all available drivers by searching for \s-1DBD\s0::* modules through the directories in \f(CW@INC\fR. By default a warning will be given if some drivers are hidden by others of the same name in earlier directories. Passing a true value for \f(CW$quiet\fR will inhibit the warning. .Ip "\fBdata_sources\fR" 4 .Sp .Vb 2 \& @ary = DBI->data_sources($driver); \& @ary = DBI->data_sources($driver, \e%attr); .Ve Returns a list of all data sources (databases) available via the named driver. The driver will be loaded if not already. If \f(CW$driver\fR is empty or undef then the value of the \s-1DBI_DRIVER\s0 environment variable will be used. .Sp Data sources will be returned in a form suitable for passing to the the \f(CWconnect\fR entry elsewhere in this documentmethod, i.e., they will include the \*(L"dbi:$driver:\*(R" prefix. .Sp Note that many drivers have no way of knowing what data sources might be available for it and thus, typically, return an empty or incomplete list. .Ip "\fBtrace\fR" 4 .Sp .Vb 2 \& DBI->trace($trace_level) \& DBI->trace($trace_level, $trace_filename) .Ve \s-1DBI\s0 trace information can be enabled for all handles using this \s-1DBI\s0 class method. To enable trace information for a specific handle use the similar \f(CW$h\fR\->trace method described elsewhere. .Sp \fBTrace Levels:\fR .Sp .Vb 8 \& 0 - trace disabled. \& 1 - trace DBI method calls returning with results. \& 2 - trace method entry with parameters and exit with results. \& 3 - as above, adding some high-level information from the driver \& also adds some internal information from the DBI. \& 4 - as above, adding more detailed information from the driver \& also includes DBI mutex information when using threaded perl. \& 5 and above - as above but with more and more obscure information. .Ve Trace level 1 is best for a simple overview of what's happening. Trace level 2 is a good choice for general purpose tracing. Levels 3 and above (up to 9) are best reserved for use when investigating a specific problem and you need to see \*(L'inside\*(R' the driver and \s-1DBI\s0. .Sp The trace output is detailed and typically \fIvery\fR useful. Much of the trace output is formatted using the the \f(CWneat\fR entry elsewhere in this documentfunction and thus strings in the trace output may be edited and truncated by it. .Sp Initially trace output is written to \s-1STDERR\s0. If \f(CW$trace_filename\fR is specified then the file is opened in append mode and \fIall\fR trace output (including that from other handles) is redirected to that file. Further calls to trace without a \f(CW$trace_filename\fR do not alter where the trace output is sent. If \f(CW$trace_filename\fR is undefined then trace output is sent to \s-1STDERR\s0 and the previous trace file closed. .Sp See also the \f(CW$h\fR\->\fItrace()\fR and \f(CW$h\fR\->\fItrace_msg()\fR methodd and the \f(CWDEBUGGING\fR entry elsewhere in this documentfor information about the \s-1DBI_TRACE\s0 environment variable. .Sh "\s-1DBI\s0 Utility Functions" .Ip "\fBneat\fR" 4 .Sp .Vb 1 \& $str = DBI::neat($value, $maxlen); .Ve Return a string containing a neat (and tidy) representation of the supplied value. .Sp Strings will be quoted (but internal quotes will not be escaped). Values \fIknown\fR to be numeric will be unquoted. Undefined (\s-1NULL\s0) values will be shown as \f(CWundef\fR (without quotes). Unprintable characters will be replaced by dot (.). .Sp For result strings longer than \f(CW$maxlen\fR the result string will be truncated to \f(CW$maxlen\fR\-4 and \f(CW...'\fR will be appended. If \f(CW$maxlen\fR is 0 or undef it defaults to \f(CW$DBI::neat_maxlen\fR which, in turn, defaults to 400. .Sp This function is designed to format values for human consumption. It is used internally by the \s-1DBI\s0 for the \f(CWtrace\fR entry elsewhere in this documentoutput. It should typically \fInot\fR be used for formating values for database use (see also the \f(CWquote\fR entry elsewhere in this document). .Ip "\fBneat_list\fR" 4 .Sp .Vb 1 \& $str = DBI::neat_list(\e@listref, $maxlen, $field_sep); .Ve Calls \s-1DBI::\s0neat on each element of the list and returns a string containing the results joined with \f(CW$field_sep\fR. \f(CW$field_sep\fR defaults to \f(CW", "\fR. .Ip "\fBlooks_like_number\fR" 4 .Sp .Vb 1 \& @bool = DBI::looks_like_number(@array); .Ve Returns true for each element that looks like a number. Returns false for each element that does not look like a number. Returns undef for each element that is undefined or empty. .Sh "\s-1DBI\s0 Dynamic Attributes" These attributes are always associated with the last handle used. .PP Where an attribute is equivalent to a method call, then refer to the method call for all related documentation. .PP \fBWarning:\fR these attributes are provided as a convenience but they do have limitations. Specifically, because they are associated with the last handle used, they should only be used \fIimmediately\fR after calling the method which \*(L'sets\*(R' them. They have a \*(L'short lifespan\*(R'. .PP If in any doubt, use the corresponding method call. .Ip "\fB$\s-1DBI::\s0err\fR" 4 Equivalent to \f(CW$h\fR\->err. .Ip "\fB$\s-1DBI::\s0errstr\fR" 4 Equivalent to \f(CW$h\fR\->errstr. .Ip "\fB$\s-1DBI::\s0state\fR" 4 Equivalent to \f(CW$h\fR\->state. .Ip "\fB$\s-1DBI::\s0rows\fR" 4 Equivalent to \f(CW$h\fR\->rows. Please refer to the the \f(CWrows\fR entry elsewhere in this documentmethod documentation. .SH "METHODS COMMON TO ALL HANDLES" .Ip "\fBerr\fR" 4 .Sp .Vb 1 \& $rv = $h->err; .Ve Returns the \fInative\fR database engine error code from the last driver function called. The code is typically an integer but you should not assume that. .Sp If you need to test for individual errors \fIand\fR 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. .Ip "\fBerrstr\fR" 4 .Sp .Vb 1 \& $str = $h->errstr; .Ve Returns the native database engine error message from the last driver function called. .Ip "\fBstate\fR" 4 .Sp .Vb 1 \& $str = $h->state; .Ve Returns an error code in the standard \s-1SQLSTATE\s0 five character format. Note that the specific success code \f(CW00000\fR is translated to \f(CW0\fR (false). If the driver does not support \s-1SQLSTATE\s0, and most don't, then state will return \f(CWS1000\fR (General Error) for all errors. .Ip "\fBtrace\fR" 4 .Sp .Vb 2 \& $h->trace($trace_level); \& $h->trace($trace_level, $trace_filename); .Ve \s-1DBI\s0 trace information can be enabled for a specific handle (and any future children of that handle) by setting the trace level using the trace method. .Sp Trace level 1 is best for a simple overview of what's happening. Trace level 2 is a good choice for general purpose tracing. Levels 3 and above (up to 9) are best reserved for use when investigating a specific problem and you need to see \*(L'inside\*(R' the driver and \s-1DBI\s0. Use \f(CW$trace_level\fR 0 to disable the trace. .Sp The trace output is detailed and typically \fIvery\fR useful. Much of the trace output is formatted using the the \f(CWneat\fR entry elsewhere in this documentfunction and thus strings in the trace output may be edited and truncated by it. .Sp Initially trace output is written to \s-1STDERR\s0. If \f(CW$trace_filename\fR is specified then the file is opened in append mode and \fIall\fR trace output (including that from other handles) is redirected to that file. Further calls to trace without a \f(CW$trace_filename\fR do not alter where the trace output is sent. If \f(CW$trace_filename\fR is undefined then trace output is sent to \s-1STDERR\s0 and the previous trace file closed. .Sp See also the \s-1DBI\s0\->\fItrace()\fR method and the \f(CWDEBUGGING\fR entry elsewhere in this documentfor information about the \s-1DBI_TRACE\s0 environment variable. .Ip "\fBtrace_msg\fR" 4 .Sp .Vb 2 \& $h->trace_msg($message_text); \& $h->trace_msg($message_text, $min_level); .Ve Writes \f(CW$message_text\fR to trace file \fIif\fR trace is enabled for \f(CW$h\fR or for the \s-1DBI\s0 as a whole. Can also be called as \s-1DBI\s0\->\fItrace_msg\fR\|($msg). See the \f(CWtrace\fR entry elsewhere in this document. .Sp If \f(CW$min_level\fR is defined then the message is output only if the trace level is equal to or greater than that level. \f(CW$min_level\fR defaults to 1. .Ip "\fBfunc\fR" 4 .Sp .Vb 1 \& $h->func(@func_arguments, $func_name); .Ve The func 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 \fIlast\fR argument. .Sp This method is not directly related to calling stored procedures. Calling stored procedures is currently not defined by the \s-1DBI\s0. Some drivers, such as \s-1DBD::\s0Oracle, support it in non-portable ways. See driver documentation for more details. .SH "ATTRIBUTES COMMON TO ALL HANDLES" These attributes are common to all types of DBI handles. .PP Some attributes are inherited by \fIchild\fR 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 \fIexisting\fR statement handles, only future ones. .PP Attempting to set or get the value of an unknown attribute is fatal, except for private driver specific attributes (which all have names starting with a lowercase letter). .PP Example: .PP .Vb 2 \& $h->{AttributeName} = ...; # set/write \& ... = $h->{AttributeName}; # get/read .Ve .Ip "\fBWarn\fR (boolean, inherited)" 4 Enables useful warnings for certain bad practices. Enabled by default. Some emulation layers, especially those for perl4 interfaces, disable warnings. Since warnings are generated using the perl \fIwarn()\fR function they can be intercepted using the perl \f(CW$SIG\fR{_\|_WARN_\|_} hook. .Ip "\fBActive\fR (boolean, read-only)" 4 True if the handle object is \*(L'active\*(R'. 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 ($dbh->disconnect should set Active off). For a statement handle it \fItypically\fR means that the handle is a select that may have more data to fetch ($dbh->finish or fetching all the data should set Active off). .Ip "\fBKids\fR (integer, read-only)" 4 For a driver handle, Kids is the number of currently existing database handles that were created from that driver handle. For a database handle, Kids is the number of currently existing statement handles that were created from that database handle. .Ip "\fBActiveKids\fR (integer, read-only)" 4 Like Kids (above), but only counting those that are Active (as above). .Ip "\fBCachedKids\fR (hash ref)" 4 For a database handle, returns a reference to the cache (hash) of statement handles created by the the \f(CWprepare_cached\fR entry elsewhere in this documentmethod. For a driver handle, it would return a reference to the cache (hash) of statement handles created by the the \f(CWconnect_cached\fR entry elsewhere in this documentmethod. .Ip "\fBCompatMode\fR (boolean, inherited)" 4 Used by emulation layers (such as Oraperl) to enable compatible behaviour in the underlying driver (e.g., \s-1DBD::\s0Oracle) for this handle. Not normally set by application code. .Ip "\fBInactiveDestroy\fR (boolean)" 4 This attribute can be used to disable the database related effect of \s-1DESTROY\s0'ing a handle (which would normally close a prepared statement or disconnect from the database etc). It is specifically designed for use in \s-1UNIX\s0 applications which \*(L'fork\*(R' child processes. Either the parent or the child process, but not both, should set InactiveDestroy on all their handles. For a database handle, this attribute does not disable an \fIexplicit\fR call to the disconnect method, only the implicit call from \s-1DESTROY\s0. .Ip "\fBPrintError\fR (boolean, inherited)" 4 This attribute can be used to force errors to generate warnings (using warn) in addition to returning error codes in the normal way. When set on, any method which results in an error occuring will cause the \s-1DBI\s0 to effectively do a \fIwarn\fR\|("$class \f(CW$method\fR failed: \f(CW$DBI::errstr\fR") where \f(CW$class\fR is the driver class and \f(CW$method\fR is the name of the method which failed. E.g., .Sp .Vb 1 \& DBD::Oracle::db prepare failed: ... error text here ... .Ve By default \s-1DBI\s0\->connect sets PrintError on (except for old-style connect usage, see the \f(CWconnect\fR entry elsewhere in this documentfor more details). .Sp If desired, the warnings can be caught and processed using a \f(CW$SIG\fR{_\|_WARN_\|_} handler or modules like \s-1CGI::\s0Carp and \s-1CGI::\s0ErrorWrap. .Ip "\fBRaiseError\fR (boolean, inherited)" 4 This attribute can be used to force errors to raise exceptions rather than simply return error codes in the normal way. It defaults to off. When set on, any method which results in an error occuring will cause the \s-1DBI\s0 to effectively do a \fIdie\fR\|("$class \f(CW$method\fR failed: \f(CW$DBI::errstr\fR") where \f(CW$class\fR is the driver class and \f(CW$method\fR is the name of the method which failed. E.g., .Sp .Vb 1 \& DBD::Oracle::db prepare failed: ... error text here ... .Ve If PrintError is also on then the PrintError is done before the RaiseError unless no _\|_DIE_\|_ handler has been defined, in which case PrintError is skipped since the die will print the message. .Sp If you want to temporarily turn RaiseError off (inside a library function that is likely to fail for example), the recommended way is like this: .Sp .Vb 4 \& { \& local $h->{RaiseError} = 0 if $h->{RaiseError}; \& ... \& } .Ve The original value will automatically and reliably be restored by perl regardless of how the block is exited. The \f(CW... if $h-\fR{RaiseError}> is optional but makes the code slightly faster in the common case. The same logic applies to other attributes, including RaiseError. .Sp \fBSadly this doesn't work\fR for perl versions upto and including 5.004_04. For backwards compatibility could just use \f(CWeval { ... }\fR instead. .Ip "\fBChopBlanks\fR (boolean, inherited)" 4 This attribute can be used to control the trimming of trailing space characters from \fIfixed width\fR character (\s-1CHAR\s0) fields. No other field types are affected, even where field values have trailing spaces. .Sp The default is false (it is possible that that may change). Applications that need specific behaviour should set the attribute as needed. Emulation interfaces should set the attribute to match the behaviour of the interface they are emulating. .Sp Drivers are not required to support this attribute but any driver which does not must arrange to return undef as the attribute value. .Ip "\fBLongReadLen\fR (unsigned integer, inherited)" 4 This attribute may be used to control the maximum length of \*(L'long\*(R' ('blob\*(R', \*(L'memo\*(R' etc.) fields which the driver will \fIread\fR from the database automatically when it fetches each row of data. The LongReadLen attribute only relates to fetching/reading long values it is \fInot\fR involved in inserting/updating them. .Sp A value of 0 means don't automatically fetch any long data (fetch should return undef for long fields when LongReadLen is 0). .Sp The default is typically 0 (zero) bytes but may vary between drivers. Applications fetching long fields should set this value to slightly larger than the longest long field value which will be fetched. .Sp Some databases return some \*(L'long\*(R' types encoded as pairs of hex digits. For these types LongReadLen relates to the underlying data and not the doubled-up length of the encoded string. .Sp Changing the value of LongReadLen for a statement handle \fIafter\fR it's been \fIprepare()\fR'd \fIwill typically have no effect\fR so it's usual to set LongReadLen on the \f(CW$dbh\fR before calling prepare. .Sp Note that the value used here has a direct effect on the memory used by the application, so don't be too generous. It's also a good idea to use values which are just smaller than a power of 2, e.g., 2**16-2 which is 65534 bytes. .Sp See the \f(CWLongTruncOk\fR entry elsewhere in this documentabout truncation behaviour. .Ip "\fBLongTruncOk\fR (boolean, inherited)" 4 This 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 LongReadLen attribute). .Sp By default LongTruncOk is false and fetching a truncated long value will cause the fetch to fail. (Applications should always take care 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.) .Sp If a fetch fails due to a long field truncation when LongTruncOk is false, many drivers will allow you to continue fetching further rows. .Sp See also the \f(CWLongReadLen\fR entry elsewhere in this document. .Ip "\fBTaint\fR (boolean, inherited)" 4 If this attribute it set to some true value and Perl is running in taint mode (e.g., started with the \f(CW-T\fR option), then a) all data fetched from the database is tainted, and b) the arguments to most \s-1DBI\s0 method calls are checked for being tainted. \fIThis may change.\fR .Sp The attribute defaults to off, even if perl is in taint mode. See the \fIperlsec\fR manpage for more about taint mode. If Perl is not running in taint mode, this attribute has no effect. .Sp Currently only fetched data is tainted. It is likely that the results of other \s-1DBI\s0 method calls, and the value of fetched attributes, will also be tainted in future versions. That change may well break your applications unless you take great care now. If you use \s-1DBI\s0 Taint mode, please report your experience and any suggestions for changes. .Ip "\fBprivate_*\fR" 4 The \s-1DBI\s0 provides a way to store extra information in a \s-1DBI\s0 handle as \&'private\*(R' attributes. The \s-1DBI\s0 will allow you to store and retreive any attribute which has a name starting with \*(L'private_\*(R'. It is \fIstrongly\fR recommended that you use just \fIone\fR private attribute (e.g., use a hash ref) \fIand\fR give it a long and unambiguous name that includes the module or application that the attribute relates to (e.g., \&'private_YourFullModuleName_thingy'). .SH "DBI DATABASE HANDLE OBJECTS" .Sh "Database Handle Methods" .Ip "\fBselectrow_array\fR" 4 .Sp .Vb 3 \& @row_ary = $dbh->selectrow_array($statement); \& @row_ary = $dbh->selectrow_array($statement, \e%attr); \& @row_ary = $dbh->selectrow_array($statement, \e%attr, @bind_values); .Ve This utility method combines the \f(CWprepare\fR, \f(CWexecute\fR, and \f(CWfetchrow_array\fR entries elsewhere in this documentinto a single call. If called in a list context it returns the first row of data from the statement. If called in a scalar context it returns the first field of the first row. The \f(CW$statement\fR parameter can be a previously prepared statement handle in which case the prepare is skipped. .Sp If any method fails, and the \f(CWRaiseError\fR entry elsewhere in this documentis not set, selectrow_array will return an empty list (or undef in scalar context). .Ip "\fBselectall_arrayref\fR" 4 .Sp .Vb 3 \& $ary_ref = $dbh->selectall_arrayref($statement); \& $ary_ref = $dbh->selectall_arrayref($statement, \e%attr); \& $ary_ref = $dbh->selectall_arrayref($statement, \e%attr, @bind_values); .Ve This utility method combines the \f(CWprepare\fR, \f(CWexecute\fR, and \f(CWfetchall_arrayref\fR entries elsewhere in this documentinto a single call. It returns a reference to an array containing references to arrays for each row of data fetched. .Sp The \f(CW$statement\fR parameter can be a previously prepared statement handle in which case the prepare is skipped. .Sp If any method except fetch fails, and the \f(CWRaiseError\fR entry elsewhere in this documentis not set, selectall_arrayref will return undef. If fetch fails, and the \f(CWRaiseError\fR entry elsewhere in this documentis not set, then it will return with whatever data it has fetched thus far. .Ip "\fBselectcol_arrayref\fR" 4 .Sp .Vb 3 \& $ary_ref = $dbh->selectcol_arrayref($statement); \& $ary_ref = $dbh->selectcol_arrayref($statement, \e%attr); \& $ary_ref = $dbh->selectcol_arrayref($statement, \e%attr, @bind_values); .Ve This utility method combines the \f(CWprepare\fR and \f(CWexecute\fR entries elsewhere in this document 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. .Sp The \f(CW$statement\fR parameter can be a previously prepared statement handle in which case the prepare is skipped. .Sp If any method except fetch fails, and the \f(CWRaiseError\fR entry elsewhere in this documentis not set, selectall_arrayref will return undef. If fetch fails, and the \f(CWRaiseError\fR entry elsewhere in this documentis not set, then it will return with whatever data it has fetched thus far. .Ip "\fBprepare\fR" 4 .Sp .Vb 2 \& $sth = $dbh->prepare($statement) || die $dbh->errstr; \& $sth = $dbh->prepare($statement, \e%attr) || die $dbh->errstr; .Ve Prepares a \fIsingle\fR statement for later execution by the database engine and returns a reference to a statement handle object. .Sp The returned statement handle can be used to get attributes of the statement and invoke the the \f(CWexecute\fR entry elsewhere in this documentmethod. See the section on \fI/Statement Handle Methods\fR. .Sp Note that prepare should never execute a statement, even if it is not a select statement, it only \fIprepares\fR it for execution. (Having said that, some drivers, notably Oracle 7, will execute data definition statements such as create/drop table when they are prepared. In practice this is rarely a problem.) .Sp Drivers for engines which don't have the concept of preparing a statement will typically just store the statement in the returned handle and process it when \f(CW$sth\fR\->execute is called. Such drivers are likely to be unable to give much useful information about the statement, such as \f(CW$sth\fR\->{\s-1NUM_OF_FIELDS\s0}, until after \f(CW$sth\fR\->execute has been called. Portable applications should take this into account. .Sp In general \s-1DBI\s0 drivers do \fInot\fR parse the contents of the statement (other than simply counting any the \f(CWPlaceholders\fR entry elsewhere in this document). 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 using a simple engine and need to take extra care if attempting to write applications to be portable between engines. .Sp Portable applications should not assume that a new statement can be prepared and/or executed while still fetching results from a previous statement. .Sp Some command-line \s-1SQL\s0 tools use statement terminators, like a semicolon, to indicate the end of a statement. Such terminators should not be used with the \s-1DBI\s0. .Ip "\fBprepare_cached\fR" 4 .Sp .Vb 3 \& $sth = $dbh->prepare_cached($statement) \& $sth = $dbh->prepare_cached($statement, \e%attr) \& $sth = $dbh->prepare_cached($statement, \e%attr, $allow_active) .Ve Like the \f(CWprepare\fR entry elsewhere in this documentexcept that the statement handle returned will be stored in a hash associated with the \f(CW$dbh\fR. If another call is made to prepare_cached with the \fIsame parameter values\fR then the corresponding cached \f(CW$sth\fR will be returned without contacting the database server. .Sp This caching can be useful in some applications but it can also cause problems and should be used with care. A warning will be generated if the cached \f(CW$sth\fR being returned is active (i.e., is a select that may still have data to be fetched) unless \f(CW$allow_active\fR is true. .Sp The cache can be accessed (and cleared) via the the \f(CWCachedKids\fR entry elsewhere in this documentattribute. .Ip "\fBdo\fR" 4 .Sp .Vb 3 \& $rc = $dbh->do($statement) || die $dbh->errstr; \& $rc = $dbh->do($statement, \e%attr) || die $dbh->errstr; \& $rv = $dbh->do($statement, \e%attr, @bind_values) || ... .Ve Prepare and execute a single statement. Returns the number of rows affected (\-1 if not known or not available) or undef on error. .Sp This method is typically most useful for \fInon-select\fR statements which either cannot be prepared in advance (due to a limitation of the driver) or which do not need to be executed repeatedly. It should not be used for select statements because it does not return a statement handle so you can't fetch any data. .Sp The default do method is logically similar to: .Sp .Vb 7 \& 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 \& } .Ve Example: .Sp .Vb 4 \& my $rows_deleted = $dbh->do(q{ \& delete from table \& where status = ? \& }, undef, 'DONE') || die $dbh->errstr; .Ve Using placeholders and \f(CW@bind_values\fR with the \f(CWdo\fR method can be useful because it avoids the need to correctly quote any variables in the \f(CW$statement\fR. .Sp The \f(CWq{...}\fR style quoting used in this example avoids clashing with quotes that may be used in the \s-1SQL\s0 statement. Use the double-quote like \f(CWqq{...}\fR operator if you want to interpolate variables into the string. See the section on \fIQuote and Quote-like Operators\fR in the \fIperlop\fR manpage for more details. .Ip "\fBcommit\fR" 4 .Sp .Vb 1 \& $rc = $dbh->commit || die $dbh->errstr; .Ve Commit (make permanent) the most recent series of database changes if the database supports transactions. .Sp If the database supports transactions and AutoCommit is on then the commit should issue a \*(L"commit ineffective with AutoCommit\*(R" warning. .Sp See also the \f(CWTransactions\fR entry elsewhere in this document. .Ip "\fBrollback\fR" 4 .Sp .Vb 1 \& $rc = $dbh->rollback || die $dbh->errstr; .Ve Roll-back (undo) the most recent series of uncommitted database changes if the database supports transactions. .Sp If the database supports transactions and AutoCommit is on then the rollback should issue a \*(L"rollback ineffective with AutoCommit\*(R" warning. .Sp See also the \f(CWTransactions\fR entry elsewhere in this document. .Ip "\fBdisconnect\fR" 4 .Sp .Vb 1 \& $rc = $dbh->disconnect || warn $dbh->errstr; .Ve Disconnects the database from the database handle. Typically only used before exiting the program. The handle is of little use after disconnecting. .Sp The transaction behaviour of the disconnect 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 AutoCommit should explicitly call commit or rollback before calling disconnect. .Sp The database is automatically disconnected (by the \s-1DESTROY\s0 method) if still connected when there are no longer any references to the handle. The \s-1DESTROY\s0 method for each driver \fIshould\fR implicitly call rollback to undo any uncommitted changes. This is \fIvital\fR behaviour to ensure that incomplete transactions don't get committed simply because Perl calls \s-1DESTROY\s0 on every object before exiting. Also, do not rely on the order of object destruction during \*(L'global destruction\*(R', it is undefined. .Sp Generally if you want your changes to be commited or rolled back when you disconnect then you should explicitly call the \f(CWcommit\fR entry elsewhere in this documentor the \f(CWrollback\fR entry elsewhere in this documentbefore disconnecting. .Sp If you disconnect from a database while you still have active statement handles you will get a warning. The statement handles should either be cleared (destroyed) before disconnecting or the finish method called on each one. .Ip "\fBping\fR" 4 .Sp .Vb 1 \& $rc = $dbh->ping; .Ve 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. .Sp The default implementation currently always returns true without actually doing anything. Actually it returns \*(L"\f(CW0E0\fR\*(R" which is true but zero. That way you can tell if the return value is genuine or just the default. .Sp Very few applications would have any use for this method. See the specialist Apache::\s-1DBI\s0 module for one example usage. .Ip "\fBtable_info\fR *\s-1NEW\s0*" 4 \fBWarning:\fR This method is experimental and may change or disappear. .Sp .Vb 1 \& $sth = $dbh->table_info; .Ve Returns an active statement handle that can be used to fetch information about tables and views that exist in the database. .Sp The handle has at least the following fields in the order show below. Other fields, after these, may also be present. .Sp \fB\s-1TABLE_CAT\s0\fR: Table catalogue identifier. \s-1NULL\s0 (undef) if not applicable to data source (usually the case). Empty if not applicable to the table. .Sp \fB\s-1TABLE_SCHEM\s0\fR: The name of the schema containing the \s-1TABLE_NAME\s0 value. \s-1NULL\s0 (undef) if not applicable to data source. Empty if not applicable to the table. .Sp \fB\s-1TABLE_NAME\s0\fR: Name of the table (or view, synonym, etc). .Sp \fB\s-1TABLE_TYPE\s0\fR: One of the following: \*(L"\s-1TABLE\s0\*(R", \*(L"\s-1VIEW\s0\*(R", \*(L"\s-1SYSTEM\s0 \s-1TABLE\s0\*(R", \*(L"\s-1GLOBAL\s0 \s-1TEMPORARY\s0\*(R", \*(L"\s-1LOCAL\s0 \s-1TEMPORARY\s0\*(R", \*(L"\s-1ALIAS\s0\*(R", \*(L"\s-1SYNONYM\s0\*(R" or a data source specific type identifier. .Sp \fB\s-1REMARKS\s0\fR: A description of the table. May be \s-1NULL\s0 (undef). .Sp Note that table_info might not return records for all tables. Applications can use any valid table regardless of whether it's returned by table_info. See also the \f(CWtables\fR entry elsewhere in this document. .Sp For more detailed information about the fields and their meanings, you can refer to: .Sp .Vb 1 \& http://msdn.microsoft.com/library/sdkdoc/dasdk/odbc/odbcsqltables.htm .Ve .Ip "\fBtables\fR *\s-1NEW\s0*" 4 \fBWarning:\fR This method is experimental and may change or disappear. .Sp .Vb 1 \& @names = $dbh->tables; .Ve Returns a list of table and view names. This list should include all tables which can be used in a select statement without further qualification. That typically means all the tables and views owned by the current user and all those accessible via public synonyms/aliases (excluding non-metadata system tables and views). .Sp Note that table_info might not return records for all tables. Applications can use any valid table regardless of whether it's returned by tables. See also the \f(CWtable_info\fR entry elsewhere in this document. .Ip "\fBtype_info_all\fR *\s-1NEW\s0*" 4 \fBWarning:\fR This method is experimental and may change or disappear. .Sp .Vb 1 \& $type_info_all = $dbh->type_info_all; .Ve 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. .Sp The first item is a reference to a hash of Name => Index pairs. The following items are references to arrays, one per supported data type variant. The leading hash defines the names and order of the fields within the following list of arrays. For example: .Sp .Vb 25 \& $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, \& NUM_PREC_RADIX => 15, \& }, \& [ '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 \& ], \& ]; .Ve Note that more than one row may have the same value in the \s-1DATA_TYPE\s0 field if there are different ways to spell the type name and/or there are varients of the type with different attributes (e.g., with and without \s-1AUTO_UNIQUE_VALUE\s0 set, with and without \s-1UNSIGNED_ATTRIBUTE\s0 etc). .Sp The rows are ordered by \s-1DATA_TYPE\s0 first and then by how closely each type maps to the corresponding \s-1ODBC\s0 \s-1SQL\s0 data type, closest first. .Sp The meaning of the fields is described in the documentation for the the \f(CWtype_info\fR entry elsewhere in this documentmethod. The index values shown above (e.g., \s-1NULLABLE\s0 => 6) are for illustration only. Drivers may define the fields with a different order. .Sp This method is not normally used directly. The the \f(CWtype_info\fR entry elsewhere in this documentmethod provides a more useful interface to the data. .Ip "\fBtype_info\fR *\s-1NEW\s0*" 4 \fBWarning:\fR This method is experimental and may change or disappear. .Sp .Vb 1 \& @type_info = $dbh->type_info($data_type); .Ve Returns a list of hash references holding information about one or more variants of \f(CW$data_type\fR (or a type \fIreasonably compatible\fR with it). .Sp If \f(CW$data_type\fR is \s-1SQL_ALL_TYPES\s0 then the list will contain hashes for all data type variants supported by the database and driver. .Sp The list is ordered by \s-1DATA_TYPE\s0 first and then by how closely each type maps to the corresponding \s-1ODBC\s0 \s-1SQL\s0 data type, closest first. .Sp The keys of the hash follow the same letter case conventions as the rest of the \s-1DBI\s0 (see the section on \fI/Naming Conventions and Name Space\fR). The following items should exist: .Ip "\s-1TYPE_NAME\s0 (string)" 8 Data type name for use in \s-1CREATE\s0 \s-1TABLE\s0 statements etc. .Ip "\s-1DATA_TYPE\s0 (integer)" 8 \s-1SQL\s0 data type number. .Ip "\s-1COLUMN_SIZE\s0 (integer)" 8 For numeric types this is either the total number of digits (if the \s-1NUM_PREC_RADIX\s0 value is 10) or the total number of bits allowed in the column (if \s-1NUM_PREC_RADIX\s0 is 2). .Sp For string types this is the maximum size of the string in bytes. .Sp For date and interval types this is the maximum number of characters needed to display the value. .Ip "\s-1LITERAL_PREFIX\s0 (string)" 8 Characters used to prefix a literal. Typically \*(L"'\*(R" for characters, possibly \*(L"0x\*(R" for binary values passed as hex. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1LITERAL_SUFFIX\s0 (string)" 8 Characters used to suffix a literal. Typically \*(L"'\*(R" for characters. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1CREATE_PARAMS\s0 (string)" 8 Parameters for a data type definition. For example, \s-1CREATE_PARAMS\s0 for a \s-1DECIMAL\s0 would be \*(L"precision,scale\*(R". For a \s-1VARCHAR\s0 it would be \*(L"max length\*(R". \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1NULLABLE\s0 (integer)" 8 Indicates whether the data type accepts a \s-1NULL\s0 value: 0 = no, 1 = yes, 2 = unknown. .Ip "\s-1CASE_SENSITIVE\s0 (boolean)" 8 Indicates whether the data type is case sensitive in collations and comparisons. .Ip "\s-1SEARCHABLE\s0 (integer)" 8 Indicates how the data type can be used in a \s-1WHERE\s0 clause: .Sp .Vb 4 \& 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 .Ve .Ip "\s-1UNSIGNED_ATTRIBUTE\s0 (boolean)" 8 Indicates whether the data type is unsigned. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1FIXED_PREC_SCALE\s0 (boolean)" 8 Indicates whether the data type always has the same precision and scale (such as a money type). \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1AUTO_UNIQUE_VALUE\s0 (boolean)" 8 Indicates whether a column of this data type is automatically set to a unique value whenever a new row is inserted. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1LOCAL_TYPE_NAME\s0 (string)" 8 Localised version of the \s-1TYPE_NAME\s0 for use in dialogue with users. \s-1NULL\s0 (undef) is returned if a localised name is not available (in which case \s-1TYPE_NAME\s0 should be used). .Ip "\s-1MINIMUM_SCALE\s0 (integer)" 8 The minimum scale of the data type. If a data type has a fixed scale then \s-1MAXIMUM_SCALE\s0 holds the same value. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1MAXIMUM_SCALE\s0 (integer)" 8 The maximum scale of the data type. If a data type has a fixed scale then \s-1MINIMUM_SCALE\s0 holds the same value. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Ip "\s-1NUM_PREC_RADIX\s0 (integer)" 8 The radix value of the data type. For approximate numeric types this contains the value 2 and \s-1COLUMN_SIZE\s0 holds the number of bits. For exact numeric types this contains the value 10 and \s-1COLUMN_SIZE\s0 holds the number of decimal digits. \s-1NULL\s0 (undef) is returned for data types where this is not applicable. .Sp For more detailed information about these fields and their meanings, you can refer to: .Sp .Vb 1 \& http://msdn.microsoft.com/library/sdkdoc/dasdk/odbc/odbcsqlgettypeinfo.htm .Ve The individual data types are described here: .Sp .Vb 1 \& http://msdn.microsoft.com/library/sdkdoc/dasdk/odbc/odbcsql_data_types.htm .Ve .Ip "\fBquote\fR" 4 .Sp .Vb 2 \& $sql = $dbh->quote($value); \& $sql = $dbh->quote($value, $data_type); .Ve Quote a string literal for use as a literal value in an \s-1SQL\s0 statement by \fIescaping\fR any special characters (such as quotation marks) contained within the string \fIand\fR adding the required type of outer quotation marks. .Sp .Vb 2 \& $sql = sprintf "select foo from bar where baz = %s", \& $dbh->quote("Don't\en"); .Ve For most database types quote would return \f(CW'Don''t'\fR (including the outer quotation marks). .Sp An undefined \f(CW$value\fR value will be returned as the string \s-1NULL\s0 (without quotation marks) to match how NULLs are represented in \s-1SQL\s0. .Sp If \f(CW$data_type\fR is supplied it is used to try to determine the required quoting behaviour by using the information returned by the \f(CWtype_info\fR entry elsewhere in this document. As a special case, the standard numeric types are optimised to return \f(CW$value\fR without calling type_info. .Sp Quote will probably \fInot\fR 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. There is no need to quote values being used with the section on \fI/"Placeholders and Bind Values\fR. .Sh "Database Handle Attributes" This section describes attributes specific to database handles. .PP Changes to these database handle attributes do not affect any other existing or future database handles. .PP Attempting to set or get the value of an unknown attribute is fatal, except for private driver specific attributes (which all have names starting with a lowercase letter). .PP Example: .PP .Vb 2 \& $h->{AutoCommit} = ...; # set/write \& ... = $h->{AutoCommit}; # get/read .Ve .Ip "\fBAutoCommit\fR (boolean)" 4 If true then database changes cannot be rolled-back (undone). If false then database changes automatically occur within a \*(L'transaction\*(R' which must either be committed or rolled-back using the commit or rollback methods. .Sp Drivers should always default to AutoCommit mode. (An unfortunate choice largely forced on the \s-1DBI\s0 by \s-1ODBC\s0 and \s-1JDBC\s0 conventions.) .Sp Attempting to set AutoCommit to an unsupported value is a fatal error. This is an important feature of the \s-1DBI\s0. Applications which need full transaction behaviour can set \f(CW$dbh\fR\->{AutoCommit} = 0 (or via the \f(CWconnect\fR entry elsewhere in this document) without having to check the value was assigned okay. .Sp For the purposes of this description we can divide databases into three categories: .Sp .Vb 3 \& Database which don't support transactions at all. \& Database in which a transaction is always active. \& Database in which a transaction must be explicitly started ('BEGIN WORK'). .Ve \fB* Database which don't support transactions at all\fR .Sp For these databases attempting to turn AutoCommit off is a fatal error. Commit and rollback both issue warnings about being ineffective while AutoCommit is in effect. .Sp \fB* Database in which a transaction is always active\fR .Sp These are typically mainstream commercial relational databases with \&'\s-1ANSI\s0 standard\*(R' transaction behaviour. .Sp If AutoCommit is off then changes to the database won't have any lasting effect unless the \f(CWcommit\fR entry elsewhere in this documentis called (but see also the \f(CWdisconnect\fR entry elsewhere in this document). If the \f(CWrollback\fR entry elsewhere in this documentis called then any changes since the last commit are undone. .Sp If AutoCommit is on then the effect is the same as if the \s-1DBI\s0 were to have called commit automatically after every successful database operation. In other words, calling commit or rollback explicitly while AutoCommit is on would be ineffective because the changes would have already been commited. .Sp Changing AutoCommit from off to on should issue a the \f(CWcommit\fR entry elsewhere in this documentin most drivers. .Sp Changing AutoCommit from on to off should have no immediate effect. .Sp For databases which don't support a specific auto-commit mode, the driver has to commit each statement automatically using an explicit \s-1COMMIT\s0 after it completes successfully (and roll it back using an explicit \s-1ROLLBACK\s0 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. .Sp \fB* Database in which a transaction must be explicitly started\fR .Sp For these database the intention is to have them act like databases in which a transaction is always active (as described above). .Sp To do this the \s-1DBI\s0 driver will automatically begin a transaction when AutoCommit is turned off (from the default on state) and will automatically begin another transaction after a the \f(CWcommit\fR entry elsewhere in this documentor the \f(CWrollback\fR entry elsewhere in this document. .Sp In this way, the application does not have to treat these databases as a special case. .Sp See the \f(CWdisconnect\fR entry elsewhere in this documentfor other important notes about transactions. .Ip "\fBDriver\fR (handle)" 4 Holds the handle of the parent Driver. The only recommended use for this is to find the name of the driver using .Sp .Vb 1 \& $dbh->{Driver}->{Name} .Ve .Ip "\fBName\fR (string)" 4 Holds the \*(L'name\*(R' of the database. Usually (and recommended to be) the same as the \*(L"dbi:DriverName:...\*(R" string used to connect to the database but with the leading \*(L"dbi:DriverName:\*(R" removed. .Ip "\fBRowCacheSize\fR (integer) *\s-1NEW\s0*" 4 A hint to the driver indicating the size of local row cache the application would like the driver to use for future select statements. If a row cache is not implemented then setting RowCacheSize is ignored and getting the value returns undef. .Sp Some RowCacheSize values have special meaning: .Sp .Vb 4 \& 0 - Automatically determine a reasonable cache size for each select \& 1 - Disable the local row cache \& >1 - Cache this many rows \& <0 - Cache as many rows fit into this much memory for each select. .Ve Note that large cache sizes may require very large amount of memory (cached rows * maximum size of row) and that a large cache will cause a longer delay for the first fetch and when the cache needs refilling. .Sp See also the \f(CWRowsInCache\fR entry elsewhere in this documentstatement handle attribute. .SH "DBI STATEMENT HANDLE OBJECTS" .Sh "Statement Handle Methods" .Ip "\fBbind_param\fR" 4 .Sp .Vb 3 \& $rc = $sth->bind_param($p_num, $bind_value) || die $sth->errstr; \& $rv = $sth->bind_param($p_num, $bind_value, \e%attr) || ... \& $rv = $sth->bind_param($p_num, $bind_value, $bind_type) || ... .Ve The bind_param method can be used to \fIbind\fR (assign/associate) a value with a \fIplaceholder\fR embedded in the prepared statement. Placeholders are indicated with question mark character (\f(CW?\fR). For example: .Sp .Vb 5 \& $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); .Ve Note that the \f(CW?\fR is not enclosed in quotation marks even when the placeholder represents a string. Some drivers also allow \f(CW:1\fR, \f(CW:2\fR etc and \f(CW:name\fR style placeholders in addition to \f(CW?\fR but their use is not portable. Undefined bind values or \f(CWundef\fR are be used to indicate null values. .Sp Some drivers do not support placeholders. .Sp With most drivers placeholders can't be used for any element of a statement that would prevent the database server validating the statement and creating a query execution plan for it. For example: .Sp .Vb 2 \& "select name, age from ?" # wrong (will probably fail) \& "select name, ? from people" # wrong (but may not 'fail') .Ve Also, placeholders can only represent single scalar values, so this statement, for example, won't work as expected for more than one value: .Sp .Vb 1 \& "select name, age from people where name in (?)" # wrong .Ve \fBData Types for Placeholders\fR .Sp The \f(CW\e%attr\fR parameter can be used to hint at the data type the placeholder should have. Typically the driver is only interested in knowing if the placeholder should be bound as a number or a string. .Sp .Vb 1 \& $sth->bind_param(1, $value, { TYPE => SQL_INTEGER }); .Ve As a short-cut for this common case, the data type can be passed directly inplace of the attr hash reference. This example is equivalent to the one above: .Sp .Vb 1 \& $sth->bind_param(1, $value, SQL_INTEGER); .Ve The \s-1TYPE\s0 value indicates the \fIstandard\fR (non-driver-specific) type for this parameter. To specify the driver-specific type the driver \fImay\fR support a driver-specific attribute, e.g., { ora_type => 97 }. The data type for a placeholder cannot be changed after the first bind_param call (but it can be left unspecified, in which case it defaults to the previous value). .Sp 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. .Sp As an alternative to specifying the data type in the bind_param call, you can let the driver pass the value as the default type (\s-1VARCHAR\s0) then use an \s-1SQL\s0 function to convert the type within the statement. E.g., .Sp .Vb 1 \& insert into price(code, price) values (?, convert(money,?)) .Ve The convert function used here is just an example. The actual function and syntax will vary between different databases (and so is obviously non-portable). .Sp See also the section on \fI/"Placeholders and Bind Values\fR for more information. .Ip "\fBbind_param_inout\fR" 4 .Sp .Vb 3 \& $rc = $sth->bind_param_inout($p_num, \e$bind_value, $max_len) || die $sth->errstr; \& $rv = $sth->bind_param_inout($p_num, \e$bind_value, $max_len, \e%attr) || ... \& $rv = $sth->bind_param_inout($p_num, \e$bind_value, $max_len, $bind_type) || ... .Ve This method acts like the \f(CWbind_param\fR entry elsewhere in this documentbut also enables values to be \fIoutput from\fR (updated by) the statement. The statement is typically a call to a stored procedure. The \f(CW$bind_value\fR must be passed as a \fIreference\fR to the actual value to be used. .Sp Note that unlike the \f(CWbind_param\fR entry elsewhere in this documentthe \f(CW$bind_value\fR variable is \fInot\fR read when bind_param_inout is called. Instead, the value in the variable is read at the time the \f(CWexecute\fR entry elsewhere in this documentis called. .Sp The additional \f(CW$max_len\fR parameter specifies the minimum amount of memory to allocate to \f(CW$bind_value\fR for the new value. If the value is too big to fit then the execute should fail. If unsure what value to use, pick a generous length larger than the longest value that would ever be returned. The only cost of using a very large value is memory. .Sp It is expected that few drivers will support this method. The only driver currently known to do so is \s-1DBD::\s0Oracle (\s-1DBD::ODBC\s0 may support it in a future release). Therefore it should \fInot\fR be used for database independent applications. .Sp Undefined values or \f(CWundef\fR are be used to indicate null values. See also the section on \fI/"Placeholders and Bind Values\fR for more information. .Ip "\fBexecute\fR" 4 .Sp .Vb 2 \& $rv = $sth->execute || die $sth->errstr; \& $rv = $sth->execute(@bind_values) || die $sth->errstr; .Ve Perform whatever processing is necessary to execute the prepared statement. An undef is returned if an error occurs, a successful execute 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 execute (and most other \s-1DBI\s0 methods) for errors. .Sp For a \fInon-select\fR statement, execute returns the number of rows affected (if known). If no rows were affected then execute returns \*(L"0E0\*(R" which Perl will treat as 0 but will regard as true. Note that it is \fInot\fR an error for no rows to be affected by a statement. If the number of rows affected is not known then execute returns \-1. .Sp For \fIselect\fR statements execute simply \*(L'starts\*(R' the query within the Engine. Use one of the fetch methods to retreive the data after calling execute. The execute method does \fInot\fR return the number of rows that will be returned by the query (because most Engines can't tell in advance), it simply returns a true value. .Sp If any arguments are given then execute will effectively call the \f(CWbind_param\fR entry elsewhere in this documentfor each value before executing the statement. Values bound in this way are usually treated as \s-1SQL_VARCHAR\s0 types unless the driver can determine the correct type (which is rare) or bind_param (or bind_param_inout) has already been used to specify the type. .Ip "\fBfetchrow_arrayref\fR" 4 .Sp .Vb 2 \& $ary_ref = $sth->fetchrow_arrayref; \& $ary_ref = $sth->fetch; # alias .Ve Fetches the next row of data and returns a reference to an array holding the field values. Null field values are returned as undef. This is the fastest way to fetch data, particularly if used with \f(CW$sth\fR\->bind_columns. .Sp If there are no more rows \fIor\fR an error occurs then fetchrow_arrayref returns an undef. You should check \f(CW$sth\fR\->err afterwards (or use the RaiseError attribute) to discover if the undef returned was due to an error. .Sp Note that \fIcurrently\fR the \fIsame\fR array ref will be returned for each fetch so don't store the ref and then use it after a later fetch. .Ip "\fBfetchrow_array\fR" 4 .Sp .Vb 1 \& @ary = $sth->fetchrow_array; .Ve An alternative to \f(CWfetchrow_arrayref\fR. Fetches the next row of data and returns it as an array holding the field values. Null values are returned as undef. .Sp If there are no more rows \fIor\fR an error occurs then fetchrow_array returns an empty list. You should check \f(CW$sth\fR\->err afterwards (or use the RaiseError attribute) to discover if the empty list returned was due to an error. .Ip "\fBfetchrow_hashref\fR" 4 .Sp .Vb 2 \& $hash_ref = $sth->fetchrow_hashref; \& $hash_ref = $sth->fetchrow_hashref($name); .Ve An alternative to \f(CWfetchrow_arrayref\fR. Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs. Null values are returned as undef. .Sp If there are no more rows \fIor\fR an error occurs then fetchrow_hashref returns an undef. You should check \f(CW$sth\fR\->err afterwards (or use the RaiseError attribute) to discover if the undef returned was due to an error. .Sp The optional \f(CW$name\fR parameter specifies the name of the statement handle attribute to use to get the field names. It defaults to \*(L'the \f(CWNAME\fR entry elsewhere in this document\*(R'. .Sp The keys of the hash are the same names returned by \f(CW$sth\fR\->{$name}. If more than one field has the same name there will only be one entry in the returned hash for those fields. .Sp Note that using fetchrow_hashref is currently \fInot portable\fR between databases because different databases return fields names with different letter cases (some all uppercase, some all lower, and some return the letter case used to create the table). This will be addressed in a future version of the \s-1DBI\s0. .Sp Because of the extra work fetchrow_hashref and perl have to perform it is not as efficient as fetchrow_arrayref or fetchrow_array and is not recommended where performance is very important. Currently a new hash reference is returned for each row. This is likely to change in the future so don't rely on it. .Ip "\fBfetchall_arrayref\fR" 4 .Sp .Vb 3 \& $tbl_ary_ref = $sth->fetchall_arrayref; \& $tbl_ary_ref = $sth->fetchall_arrayref( $slice_array_ref ); \& $tbl_ary_ref = $sth->fetchall_arrayref( $slice_hash_ref ); .Ve The \f(CWfetchall_arrayref\fR 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 which contains one reference per row. .Sp If there are no rows to return, fetchall_arrayref returns a reference to an empty array. If an error occurs fetchall_arrayref returns the data fetched thus far, which may be none. You should check \f(CW$sth\fR\->err afterwards (or use the RaiseError attribute) to discover if the data is complete or was truncated due to an error. .Sp When passed an array reference, fetchall_arrayref uses the \f(CWfetchrow_arrayref\fR entry elsewhere in this documentto fetch each row as an array ref. If the parameter array is not empty then it is used as a slice to select individual columns by index number. .Sp With no parameters, fetchall_arrayref acts as if passed an empty array ref. .Sp When passed a hash reference, fetchall_arrayref uses the \f(CWfetchrow_hashref\fR entry elsewhere in this documentto fetch each row as a hash ref. If the parameter hash is not empty then it is used as a slice to select individual columns by name. The names should be lower case regardless of the letter case in \f(CW$sth\fR\->{\s-1NAME\s0}. The values of the hash should be set to 1. .Sp For example, to fetch just the first column of every row you can use: .Sp .Vb 1 \& $tbl_ary_ref = $sth->fetchall_arrayref([0]); .Ve To fetch the second to last and last column of every row you can use: .Sp .Vb 1 \& $tbl_ary_ref = $sth->fetchall_arrayref([-2,-1]); .Ve To fetch only the fields called foo and bar of every row you can use: .Sp .Vb 1 \& $tbl_ary_ref = $sth->fetchall_arrayref({ foo=>1, bar=>1 }); .Ve The first two examples return a ref to an array of array refs. The last returns a ref to an array of hash refs. .Ip "\fBfinish\fR" 4 .Sp .Vb 1 \& $rc = $sth->finish; .Ve Indicates that no more data will be fetched from this statement handle before it is either executed again or destroyed. \fIIt is rarely needed\fR but can sometimes be helpful in very specific situations in order to allow the server to free up resources currently being held (such as sort buffers). .Sp When all the data has been fetched from a select statement the driver should automatically call finish for you. So you should not normally need to call it explicitly. .Sp Consider a query like .Sp .Vb 1 \& SELECT foo FROM table WHERE bar=? ORDER BY foo .Ve where you want to select just the first (smallest) foo value from 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 one row, the handle won't be re-executed for some time and won't be destroyed, the finish method can be used to tell the server that the buffer space can be freed. .Sp Calling finish resets the the \f(CWActive\fR entry elsewhere in this documentattribute for the statement. It may also make some statement handle attributes, like \s-1NAME\s0 and \s-1TYPE\s0 etc., unavailable if they have not already been accessed (and thus cached). .Sp The finish method does not affect the transaction status of the session. It has nothing to do with transactions. It's mostly an internal \*(L'housekeeping\*(R' method that is rarely needed. There's no need to call finish if you're about to destroy or re-execute the statement handle. See also the \f(CWdisconnect\fR entry elsewhere in this document and the the \f(CWActive\fR entry elsewhere in this documentattribute. .Ip "\fBrows\fR" 4 .Sp .Vb 1 \& $rv = $sth->rows; .Ve Returns the number of rows affected by the last row affecting command, or \-1 if not known or not available. .Sp Generally you can only rely on a row count after a \fInon\fR\-select \f(CWexecute\fR (for some specific operations like update and delete) or after fetching \fIall\fR the rows of a select statement. .Sp For select statements it is generally not possible to know how many rows will be returned except by fetching them all. Some drivers will return the number of rows the application has fetched \fIso far\fR but others may return \-1 until all rows have been fetched. So, use of the rows method, or \f(CW$DBI::rows\fR, with select statements is \fInot\fR recommended. .Ip "\fBbind_col\fR" 4 .Sp .Vb 1 \& $rc = $sth->bind_col($column_number, \e$var_to_bind); .Ve Binds an output column (field) of a select statement to a perl variable. You do not need to do this but it can be useful for some applications. .Sp Whenever a row is fetched from the database the corresponding perl variable is automatically updated. There is no need to fetch and assign the values manually. This makes using bound variables very efficient. See bind_columns below for an example. Note that column numbers count up from 1. .Sp The binding is performed at a very low level using perl aliasing so there is no extra copying taking place. So long as the driver uses the correct internal \s-1DBI\s0 call to get the array the fetch function returns, it will automatically support column binding. .Sp For maximum portability between drivers, bind_col should be called after execute. .Sp The the \f(CWbind_param\fR entry elsewhere in this documentmethod performs a similar function for input variables. .Ip "\fBbind_columns\fR" 4 .Sp .Vb 1 \& $rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind); .Ve Calls the \f(CWbind_col\fR entry elsewhere in this documentfor each column of the select statement. You do not need to bind columns but it can be useful for some applications. The bind_columns method will die if the number of references does not match the number of fields. .Sp For maximum portability between drivers, bind_columns should be called after execute. .Sp For example: .Sp .Vb 4 \& $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); .Ve .Vb 2 \& # Bind perl variables to columns: \& $rv = $sth->bind_columns(\e$region, \e$sales); .Ve .Vb 2 \& # you can also use perl's \e(...) syntax (see perlref docs): \& # $sth->bind_columns(\e($region, $sales)); .Ve .Vb 4 \& # Column binding is the most efficient way to fetch data \& while ($sth->fetch) { \& print "$region: $sales\en"; \& } .Ve For compatibility with old scripts, if the first parameter is undef or a hash reference it will be ignored. .Ip "\fBdump_results\fR" 4 .Sp .Vb 1 \& $rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh); .Ve Fetches all the rows from \f(CW$sth\fR, calls \s-1DBI::\s0neat_list for each row and prints the results to \f(CW$fh\fR (defaults to \f(CWSTDOUT\fR) separated by \f(CW$lsep\fR (default \f(CW"\en"\fR). \f(CW$fsep\fR defaults to \f(CW", "\fR and \f(CW$maxlen\fR defaults to 35. .Sp This method is designed as a handy utility for prototyping and testing queries. Since it uses the \f(CWneat_list\fR entry elsewhere in this documentwhich uses the \f(CWneat\fR entry elsewhere in this documentwhich formats and edits the string for reading by humans, it's not recomended for data transfer applications. .Sh "Statement Handle Attributes" This section describes attributes specific to statement handles. Most of these attributes are read-only. .PP Changes to these statement handle attributes do not affect any other existing or future statement handles. .PP Attempting to set or get the value of an unknown attribute is fatal, except for private driver specific attributes (which all have names starting with a lowercase letter). .PP Example: .PP .Vb 1 \& ... = $h->{NUM_OF_FIELDS}; # get/read .Ve Note that some drivers cannot provide valid values for some or all of these attributes until after \f(CW$sth\fR\->execute has been called. .PP See also the \f(CWfinish\fR entry elsewhere in this documentfor the effect it may have on some attributes. .Ip "\fB\s-1NUM_OF_FIELDS\s0\fR (integer, read-only)" 4 Number of fields (columns) the prepared statement will return. Non-select statements will have \s-1NUM_OF_FIELDS\s0 == 0. .Ip "\fB\s-1NUM_OF_PARAMS\s0\fR (integer, read-only)" 4 The number of parameters (placeholders) in the prepared statement. See \s-1SUBSTITUTION\s0 \s-1VARIABLES\s0 below for more details. .Ip "\fB\s-1NAME\s0\fR (array-ref, read-only)" 4 Returns a \fIreference\fR 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 the \f(CWNAME_lc\fR entry elsewhere in this documentor the \f(CWNAME_uc\fR entry elsewhere in this document. .Sp .Vb 1 \& print "First column name: $sth->{NAME}->[0]\en"; .Ve .Ip "\fBNAME_lc\fR (array-ref, read-only)" 4 Like the \f(CWNAME\fR entry elsewhere in this documentbut always returns lowercase names. .Ip "\fBNAME_uc\fR (array-ref, read-only)" 4 Like the \f(CWNAME\fR entry elsewhere in this documentbut always returns uppercase names. .Ip "\fB\s-1TYPE\s0\fR (array-ref, read-only) *\s-1NEW\s0*" 4 Returns a \fIreference\fR to an array of integer values for each column. The value indicates the data type of the corresponding column. .Sp The values used correspond to the international standards (\s-1ANSI\s0 X3.135 and \s-1ISO/IEC\s0 9075) which, in general terms, means \s-1ODBC\s0. Driver specific types which don't exactly match standard types should generally return the same values as an \s-1ODBC\s0 driver supplied by the makers of the database. That might include private type numbers in ranges the vendor has officially registered. See: .Sp .Vb 1 \& ftp://jerry.ece.umassd.edu/isowg3/dbl/SQL_Registry .Ve Where there's no vendor supplied \s-1ODBC\s0 driver to be compatible with, the \s-1DBI\s0 driver can use type numbers in the range now \fIofficially\fR reserved for use by the \s-1DBI\s0: \-9999 to \-9000. .Sp All possible values for \s-1TYPE\s0 should have at least one entry in the output of the \f(CWtype_info_all()\fR method (see the \f(CWtype_info_all\fR entry elsewhere in this document). .Ip "\fB\s-1PRECISION\s0\fR (array-ref, read-only) *\s-1NEW\s0*" 4 Returns a \fIreference\fR to an array of integer values for each column. For nonnumeric columns the value generally refers to either the maximum length or the defined length of the column. For numeric columns the value refers to the maximum number of significant digits used by the data type (without considering a sign character or decimal point). Note that for floating point types (\s-1REAL\s0, \s-1FLOAT\s0, \s-1DOUBLE\s0) the \&'display size\*(R' can be up to 7 characters greater than the precision (for the sign + decimal point + the letter E + a sign + 2 or 3 digits). .Ip "\fB\s-1SCALE\s0\fR (array-ref, read-only) *\s-1NEW\s0*" 4 Returns a \fIreference\fR to an array of integer values for each column. \s-1NULL\s0 (undef) values indicate columns where scale is not applicable. .Ip "\fB\s-1NULLABLE\s0\fR (array-ref, read-only)" 4 Returns a \fIreference\fR to an array indicating the possibility of each column returning a null: 0 = no, 1 = yes, 2 = unknown. .Sp .Vb 1 \& print "First column may return NULL\en" if $sth->{NULLABLE}->[0]; .Ve .Ip "\fBCursorName\fR (string, read-only)" 4 Returns the name of the cursor associated with the statement handle if available. If not available or the database driver does not support the \f(CW"where current of ..."\fR \s-1SQL\s0 syntax then it returns undef. .Ip "\fBStatement\fR (string, read-only) *\s-1NEW\s0*" 4 Returns the statement string passed to the the \f(CWprepare\fR entry elsewhere in this documentmethod. .Ip "\fBRowsInCache\fR (integer, read-only) *\s-1NEW\s0*" 4 If the driver supports a local row cache for select statements then this attribute holds the number of un-fetched rows in the cache. If the driver doesn't, then it returns undef. Note that some drivers pre-fetch rows on execute, others wait till the first fetch. .Sp See also the the \f(CWRowCacheSize\fR entry elsewhere in this documentdatabase handle attribute. .SH "FURTHER INFORMATION" .Sh "Transactions" 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. .PP This section applies to databases which support transactions and where AutoCommit is \fIoff\fR. See the \f(CWAutoCommit\fR entry elsewhere in this documentfor details of using AutoCommit with various types of database. .PP The recommended way to implement robust transactions in Perl applications is to make use of \f(CWeval { ... }\fR (which is very fast, unlike \f(CWeval "..."\fR). .PP .Vb 13 \& eval { \& foo(...) # do lots of work here \& bar(...) # including inserts \& baz(...) # and updates \& }; \& if ($@) { \& # $@ contains $DBI::errstr if DBI RaiseError caused die \& $dbh->rollback; \& # add other application on-error-clean-up code here \& } \& else { \& $dbh->commit; \& } .Ve The code in \fIfoo()\fR, or any other code executed from within the curly braces, can be implemented in this way: .PP .Vb 1 \& $h->method(@args) || die $h->errstr .Ve or the \f(CW$h\fR\->{RaiseError} attribute can be set on. With RaiseError set the \s-1DBI\s0 will automatically die if any \s-1DBI\s0 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 the \f(CWRaiseError\fR entry elsewhere in this documentfor more details. .PP A major advantage of the eval approach is that the transaction will be properly rolled back if \fIany\fR code in the inner application dies for \fIany\fR reason. The major advantage of using the \f(CW$h\fR\->{RaiseError} attribute is that all \s-1DBI\s0 calls will be checked automatically. Both techniques are strongly recommended. .Sh "Handling \s-1BLOB\s0 / \s-1LONG\s0 / Memo Fields" Many databases support \*(L'blob\*(R' (binary large objects), \*(L'long\*(R' 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. .PP 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 select statement (unlike other data types) some special handling is required. .PP In this situation the value of the \f(CW$h\fR\->{LongReadLen} attribute is used to determine how much buffer space to allocate when \fIfetching\fR such fields. The \f(CW$h\fR\->{LongTruncOk} attribute is used to determine how to behave if a fetched value can't fit into the buffer. .PP When trying to insert long or binary values, placeholders should be used since there are often limits on the maximum size of an (insert) statement and the the \f(CWquote\fR entry elsewhere in this documentmethod generally can't cope with binary data. See the section on \fI/Placeholders and Bind Values\fR. .Sh "Simple Examples" Here's a complete example program to select and fetch some data: .PP .Vb 2 \& my $dbh = DBI->connect("dbi:DriverName:db_name", $user, $password) \& || die "Can't connect to $data_source: $DBI::errstr"; .Ve .Vb 4 \& my $sth = $dbh->prepare( q{ \& SELECT name, phone \& FROM mytelbook \& }) || die "Can't prepare statement: $DBI::errstr"; .Ve .Vb 2 \& my $rc = $sth->execute \& || die "Can't execute statement: $DBI::errstr"; .Ve .Vb 2 \& print "Query will return $sth->{NUM_OF_FIELDS} fields.\en\en"; \& print "Field names: @{ $sth->{NAME} }\en"; .Ve .Vb 5 \& while (($name, $phone) = $sth->fetchrow_array) { \& print "$name: $phone\en"; \& } \& # check for problems which may have terminated the fetch early \& die $sth->errstr if $sth->err; .Ve .Vb 1 \& $dbh->disconnect; .Ve Here's a complete example program to insert some data from a file: (this example uses RaiseError to avoid needing to check each call) .PP .Vb 3 \& my $dbh = DBI->connect("dbi:DriverName:db_name", $user, $password, { \& RaiseError => 1, AutoCommit => 0 \& }); .Ve .Vb 3 \& my $sth = $dbh->prepare( q{ \& INSERT INTO table (name, phone) VALUES (?, ?) \& }); .Ve .Vb 7 \& open FH, "<phone.csv" or die "Unable to open phone.csv: $!"; \& while (<FH>) { \& chop; \& my ($name, $phone) = split /,/; \& $sth->execute($name, $phone); \& } \& close FH; .Ve .Vb 2 \& $dbh->commit; \& $dbh->disconnect; .Ve Converting fetched NULLs (undefined values) to empty strings: .PP .Vb 5 \& while($row = $sth->fetchrow_arrayref) { \& # this is a fast and simple way to deal with nulls: \& foreach (@$row) { $_ = '' unless defined } \& print "@$row\en"; \& } .Ve The \f(CWq{...}\fR style quoting used in these example avoids clashing with quotes that may be used in the \s-1SQL\s0 statement. Use the double-quote like \f(CWqq{...}\fR operator if you want to interpolate variables into the string. See the section on \fIQuote and Quote-like Operators\fR in the \fIperlop\fR manpage for more details. .Sh "Threads and Thread Safety" Perl versions 5.004_50 and later support threads on many platforms. The \s-1DBI\s0 should build on these platforms but currently has made \fIno\fR attempt to be thread safe. .Sh "Signal Handling and Canceling Operations" The first thing to say is that signal handling in Perl is currently \fInot\fR safe. There is \fIalways\fR a small risk of Perl crashing and/or core dumping when, or after, handling a signal. (The risk was reduced with 5.004_04 but is still present.) .PP The two most common uses of signals in relation to the \s-1DBI\s0 are for canceling operations when the user types Ctrl-C (interrupt), and for implementing a timeout using \fIalarm()\fR and \f(CW$SIG\fR{\s-1ALRM\s0}. .PP To assist in implementing these operations the \s-1DBI\s0 provides a \f(CWcancel\fR method for statement handles. The cancel method should abort the current operation and is designed to be called from a signal handler. .PP However, it must be stressed that: a) few drivers implement this at the moment (the \s-1DBI\s0 provides a default method that just returns undef), b) even if implemented there is still a possibility that the statement handle, and possibly the parent database handle, will not be usable afterwards. .PP If cancel returns true then it is implemented and has successfully invoked the database engine's own cancel function. If it returns false then cancel failed (undef if not implemented). .SH "DEBUGGING" In addition to the the \f(CWtrace\fR entry elsewhere in this documentmethod you can enable the same trace information by setting the DBI_TRACE environment variable before starting perl. .PP On unix-like systems using a bourne-like shell you can do this easily for a single command: .PP .Vb 1 \& DBI_TRACE=2 perl your_test_script.pl .Ve If DBI_TRACE is set to a non-numeric value then it is assumed to be a file name and the trace level will be set to 2 with all trace output will be appended to that file. If the name beings with a number followed by an equals (\f(CW=\fR) then they are stripped off from the name and the number is used to set the trace level. For example: .PP .Vb 1 \& DBI_TRACE=3=dbitrace.log perl your_test_script.pl .Ve See also the the \f(CWtrace\fR entry elsewhere in this documentmethod. .SH "WARNING AND ERROR MESSAGES" (This section needs more words about causes and remedies.) .Sh "Fatal Errors" .Ip "Can't call method \*(N"prepare\*(T" without a package or object reference" 4 The \f(CW$dbh\fR handle you're using to call prepare is probably undefined because the preceeding connect failed. You should always check the return status of \s-1DBI\s0 methods, or use the the \f(CWRaiseError\fR entry elsewhere in this documentattribute. .Ip "Can't call method \*(N"execute\*(T" without a package or object reference" 4 The \f(CW$sth\fR handle you're using to call execute is probably undefined because the preceeding prepare failed. You should always check the return status of \s-1DBI\s0 methods, or use the the \f(CWRaiseError\fR entry elsewhere in this documentattribute. .Ip "\s-1DBI/DBD\s0 internal version mismatch" 4 .Ip "\s-1DBD\s0 driver has not implemented the AutoCommit attribute" 4 .Ip "Can't [sg]et %s->{%s}: unrecognised attribute" 4 .Sh "Warnings" .Ip "Database handle destroyed without explicit disconnect" 4 .Ip "\s-1DBI\s0 Handle cleared whilst still holding %d cached kids!" 4 .Ip "\s-1DBI\s0 Handle cleared whilst still active!" 4 .Ip "\s-1DBI\s0 Handle has uncleared implementors data" 4 .Ip "\s-1DBI\s0 Handle has %d uncleared child handles" 4 .SH "SEE ALSO" .Sh "Database Documentation" \s-1SQL\s0 Language Reference Manual. .Sh "Books and Journals" .PP .Vb 2 \& Programming the Perl DBI, by Alligator Descartes and Tim Bunce. \& Due to be published by O'Reilly September/October 1999. .Ve .Vb 2 \& Programming Perl 2nd Ed. by Larry Wall, Tom Christiansen & Randal Schwartz. \& Learning Perl by Randal Schwartz. .Ve .Vb 2 \& Dr Dobb's Journal, November 1996. \& The Perl Journal, April 1997. .Ve .Sh "Manual Pages" the \fIperl(1)\fR manpage, the \fIperlmod(1)\fR manpage, the \fIperlbook(1)\fR manpage .Sh "Mailing List" The dbi-users mailing list is the primary means of communication among users of the \s-1DBI\s0 and its related modules. Subscribe and unsubscribe via: .PP .Vb 1 \& http://www.isc.org/dbi-lists.html .Ve Mailing list archives are held at: .PP .Vb 4 \& http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest/ \& http://www.xray.mpe.mpg.de/mailing-lists/#dbi \& http://outside.organic.com/mail-archives/dbi-users/ \& http://www.coe.missouri.edu/~faq/lists/dbi.html .Ve .Sh "Assorted Related \s-1WWW\s0 Links" The \s-1DBI\s0 \*(L'Home Page\*(R' (not maintained by me): .PP .Vb 1 \& http://www.symbolstone.org/technology/perl/DBI .Ve Other \s-1DBI\s0 related links: .PP .Vb 5 \& http://eskimo.tamu.edu/~jbaker/dbi-examples.html \& 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 .Ve Other database related links: .PP .Vb 2 \& http://www.jcc.com/sql_stnd.html \& http://cuiwww.unige.ch/OSG/info/FreeDB/FreeDB.home.html .Ve Commercial and Data Warehouse Links .PP .Vb 6 \& http://www.datamining.org \& http://www.olapcouncil.org \& http://www.idwa.org \& http://www.knowledgecenters.org/dwcenter.asp \& http://pwp.starnetinc.com/larryg/ \& http://www.data-warehouse. .Ve Recommended Perl Programming Links .PP .Vb 1 \& http://language.perl.com/style/ .Ve .Sh "\s-1FAQ\s0" Please also read the \s-1DBI\s0 \s-1FAQ\s0 which is installed as a \s-1DBI::FAQ\s0 module so you can use perldoc to read it by executing the \f(CWperldoc DBI::FAQ\fR command. .SH "AUTHORS" DBI by Tim Bunce. This pod text by Tim Bunce, J. Douglas Dunlop, Jonathan Leffler and others. Perl by Larry Wall and the perl5-porters. .SH "COPYRIGHT" The DBI module is Copyright (c) 1995-1999 Tim Bunce. England. All rights reserved. .PP You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. .SH "ACKNOWLEDGEMENTS" 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. .SH "TRANSLATIONS" A German translation of this manual and other Perl module docs (all probably slightly out of date) is available, thanks to O'Reilly, at: .PP .Vb 1 \& http://www.oreilly.de/catalog/perlmodger/manpages.html .Ve Some other translations: .PP .Vb 2 \& http://cronopio.net/perl/ - Spanish \& http://member.nifty.ne.jp/hippo2000/dbimemo.htm - Japanese .Ve .SH "SUPPORT / WARRANTY" The DBI is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. .PP Commercial support for Perl and the DBI, DBD::Oracle and Oraperl modules can be arranged via The Perl Clinic. See http://www.perlclinic.com for more details. .SH "TRAINING" References to DBI related training resources. No recommendation implied. .PP .Vb 2 \& http://www.treepax.co.uk \& http://www.keller.com/dbweb .Ve .SH "OUTSTANDING ISSUES TO DO" .PP .Vb 7 \& data types (ISO type numbers and type name conversions) \& error handling \& data dictionary methods \& test harness support methods \& portability \& blob_read \& etc .Ve .SH "FREQUENTLY ASKED QUESTIONS" See the DBI FAQ for a more comprehensive list of FAQs. Use the \f(CWperldoc DBI::FAQ\fR command to read it. .Sh "How fast is the \s-1DBI\s0?" To measure the speed of the \s-1DBI\s0 and \s-1DBD::\s0Oracle code I modified \s-1DBD::\s0Oracle such that you can set an attribute which will cause the same row to be fetched from the row cache over and over again (without involving Oracle code but exercising *all* the \s-1DBI\s0 and \s-1DBD::\s0Oracle code in the code path for a fetch). .PP The results (on my lightly loaded old Sparc 10) fetching 50000 rows using: .PP .Vb 1 \& 1 while $csr->fetch; .Ve were: one field: 5300 fetches per cpu second (approx) ten fields: 4000 fetches per cpu second (approx) .PP Obviously results will vary between platforms (newer faster platforms can reach around 50000 fetches per second) but it does give a feel for the maximum performance: fast. By way of comparison, using the code: .PP .Vb 1 \& 1 while @row = $csr->fetchrow_array; .Ve (fetchrow_array is roughly the same as ora_fetch) gives: .PP .Vb 2 \& one field: 3100 fetches per cpu second (approx) \& ten fields: 1000 fetches per cpu second (approx) .Ve Notice the slowdown and the more dramatic impact of extra fields. (The fields were all one char long. The impact would be even bigger for longer strings.) .PP Changing that slightly to represent actually _doing_ something in perl with the fetched data: .PP .Vb 3 \& while(@row = $csr->fetchrow_array) { \& $hash{++$i} = [ @row ]; \& } .Ve gives: ten fields: 500 fetches per cpu second (approx) .PP That simple addition has *halved* the performance. .PP I therefore conclude that \s-1DBI\s0 and \s-1DBD::\s0Oracle overheads are small compared with Perl language overheads (and probably database overheads). .PP So, if you think the \s-1DBI\s0 or your driver is slow, try replacing your fetch loop with just: .PP .Vb 1 \& 1 while $csr->fetch; .Ve and time that. If that helps then point the finger at your own code. If that doesn't help much then point the finger at the database, the platform, the network etc. But think carefully before pointing it at the \s-1DBI\s0 or your driver. .PP (Having said all that, if anyone can show me how to make the \s-1DBI\s0 or drivers even more efficient, I'm all ears.) .Sh "Why doesn't my \s-1CGI\s0 script work right?" Read the information in the references below. Please do \fInot\fR post \s-1CGI\s0 related questions to the dbi-users mailing list (or to me). .PP .Vb 6 \& http://www.perl.com/perl/faq/idiots-guide.html \& http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml \& http://www.perl.com/perl/faq/perl-cgi-faq.html \& http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html \& http://www.boutell.com/faq/ \& http://www.perl.com/perl/faq/ .Ve Using Apache and mod_perl? .PP .Vb 1 \& http://perl.apache.org/guide/ .Ve General problems and good ideas: .PP .Vb 2 \& Use the CGI::ErrorWrap module. \& Remember that many env vars won't be set for CGI scripts .Ve .Sh "How can I maintain a \s-1WWW\s0 connection to a database?" For information on the Apache httpd server and the mod_perl module see .PP .Vb 1 \& http://perl.apache.org/ .Ve .Sh "What about \s-1ODBC\s0?" A \s-1DBD::ODBC\s0 module is available. .Sh "Does the \s-1DBI\s0 have a year 2000 problem?" No. The \s-1DBI\s0 has no knowledge or understanding of dates at all. .PP Individual drivers (\s-1DBD\s0::*) may have some date handling code but are unlikely to have year 2000 related problems within their code. However, your application code which \fIuses\fR the \s-1DBI\s0 and \s-1DBD\s0 drivers may have year 2000 related problems if it has not been designed and written well. .PP See also the \*(L"Does Perl have a year 2000 problem?\*(R" section of the Perl \s-1FAQ\s0: .PP .Vb 1 \& http://www.perl.com/CPAN/doc/FAQs/FAQ/PerlFAQ.html .Ve .SH "OTHER RELATED WORK AND PERL MODULES" .Ip "Apache::\s-1DBI\s0 by E.Mergl@bawue.de" 4 To be used with the Apache daemon together with an embedded perl interpreter like mod_perl. Establishes a database connection which remains open for the lifetime of the http daemon. This way the \s-1CGI\s0 connect and disconnect for every database access becomes superfluous. .Ip "\s-1JDBC\s0 Server by Stuart \*(N'Zen\*(T' Bishop <zen@bf.rmit.edu.au>" 4 The server is written in Perl. The client classes that talk to it are of course in Java. Thus, a Java applet or application will be able to comunicate via the \s-1JDBC\s0 \s-1API\s0 with any database that has a \s-1DBI\s0 driver installed. The \s-1URL\s0 used is in the form jdbc:dbi://host.domain.etc:999/Driver/DBName. It seems to be very similar to some commercial products, such as jdbcKona. .Ip "Remote Proxy \s-1DBD\s0 support" 4 As of \s-1DBI\s0 1.02, a complete implementation of a \s-1DBD::\s0Proxy driver and the \s-1DBI::\s0ProxyServer are part of the \s-1DBI\s0 distribution. .Ip "\s-1SQL\s0 Parser" 4 .Sp .Vb 2 \& Hugo van der Sanden <hv@crypt.compulink.co.uk> \& Stephen Zander <stephen.zander@mckesson.com> .Ve Based on the O'Reilly lex/yacc book examples and byacc. .Sp See also the \s-1SQL::\s0Statement module, a very simple \s-1SQL\s0 parser and engine, base of the \s-1DBD::CSV\s0 driver. .rn }` '' .IX Title "DBI 3" .IX Name "DBI - Database independent interface for Perl" .IX Header "NAME" .IX Header "SYNOPSIS" .IX Subsection "\s-1NOTE\s0" .IX Subsection "\s-1RECENT\s0 \s-1CHANGES\s0 " .IX Item "Between \s-1DBI\s0 1.00 and \s-1DBI\s0 1.09" .IX Header "DESCRIPTION" .IX Subsection "Architecture of a \s-1DBI\s0 Application" .IX Subsection "Notation and Conventions" .IX Subsection "Outline Usage" .IX Subsection "General Interface Rules & Caveats" .IX Subsection "Naming Conventions and Name Space" .IX Subsection "Placeholders and Bind Values" .IX Subsection "\s-1SQL\s0 \- A Query Language" .IX Header "THE DBI CLASS" .IX Subsection "\s-1DBI\s0 Class Methods" .IX Item "\fBconnect\fR" .IX Item "\fBconnect_cached\fR *\s-1NEW\s0*" .IX Item "\fBavailable_drivers\fR" .IX Item "\fBdata_sources\fR" .IX Item "\fBtrace\fR" .IX Subsection "\s-1DBI\s0 Utility Functions" .IX Item "\fBneat\fR" .IX Item "\fBneat_list\fR" .IX Item "\fBlooks_like_number\fR" .IX Subsection "\s-1DBI\s0 Dynamic Attributes" .IX Item "\fB$\s-1DBI::\s0err\fR" .IX Item "\fB$\s-1DBI::\s0errstr\fR" .IX Item "\fB$\s-1DBI::\s0state\fR" .IX Item "\fB$\s-1DBI::\s0rows\fR" .IX Header "METHODS COMMON TO ALL HANDLES" .IX Item "\fBerr\fR" .IX Item "\fBerrstr\fR" .IX Item "\fBstate\fR" .IX Item "\fBtrace\fR" .IX Item "\fBtrace_msg\fR" .IX Item "\fBfunc\fR" .IX Header "ATTRIBUTES COMMON TO ALL HANDLES" .IX Item "\fBWarn\fR (boolean, inherited)" .IX Item "\fBActive\fR (boolean, read-only)" .IX Item "\fBKids\fR (integer, read-only)" .IX Item "\fBActiveKids\fR (integer, read-only)" .IX Item "\fBCachedKids\fR (hash ref)" .IX Item "\fBCompatMode\fR (boolean, inherited)" .IX Item "\fBInactiveDestroy\fR (boolean)" .IX Item "\fBPrintError\fR (boolean, inherited)" .IX Item "\fBRaiseError\fR (boolean, inherited)" .IX Item "\fBChopBlanks\fR (boolean, inherited)" .IX Item "\fBLongReadLen\fR (unsigned integer, inherited)" .IX Item "\fBLongTruncOk\fR (boolean, inherited)" .IX Item "\fBTaint\fR (boolean, inherited)" .IX Item "\fBprivate_*\fR" .IX Header "DBI DATABASE HANDLE OBJECTS" .IX Subsection "Database Handle Methods" .IX Item "\fBselectrow_array\fR" .IX Item "\fBselectall_arrayref\fR" .IX Item "\fBselectcol_arrayref\fR" .IX Item "\fBprepare\fR" .IX Item "\fBprepare_cached\fR" .IX Item "\fBdo\fR" .IX Item "\fBcommit\fR" .IX Item "\fBrollback\fR" .IX Item "\fBdisconnect\fR" .IX Item "\fBping\fR" .IX Item "\fBtable_info\fR *\s-1NEW\s0*" .IX Item "\fBtables\fR *\s-1NEW\s0*" .IX Item "\fBtype_info_all\fR *\s-1NEW\s0*" .IX Item "\fBtype_info\fR *\s-1NEW\s0*" .IX Item "\s-1TYPE_NAME\s0 (string)" .IX Item "\s-1DATA_TYPE\s0 (integer)" .IX Item "\s-1COLUMN_SIZE\s0 (integer)" .IX Item "\s-1LITERAL_PREFIX\s0 (string)" .IX Item "\s-1LITERAL_SUFFIX\s0 (string)" .IX Item "\s-1CREATE_PARAMS\s0 (string)" .IX Item "\s-1NULLABLE\s0 (integer)" .IX Item "\s-1CASE_SENSITIVE\s0 (boolean)" .IX Item "\s-1SEARCHABLE\s0 (integer)" .IX Item "\s-1UNSIGNED_ATTRIBUTE\s0 (boolean)" .IX Item "\s-1FIXED_PREC_SCALE\s0 (boolean)" .IX Item "\s-1AUTO_UNIQUE_VALUE\s0 (boolean)" .IX Item "\s-1LOCAL_TYPE_NAME\s0 (string)" .IX Item "\s-1MINIMUM_SCALE\s0 (integer)" .IX Item "\s-1MAXIMUM_SCALE\s0 (integer)" .IX Item "\s-1NUM_PREC_RADIX\s0 (integer)" .IX Item "\fBquote\fR" .IX Subsection "Database Handle Attributes" .IX Item "\fBAutoCommit\fR (boolean)" .IX Item "\fBDriver\fR (handle)" .IX Item "\fBName\fR (string)" .IX Item "\fBRowCacheSize\fR (integer) *\s-1NEW\s0*" .IX Header "DBI STATEMENT HANDLE OBJECTS" .IX Subsection "Statement Handle Methods" .IX Item "\fBbind_param\fR" .IX Item "\fBbind_param_inout\fR" .IX Item "\fBexecute\fR" .IX Item "\fBfetchrow_arrayref\fR" .IX Item "\fBfetchrow_array\fR" .IX Item "\fBfetchrow_hashref\fR" .IX Item "\fBfetchall_arrayref\fR" .IX Item "\fBfinish\fR" .IX Item "\fBrows\fR" .IX Item "\fBbind_col\fR" .IX Item "\fBbind_columns\fR" .IX Item "\fBdump_results\fR" .IX Subsection "Statement Handle Attributes" .IX Item "\fB\s-1NUM_OF_FIELDS\s0\fR (integer, read-only)" .IX Item "\fB\s-1NUM_OF_PARAMS\s0\fR (integer, read-only)" .IX Item "\fB\s-1NAME\s0\fR (array-ref, read-only)" .IX Item "\fBNAME_lc\fR (array-ref, read-only)" .IX Item "\fBNAME_uc\fR (array-ref, read-only)" .IX Item "\fB\s-1TYPE\s0\fR (array-ref, read-only) *\s-1NEW\s0*" .IX Item "\fB\s-1PRECISION\s0\fR (array-ref, read-only) *\s-1NEW\s0*" .IX Item "\fB\s-1SCALE\s0\fR (array-ref, read-only) *\s-1NEW\s0*" .IX Item "\fB\s-1NULLABLE\s0\fR (array-ref, read-only)" .IX Item "\fBCursorName\fR (string, read-only)" .IX Item "\fBStatement\fR (string, read-only) *\s-1NEW\s0*" .IX Item "\fBRowsInCache\fR (integer, read-only) *\s-1NEW\s0*" .IX Header "FURTHER INFORMATION" .IX Subsection "Transactions" .IX Subsection "Handling \s-1BLOB\s0 / \s-1LONG\s0 / Memo Fields" .IX Subsection "Simple Examples" .IX Subsection "Threads and Thread Safety" .IX Subsection "Signal Handling and Canceling Operations" .IX Header "DEBUGGING" .IX Header "WARNING AND ERROR MESSAGES" .IX Subsection "Fatal Errors" .IX Item "Can't call method \*(N"prepare\*(T" without a package or object reference" .IX Item "Can't call method \*(N"execute\*(T" without a package or object reference" .IX Item "\s-1DBI/DBD\s0 internal version mismatch" .IX Item "\s-1DBD\s0 driver has not implemented the AutoCommit attribute" .IX Item "Can't [sg]et %s->{%s}: unrecognised attribute" .IX Subsection "Warnings" .IX Item "Database handle destroyed without explicit disconnect" .IX Item "\s-1DBI\s0 Handle cleared whilst still holding %d cached kids!" .IX Item "\s-1DBI\s0 Handle cleared whilst still active!" .IX Item "\s-1DBI\s0 Handle has uncleared implementors data" .IX Item "\s-1DBI\s0 Handle has %d uncleared child handles" .IX Header "SEE ALSO" .IX Subsection "Database Documentation" .IX Subsection "Books and Journals" .IX Subsection "Manual Pages" .IX Subsection "Mailing List" .IX Subsection "Assorted Related \s-1WWW\s0 Links" .IX Subsection "\s-1FAQ\s0" .IX Header "AUTHORS" .IX Header "COPYRIGHT" .IX Header "ACKNOWLEDGEMENTS" .IX Header "TRANSLATIONS" .IX Header "SUPPORT / WARRANTY" .IX Header "TRAINING" .IX Header "OUTSTANDING ISSUES TO DO" .IX Header "FREQUENTLY ASKED QUESTIONS" .IX Subsection "How fast is the \s-1DBI\s0?" .IX Subsection "Why doesn't my \s-1CGI\s0 script work right?" .IX Subsection "How can I maintain a \s-1WWW\s0 connection to a database?" .IX Subsection "What about \s-1ODBC\s0?" .IX Subsection "Does the \s-1DBI\s0 have a year 2000 problem?" .IX Header "OTHER RELATED WORK AND PERL MODULES" .IX Item "Apache::\s-1DBI\s0 by E.Mergl@bawue.de" .IX Item "\s-1JDBC\s0 Server by Stuart \*(N'Zen\*(T' Bishop <zen@bf.rmit.edu.au>" .IX Item "Remote Proxy \s-1DBD\s0 support" .IX Item "\s-1SQL\s0 Parser"