1DBI::FAQ(3)           User Contributed Perl Documentation          DBI::FAQ(3)
2
3
4

NAME

6       DBI::FAQ -- The Frequently Asked Questions for the Perl5 Database
7       Interface
8

SYNOPSIS

10           perldoc DBI::FAQ
11

VERSION

13       This document is currently at version 0.38, as of February 8th, 2000.
14
15       That's very old. A newer FAQ can be found at
16       <http://faq.dbi-support.com/>
17

DESCRIPTION

19       This document serves to answer the most frequently asked questions on
20       both the DBI Mailing Lists and personally to members of the DBI
21       development team.
22

Basic Information & Information Sources

24   1.1 What is DBI, DBperl, Oraperl and *perl?
25       To quote Tim Bunce, the architect and author of DBI:
26
27           ``DBI is a database access Application Programming Interface (API)
28             for the Perl Language. The DBI API Specification defines a set
29             of functions, variables and conventions that provide a consistent
30             database interface independant of the actual database being used.''
31
32       In simple language, the DBI interface allows users to access multiple
33       database types transparently. So, if you connecting to an Oracle,
34       Informix, mSQL, Sybase or whatever database, you don't need to know the
35       underlying mechanics of the 3GL layer. The API defined by DBI will work
36       on all these database types.
37
38       A similar benefit is gained by the ability to connect to two different
39       databases of different vendor within the one perl script, ie, I want to
40       read data from an Oracle database and insert it back into an Informix
41       database all within one program. The DBI layer allows you to do this
42       simply and powerfully.
43
44       DBperl is the old name for the interface specification. It's usually
45       now used to denote perl4 modules on database interfacing, such as,
46       oraperl, isqlperl, ingperl and so on. These interfaces didn't have a
47       standard API and are generally not supported.
48
49       Here's a list of DBperl modules, their corresponding DBI counterparts
50       and support information. Please note, the author's listed here
51       generally do not maintain the DBI module for the same database. These
52       email addresses are unverified and should only be used for queries
53       concerning the perl4 modules listed below. DBI driver queries should be
54       directed to the dbi-users mailing list.
55
56           Module Name Database Required   Author          DBI
57           ----------- -----------------   ------          ---
58           Sybperl     Sybase              Michael Peppler DBD::Sybase
59                                           <mpeppler@itf.ch>
60           Oraperl     Oracle 6 & 7        Kevin Stock     DBD::Oracle
61                                           <dbi-users@perl.org>
62           Ingperl     Ingres              Tim Bunce &     DBD::Ingres
63                                           Ted Lemon
64                                           <dbi-users@perl.org>
65           Interperl   Interbase           Buzz Moschetti  DBD::Interbase
66                                           <buzz@bear.com>
67           Uniperl     Unify 5.0           Rick Wargo      None
68                                           <rickers@coe.drexel.edu>
69           Pgperl      Postgres            Igor Metz       DBD::Pg
70                                           <metz@iam.unibe.ch>
71           Btreeperl   NDBM                John Conover    SDBM?
72                                           <john@johncon.com>
73           Ctreeperl   C-Tree              John Conover    None
74                                           <john@johncon.com>
75           Cisamperl   Informix C-ISAM     Mathias Koerber None
76                                           <mathias@unicorn.swi.com.sg>
77           Duaperl     X.500 Directory     Eric Douglas    None
78                       User Agent
79
80       However, some DBI modules have DBperl emulation layers, so, DBD::Oracle
81       comes with an Oraperl emulation layer, which allows you to run legacy
82       oraperl scripts without modification. The emulation layer translates
83       the oraperl API calls into DBI calls and executes them through the DBI
84       switch.
85
86       Here's a table of emulation layer information:
87
88           Module                  Emulation Layer     Status
89           ------          ---------------     ------
90           DBD::Oracle     Oraperl             Complete
91           DBD::Informix   Isqlperl            Under development
92           DBD::Ingres     Ingperl             Complete?
93           DBD::Sybase     Sybperl             Working? ( Needs verification )
94           DBD::mSQL       Msqlperl            Experimentally released with
95                                               DBD::mSQL-0.61
96
97       The Msqlperl emulation is a special case. Msqlperl is a perl5 driver
98       for mSQL databases, but does not conform to the DBI Specification. It's
99       use is being deprecated in favour of DBD::mSQL. Msqlperl may be
100       downloaded from CPAN via:
101
102           http://www.perl.com/cgi-bin/cpan_mod?module=Msqlperl
103
104   1.2. Where can I get it from?
105       The Comprehensive Perl Archive Network resources should be used for
106       retrieving up-to-date versions of the DBI and drivers. CPAN may be
107       accessed via Tom Christiansen's splendid CPAN multiplexer program
108       located at:
109
110           http://www.perl.com/CPAN/
111
112       For more specific version information and exact URLs of drivers, please
113       see the DBI drivers list and the DBI module pages which can be found
114       on:
115
116           http://dbi.perl.org/
117           http://www.symbolstone.org/technology/perl/DBI
118
119       This list is automatically generated on a nightly basis from CPAN and
120       should be up-to-date.
121
122   1.3. Where can I get more information?
123       There are a few information sources on DBI.
124
125       "Programming the Perl DBI"
126           "Programming the Perl DBI" is the official book on the DBI written
127           by Alligator Descartes and Tim Bunce and published by O'Reilly &
128           Associates.  The book was released on February 9th, 2000.
129
130           The table of contents is:
131
132               Preface
133               1. Introduction
134                   From Mainframes to Workstations
135                   Perl
136                   DBI in the Real World
137                   A Historical Interlude and Standing Stones
138               2. Basic Non-DBI Databases
139                   Storage Managers and Layers
140                   Query Languages and Data Functions
141                   Standing Stones and the Sample Database
142                   Flat-File Databases
143                   Putting Complex Data into Flat Files
144                   Concurrent Database Access and Locking
145                   DBM Files and the Berkeley Database Manager
146                   The MLDBM Module
147                   Summary
148               3. SQL and Relational Databases
149                   The Relational Database Methodology
150                   Datatypes and NULL Values
151                   Querying Data
152                   Modifying Data Within Tables
153                   Creating and Destroying Tables
154               4. Programming with the DBI
155                   DBI Architecture
156                   Handles
157                   Data Source Names
158                   Connection and Disconnection
159                   Error Handling
160                   Utility Methods and Functions
161               5. Interacting with the Database
162                   Issuing Simple Queries
163                   Executing Non-SELECT Statements
164                   Binding Parameters to Statements
165                   Binding Output Columns
166                   do() Versus prepare()
167                   Atomic and Batch Fetching
168               6. Advanced DBI
169                   Handle Attributes and Metadata
170                   Handling LONG/LOB Data
171                   Transactions, Locking, and Isolation
172               7. ODBC and the DBI
173                   ODBC -- Embraced and Extended
174                   DBI -- Thrashed and Mutated
175                   The Nuts and Bolts of ODBC
176                   ODBC from Perl
177                   The Marriage of DBI and ODBC
178                   Questions and Choices
179                   Moving Between Win32::ODBC and the DBI
180                   And What About ADO?
181               8. DBI Shell and Database Proxying
182                   dbish -- The DBI Shell
183                   Database Proxying
184               A. DBI Specification
185               B. Driver and Database Characteristics
186               C. ASLaN Sacred Site Charter
187               Index
188
189           The book should be available from all good bookshops and can be
190           ordered online either <I>via</I> O'Reilly & Associates
191
192               http://www.oreilly.com/catalog/perldbi
193
194           or Amazon
195
196               http://www.amazon.com/exec/obidos/ASIN/1565926994/dbi
197
198       POD documentation
199           PODs are chunks of documentation usually embedded within perl
200           programs that document the code ``in place'', providing a useful
201           resource for programmers and users of modules. POD for DBI and
202           drivers is beginning to become more commonplace, and documentation
203           for these modules can be read with the "perldoc" program included
204           with Perl.
205
206           The DBI Specification
207               The POD for the DBI Specification can be read with the:
208
209                   perldoc DBI
210
211               command. The Specification also forms Appendix A of
212               "Programming the Perl DBI".
213
214           Oraperl
215               Users of the Oraperl emulation layer bundled with DBD::Oracle,
216               may read up on how to program with the Oraperl interface by
217               typing:
218
219                   perldoc Oraperl
220
221               This will produce an updated copy of the original oraperl man
222               page written by Kevin Stock for perl4. The oraperl API is fully
223               listed and described there.
224
225           Drivers
226               Users of the DBD modules may read about some of the private
227               functions and quirks of that driver by typing:
228
229                   perldoc <driver>
230
231               For example, the DBD::mSQL driver is bundled with driver-
232               specific documentation that can be accessed by typing
233
234                   perldoc DBD::mSQL
235
236           Frequently Asked Questions
237               This document, the Frequently Asked Questions is also available
238               as POD documentation! You can read this on your own system by
239               typing:
240
241                   perldoc DBI::FAQ
242
243               This may be more convenient to persons not permanently, or
244               conveniently, connected to the Internet. The DBI::FAQ module
245               should be downloaded and installed for the more up-to-date
246               version.
247
248               The version of DBI::FAQ shipped with the "DBI" module may be
249               slightly out of date.
250
251           POD in general
252               Information on writing POD, and on the philosophy of POD in
253               general, can be read by typing:
254
255                   perldoc perlpod
256
257               Users with the Tk module installed may be interested to learn
258               there is a Tk-based POD reader available called "tkpod", which
259               formats POD in a convenient and readable way. This is available
260               via CPAN as the module called Tk::POD and is highly
261               recommended.
262
263       Driver and Database Characteristics
264           The driver summaries that were produced for Appendix B of
265           "Programming the Perl DBI" are available online at:
266
267               http://dbi.perl.org/
268               http://www.symbolstone.org/technology/perl/DBI
269
270           in the driver information table. These summaries contain
271           standardised information on each driver and database which should
272           aid you in selecting a database to use. It will also inform you
273           quickly of any issues within drivers or whether a driver is not
274           fully compliant with the DBI Specification.
275
276       Rambles, Tidbits and Observations
277               http://dbi.perl.org/tidbits
278               http://www.symbolstone.org/technology/perl/DBI/tidbits
279
280           There are a series of occasional rambles from various people on the
281           DBI mailing lists who, in an attempt to clear up a simple point,
282           end up drafting fairly comprehensive documents. These are quite
283           often varying in quality, but do provide some insights into the
284           workings of the interfaces.
285
286       Articles
287           A list of articles discussing the DBI can be found on the DBI WWW
288           page at:
289
290               http://dbi.perl.org/
291               http://www.symbolstone.org/technology/perl/DBI
292
293           These articles are of varying quality and age, from the original
294           Perl Journal article written by Alligator and Tim, to more recent
295           debacles published online from about.com.
296
297       README files
298           The README files included with each driver occasionally contains
299           some useful information ( no, really! ) that may be pertinent to
300           the user.  Please read them. It makes our worthless existences more
301           bearable. These can all be read from the main DBI WWW page at:
302
303               http://dbi.perl.org/
304               http://www.symbolstone.org/technology/perl/DBI
305
306       Mailing Lists
307           There are three mailing lists for DBI:
308
309               dbi-announce@perl.org     -- for announcements, very low traffic
310               dbi-users@perl.org        -- general user support
311               dbi-dev@perl.org          -- for driver developers (no user support)
312
313           For information on how to subscribe, set digest mode etc, and
314           unsubscribe, send an email message (the content will be ignored)
315           to:
316
317               dbi-announce-help@perl.org
318               dbi-users-help@perl.org
319               dbi-dev-help@perl.org
320
321       Mailing List Archives
322           US Mailing List Archives
323                   http://outside.organic.com/mail-archives/dbi-users/
324
325               Searchable hypermail archives of the three mailing lists, and
326               some of the much older traffic have been set up for users to
327               browse.
328
329           European Mailing List Archives
330                   http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest
331
332               As per the US archive above.
333

Compilation Problems

335   2.1. Compilation problems or "It fails the test!"
336       First off, consult the README for that driver in case there is useful
337       information about the problem. It may be a known problem for your given
338       architecture and operating system or database. You can check the README
339       files for each driver in advance online at:
340
341           http://dbi.perl.org/
342           http://www.symbolstone.org/technology/perl/DBI
343
344       If it's a known problem, you'll probably have to wait till it gets
345       fixed. If you're really needing it fixed, try the following:
346
347       Attempt to fix it yourself
348           This technique is generally not recommended to the faint-hearted.
349           If you do think you have managed to fix it, then, send a patch file
350           ( context diff ) to the author with an explanation of:
351
352           ·   What the problem was, and test cases, if possible.
353
354           ·   What you needed to do to fix it. Please make sure you mention
355               everything.
356
357           ·   Platform information, database version, perl version, module
358               version and DBI version.
359
360       Email the author Do NOT whinge!
361           Please email the address listed in the WWW pages for whichever
362           driver you are having problems with. Do not directly email the
363           author at a known address unless it corresponds with the one
364           listed.
365
366           We tend to have real jobs to do, and we do read the mailing lists
367           for problems. Besides, we may not have access to <insert your
368           favourite brain-damaged platform here> and couldn't be of any
369           assistance anyway! Apologies for sounding harsh, but that's the way
370           of it!
371
372           However, you might catch one of these creative genii at 3am when
373           we're doing this sort of stuff anyway, and get a patch within 5
374           minutes. The atmosphere in the DBI circle is that we do appreciate
375           the users' problems, since we work in similar environments.
376
377           If you are planning to email the author, please furnish as much
378           information as possible, ie:
379
380           ·   ALL the information asked for in the README file in the
381               problematic module. And we mean ALL of it. We don't put lines
382               like that in documentation for the good of our health, or to
383               meet obscure README file standards of length.
384
385           ·   If you have a core dump, try the Devel::CoreStack module for
386               generating a stack trace from the core dump. Send us that too.
387               Devel::CoreStack can be found on CPAN at:
388
389                   http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack
390
391           ·   Module versions, perl version, test cases, operating system
392               versions and any other pertinent information.
393
394           Remember, the more information you send us, the quicker we can
395           track problems down. If you send us no useful information, expect
396           nothing back.
397
398           Finally, please be aware that some authors, including Tim Bunce,
399           specifically request that you do not mail them directly. Please
400           respect their wishes and use the email addresses listed in the
401           appropriate module "README" file.
402
403       Email the dbi-users Mailing List
404           It's usually a fairly intelligent idea to cc the mailing list
405           anyway with problems. The authors all read the lists, so you lose
406           nothing by mailing there.
407

Platform and Driver Issues

409   3.1 What's the difference between ODBC and DBI?
410       In terms of architecture - not much: Both define programming
411       interfaces. Both allow multiple drivers to be loaded to do the actual
412       work.
413
414       In terms of ease of use - much: The DBI is a 'high level' interface
415       that, like Perl itself, strives to make the simple things easy while
416       still making the hard things possible. The ODBC is a 'low level'
417       interface. All nuts-bolts-knobs-and-dials.
418
419       Now there's an ODBC driver for the DBI (DBD::ODBC) the "What's the
420       difference" question is more usefully rephrased as:
421
422       Chapter 7 of "Programming the Perl DBI" covers this topic in far more
423       detail and should be consulted.
424
425   3.2 What's the difference between Win32::ODBC and DBD::ODBC?
426       The DBI, and thus DBD::ODBC, has a different philosophy from the
427       Win32::ODBC module:
428
429       The Win32::ODBC module is a 'thin' layer over the low-level ODBC API.
430       The DBI defines a simpler 'higher level' interface.
431
432       The Win32::ODBC module gives you access to more of the ODBC API.  The
433       DBI and DBD::ODBC give you access to only the essentials.  (But, unlike
434       Win32::ODBC, the DBI and DBD::ODBC do support parameter binding and
435       multiple prepared statements which reduces the load on the database
436       server and can dramatically increase performance.)
437
438       The Win32::ODBC module only works on Win32 systems.  The DBI and
439       DBD::ODBC are very portable and work on Win32 and Unix.
440
441       The DBI and DBD::ODBC modules are supplied as a standard part of the
442       Perl 5.004 binary distribution for Win32 (they don't work with the
443       older, non-standard, ActiveState port).
444
445       Scripts written with the DBI and DBD::ODBC are faster than Win32::ODBC
446       on Win32 and are trivially portable to other supported database types.
447
448       The DBI offers optional automatic printing or die()ing on errors which
449       makes applications simpler and more robust.
450
451       The current DBD::ODBC driver version 0.16 is new and not yet fully
452       stable.  A new release is due soon [relative to the date of the next
453       TPJ issue :-] and will be much improved and offer more ODBC
454       functionality.
455
456       To summarise: The Win32::ODBC module is your best choice if you need
457       access to more of the ODBC API than the DBI gives you. Otherwise, the
458       DBI and DBD::ODBC combination may be your best bet.
459
460       Chapter 7 of "Programming the Perl DBI" covers this topic in far more
461       detail and should be consulted.
462
463   3.3 Is DBI supported under Windows 95 / NT platforms?
464       Finally, yes! Jeff Urlwin has been working diligently on building DBI
465       and DBD::ODBC under these platforms, and, with the advent of a stabler
466       perl and a port of MakeMaker, the project has come on by great leaps
467       and bounds.
468
469       The DBI and DBD::Oracle Win32 ports are now a standard part of DBI, so,
470       downloading DBI of version higher than 0.81 should work fine as should
471       using the most recent DBD::Oracle version.
472
473   3.4 Can I access Microsoft Access or SQL-Server databases with DBI?
474       Yes, use the DBD::ODBC driver.
475
476   3.5 Is the a DBD for <insert favourite database here>?
477       Is is listed on the DBI drivers page?
478
479           http://dbi.perl.org/
480           http://www.symbolstone.org/technology/perl/DBI
481
482       If not, no. A complete absence of a given database driver from that
483       page means that no-one has announced any intention to work on it, not
484       that such a driver is impossible to write.
485
486       A corollary of the above statement implies that if you see an
487       announcement for a driver not on the above page, there's a good chance
488       it's not actually a DBI driver, and may not conform to the
489       specifications. Therefore, questions concerning problems with that code
490       should not really be addressed to the DBI Mailing Lists.
491
492   3.6 What's DBM? And why should I use DBI instead?
493       Extracted from ``DBI - The Database Interface for Perl 5'':
494
495           ``UNIX was originally blessed with simple file-based ``databases'', namely
496           the dbm system. dbm lets you store data in files, and retrieve
497           that data quickly. However, it also has serious drawbacks.
498
499               File Locking
500
501               The dbm systems did not allow particularly robust file locking
502               capabilities, nor any capability for correcting problems arising through
503               simultaneous writes [ to the database ].
504
505               Arbitrary Data Structures
506
507               The dbm systems only allows a single fixed data structure:
508               key-value pairs. That value could be a complex object, such as a
509               [ C ] struct, but the key had to be unique. This was a large
510               limitation on the usefulness of dbm systems.
511
512           However, dbm systems still provide a useful function for users with
513           simple datasets and limited resources, since they are fast, robust and
514           extremely well-tested. Perl modules to access dbm systems have now
515           been integrated into the core Perl distribution via the
516           AnyDBM_File module.''
517
518       To sum up, DBM is a perfectly satisfactory solution for essentially
519       read-only databases, or small and simple datasets. However, for more
520       scaleable dataset handling, not to mention robust transactional
521       locking, users are recommended to use a more powerful database engine
522       via DBI.
523
524       Chapter 2 of "Programming the Perl DBI" discusses DBM files in detail.
525
526   3.7 What database do you recommend me using?
527       This is a particularly thorny area in which an objective answer is
528       difficult to come by, since each dataset, proposed usage and system
529       configuration differs from person to person.
530
531       From the current author's point of view, if the dataset is relatively
532       small, being tables of less than 1 million rows, and less than 1000
533       tables in a given database, then mSQL is a perfectly acceptable
534       solution to your problem. This database is extremely cheap, is
535       wonderfully robust and has excellent support. More information is
536       available on the Hughes Technology WWW site at:
537
538           http://www.hughes.com.au
539
540       You may also wish to look at MySQL which is a more powerful database
541       engine that has a similar feel to mSQL.
542
543           http://www.tcx.se
544
545       If the dataset is larger than 1 million row tables or 1000 tables, or
546       if you have either more money, or larger machines, I would recommend
547       Oracle RDBMS.  Oracle's WWW site is an excellent source of more
548       information.
549
550           http://www.oracle.com
551
552       Informix is another high-end RDBMS that is worth considering. There are
553       several differences between Oracle and Informix which are too complex
554       for this document to detail. Information on Informix can be found on
555       their WWW site at:
556
557           http://www.informix.com
558
559       In the case of WWW fronted applications, mSQL may be a better option
560       due to slow connection times between a CGI script and the Oracle RDBMS
561       and also the amount of resource each Oracle connection will consume.
562       mSQL is lighter resource-wise and faster.
563
564       These views are not necessarily representative of anyone else's
565       opinions, and do not reflect any corporate sponsorship or views. They
566       are provided as-is.
567
568   3.8 Is <insert feature here> supported in DBI?
569       Given that we're making the assumption that the feature you have
570       requested is a non-standard database-specific feature, then the answer
571       will be no.
572
573       DBI reflects a generic API that will work for most databases, and has
574       no database-specific functionality.
575
576       However, driver authors may, if they so desire, include hooks to
577       database-specific functionality through the "func()" method defined in
578       the DBI API.  Script developers should note that use of functionality
579       provided via the "func()" methods is very unlikely to be portable
580       across databases.
581

Programming Questions

583   4.1 Is DBI any use for CGI programming?
584       In a word, yes! DBI is hugely useful for CGI programming! In fact, I
585       would tentatively say that CGI programming is one of two top uses for
586       DBI.
587
588       DBI confers the ability to CGI programmers to power WWW-fronted
589       databases to their users, which provides users with vast quantities of
590       ordered data to play with. DBI also provides the possibility that, if a
591       site is receiving far too much traffic than their database server can
592       cope with, they can upgrade the database server behind the scenes with
593       no alterations to the CGI scripts.
594
595   4.2 How do I get faster connection times with DBD::Oracle and CGI?
596           Contributed by John D. Groenveld
597
598       The Apache "httpd" maintains a pool of "httpd" children to service
599       client requests.
600
601       Using the Apache mod_perl module by Doug MacEachern, the perl
602       interpreter is embedded with the "httpd" children. The CGI, DBI, and
603       your other favorite modules can be loaded at the startup of each child.
604       These modules will not be reloaded unless changed on disk.
605
606       For more information on Apache, see the Apache Project's WWW site:
607
608           http://www.apache.org
609
610       The mod_perl module can be downloaded from CPAN via:
611
612           http://www.perl.com/cgi-bin/cpan_mod?module=Apache
613
614   4.3 How do I get persistent connections with DBI and CGI?
615           Contributed by John D. Groenveld
616
617       Using Edmund Mergl's Apache::DBI module, database logins are stored in
618       a hash with each of these "httpd" child. If your application is based
619       on a single database user, this connection can be started with each
620       child.  Currently, database connections cannot be shared between
621       "httpd" children.
622
623       Apache::DBI can be downloaded from CPAN via:
624
625           http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI
626
627   4.4 ``When I run a perl script from the command line, it works, but, when I
628       run it under the "httpd", it fails!'' Why?
629       Basically, a good chance this is occurring is due to the fact that the
630       user that you ran it from the command line as has a correctly
631       configured set of environment variables, in the case of DBD::Oracle,
632       variables like "ORACLE_HOME", "ORACLE_SID" or "TWO_TASK".
633
634       The "httpd" process usually runs under the user id of "nobody", which
635       implies there is no configured environment. Any scripts attempting to
636       execute in this situation will correctly fail.
637
638       One way to solve this problem is to set the environment for your
639       database in a "BEGIN { }" block at the top of your script. Another
640       technique is to configure your WWW server to pass-through certain
641       environment variables to your CGI scripts.
642
643       Similarly, you should check your "httpd" error logfile for any clues,
644       as well as the ``Idiot's Guide To Solving Perl / CGI Problems'' and
645       ``Perl CGI Programming FAQ'' for further information. It is unlikely
646       the problem is DBI-related.
647
648       The ``Idiot's Guide To Solving Perl / CGI Problems'' can be located at:
649
650           http://www.perl.com/perl/faq/index.html
651
652       as can the ``Perl CGI Programming FAQ''. Read BOTH these documents
653       carefully!
654
655   4.5 How do I get the number of rows returned from a "SELECT" statement?
656       Count them. Read the DBI docs for the "rows()" method.
657

Miscellaneous Questions

659   5.1 Can I do multi-threading with DBI?
660       Perl version 5.005 and later can be built to support multi-threading.
661       The DBI, as of version 1.02, does not yet support multi-threading so it
662       would be unsafe to let more than one thread enter the DBI at the same
663       time.
664
665       It is expected that some future version of the DBI will at least be
666       thread-safe (but not thread-hot) by automatically blocking threads
667       intering the DBI while it's already in use.
668
669       For some OCI example code for Oracle that has multi-threaded "SELECT"
670       statements, see:
671
672           http://www.symbolstone.org/technology/oracle/oci/orathreads.tar.gz
673
674   5.2 How do I handle BLOB data with DBI?
675       Handling BLOB data with the DBI is very straight-forward. BLOB columns
676       are specified in a SELECT statement as per normal columns. However, you
677       also need to specify a maximum BLOB size that the <I>database
678       handle</I> can fetch using the "LongReadLen" attribute.
679
680       For example:
681
682           ### $dbh is a connected database handle
683           $sth = $dbh->prepare( "SELECT blob_column FROM blobby_table" );
684           $sth->execute;
685
686       would fail.
687
688           ### $dbh is a connected database handle
689           ### Set the maximum BLOB size...
690           $dbh->{LongReadLen} = 16384;        ### 16Kb...Not much of a BLOB!
691
692           $sth = $dbh->prepare( "..." );
693
694       would succeed <I>provided no column values were larger than the
695       specified value</I>.
696
697       If the BLOB data is longer than the value of "LongReadLen", then an
698       error will occur. However, the DBI provides an additional piece of
699       functionality that will automatically truncate the fetched BLOB to the
700       size of "LongReadLen" if it is longer. This does not cause an error to
701       occur, but may make your fetched BLOB data useless.
702
703       This behaviour is regulated by the "LongTruncOk" attribute which is
704       defaultly set to a false value ( thus making overlong BLOB fetches fail
705       ).
706
707           ### Set BLOB handling such that it's 16Kb and can be truncated
708           $dbh->{LongReadLen} = 16384;
709           $dbh->{LongTruncOk} = 1;
710
711       Truncation of BLOB data may not be a big deal in cases where the BLOB
712       contains run-length encoded data, but data containing checksums at the
713       end, for example, a ZIP file, would be rendered useless.
714
715   5.3 How can I invoke stored procedures with DBI?
716       The DBI does not define a database-independent way of calling stored
717       procedures.
718
719       However, most database that support them also provide a way to call
720       them from SQL statements - and the DBI certainly supports that.
721
722       So, assuming that you have created a stored procedure within the target
723       database, eg, an Oracle database, you can use $dbh->"do()" to
724       immediately execute the procedure. For example,
725
726           $dbh->do( "BEGIN someProcedure; END;" );   # Oracle-specific
727
728       You should also be able to "prepare" and "execute", which is the
729       recommended way if you'll be calling the procedure often.
730
731   5.4 How can I get return values from stored procedures with DBI?
732           Contributed by Jeff Urlwin
733
734           $sth = $dbh->prepare( "BEGIN foo(:1, :2, :3); END;" );
735           $sth->bind_param(1, $a);
736           $sth->bind_param_inout(2, \$path, 2000);
737           $sth->bind_param_inout(3, \$success, 2000);
738           $sth->execute;
739
740       Remember to perform error checking, though! ( Or use the "RaiseError"
741       attribute ).
742
743   5.5 How can I create or drop a database with DBI?
744       Database creation and deletion are concepts that are entirely too
745       abstract to be adequately supported by DBI. For example, Oracle does
746       not support the concept of dropping a database at all! Also, in Oracle,
747       the database server essentially is the database, whereas in mSQL, the
748       server process runs happily without any databases created in it. The
749       problem is too disparate to attack in a worthwhile way.
750
751       Some drivers, therefore, support database creation and deletion through
752       the private "func()" methods. You should check the documentation for
753       the drivers you are using to see if they support this mechanism.
754
755   5.6 How can I "commit" or "rollback" a statement with DBI?
756       See the "commit()" and "rollback()" methods in the DBI Specification.
757
758       Chapter 6 of "Programming the Perl DBI" discusses transaction handling
759       within the context of DBI in more detail.
760
761   5.7 How are "NULL" values handled by DBI?
762       "NULL" values in DBI are specified to be treated as the value "undef".
763       "NULL"s can be inserted into databases as "NULL", for example:
764
765           $rv = $dbh->do( "INSERT INTO table VALUES( NULL )" );
766
767       but when queried back, the "NULL"s should be tested against "undef".
768       This is standard across all drivers.
769
770   5.8 What are these "func()" methods all about?
771       The "func()" method is defined within DBI as being an entry point for
772       database-specific functionality, eg, the ability to create or drop
773       databases. Invoking these driver-specific methods is simple, for
774       example, to invoke a "createDatabase" method that has one argument, we
775       would write:
776
777           $rv =$dbh->func( 'argument', 'createDatabase' );
778
779       Software developers should note that the "func()" methods are non-
780       portable between databases.
781
782   5.9 Is DBI Year 2000 Compliant?
783       DBI has no knowledge of understanding of what dates are. Therefore, DBI
784       itself does not have a Year 2000 problem. Individual drivers may use
785       date handling code internally and therefore be potentially susceptible
786       to the Year 2000 problem, but this is unlikely.
787
788       You may also wish to read the ``Does Perl have a Year 2000 problem?''
789       section of the Perl FAQ at:
790
791           http://www.perl.com/CPAN/doc/FAQs/FAQ/PerlFAQ.html
792

Support and Training

794       The Perl5 Database Interface is FREE software. IT COMES WITHOUT
795       WARRANTY OF ANY KIND. See the DBI README for more details.
796
797       However, some organizations are providing either technical support or
798       training programs on DBI. The present author has no knowledge as to the
799       quality of these services. The links are included for reference
800       purposes only and should not be regarded as recommendations in any way.
801       Caveat emptor.
802
803   Commercial Support
804       The Perl Clinic
805           The Perl Clinic provides commercial support for Perl and Perl
806           related problems, including the DBI and its drivers.  Support is
807           provided by the company with whom Tim Bunce, author of DBI and
808           DBD::Oracle, works and ActiveState. For more information on their
809           services, please see:
810
811               http://www.perlclinic.com
812
813   Training
814       Westlake Solutions
815           A hands-on class for experienced Perl CGI developers that teaches
816           how to write database-connected CGI scripts using Perl and DBI.pm.
817           This course, along with four other courses on CGI scripting with
818           Perl, is taught in Washington, DC; Arlington, Virginia; and on-site
819           worldwide upon request.
820
821           See:
822
823               http://www.westlake.com/training
824
825           for more details.
826

Other References

828       In this section, we present some miscellaneous WWW links that may be of
829       some interest to DBI users. These are not verified and may result in
830       unknown sites or missing documents.
831
832           http://www-ccs.cs.umass.edu/db.html
833           http://www.odmg.org/odmg93/updates_dbarry.html
834           http://www.jcc.com/sql_stnd.html
835

AUTHOR

837       Alligator Descartes <http://www.symbolstone.org/descarte/contact.html>.
838       Portions are Copyright their original stated authors.
839
841       This document is Copyright (c)1994-2000 Alligator Descartes, with
842       portions Copyright (c)1994-2000 their original authors. This module is
843       released under the 'Artistic' license which you can find in the perl
844       distribution.
845
846       This document is Copyright (c)1997-2000 Alligator Descartes. All rights
847       reserved.  Permission to distribute this document, in full or in part,
848       via email, Usenet, ftp archives or http is granted providing that no
849       charges are involved, reasonable attempt is made to use the most
850       current version and all credits and copyright notices are retained (
851       the AUTHOR and COPYRIGHT sections ).  Requests for other distribution
852       rights, including incorporation into commercial products, such as
853       books, magazine articles or CD-ROMs should be made to Alligator
854       Descartes <http://www.symbolstone.org/descarte/contact.html>.
855
856
857
858perl v5.10.1                      2007-11-15                       DBI::FAQ(3)
Impressum