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
18       Neither this document nor that web site are actively maintained.
19       Volunteers are welcome.
20

DESCRIPTION

22       This document serves to answer the most frequently asked questions on
23       both the DBI Mailing Lists and personally to members of the DBI
24       development team.
25

Basic Information & Information Sources

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

Compilation Problems

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

Platform and Driver Issues

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

Programming Questions

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

Miscellaneous Questions

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

Support and Training

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

Other References

820       In this section, we present some miscellaneous WWW links that may be of
821       some interest to DBI users. These are not verified and may result in
822       unknown sites or missing documents.
823
824           http://www-ccs.cs.umass.edu/db.html
825           http://www.odmg.org/odmg93/updates_dbarry.html
826           http://www.jcc.com/sql_stnd.html
827

AUTHOR

829       Alligator Descartes.  Portions are Copyright their original stated
830       authors.
831
833       This document is Copyright (c)1994-2000 Alligator Descartes, with
834       portions Copyright (c)1994-2000 their original authors. This module is
835       released under the 'Artistic' license which you can find in the perl
836       distribution.
837
838       This document is Copyright (c)1997-2000 Alligator Descartes. All rights
839       reserved.  Permission to distribute this document, in full or in part,
840       via email, Usenet, ftp archives or http is granted providing that no
841       charges are involved, reasonable attempt is made to use the most
842       current version and all credits and copyright notices are retained (
843       the AUTHOR and COPYRIGHT sections ).  Requests for other distribution
844       rights, including incorporation into commercial products, such as
845       books, magazine articles or CD-ROMs should be made to Alligator
846       Descartes.
847
848
849
850perl v5.16.3                      2013-04-04                       DBI::FAQ(3)
Impressum