home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / DBD / ODBC.pm < prev    next >
Encoding:
Text File  |  1997-08-10  |  2.4 KB  |  123 lines

  1. # $Id: ODBC.pm,v 1.6 1997/07/25 11:50:07 timbo Exp $
  2. #
  3. # Copyright (c) 1994,1995,1996  Tim Bunce
  4. # portions Copyright (c) 1997  Thomas K. Wenrich
  5. # portions Copyright (c) 1997  Jeff Urlwin
  6. #
  7. # You may distribute under the terms of either the GNU General Public
  8. # License or the Artistic License, as specified in the Perl README file.
  9.  
  10. require 5.004;
  11. {
  12.     package DBD::ODBC;
  13.  
  14.     use DBI ();
  15.     use DynaLoader ();
  16.  
  17.     @ISA = qw(DynaLoader);
  18.  
  19.     $VERSION = '0.16';
  20.     my $Revision = substr(q$Revision: 1.6 $, 10);
  21.  
  22.     require_version DBI 0.86;
  23.  
  24.     bootstrap DBD::ODBC $VERSION;
  25.  
  26.     $err = 0;        # holds error code   for DBI::err
  27.     $errstr = "";    # holds error string for DBI::errstr
  28.     $sqlstate = "00000";
  29.     $drh = undef;    # holds driver handle once initialised
  30.  
  31.     sub driver{
  32.     return $drh if $drh;
  33.     my($class, $attr) = @_;
  34.  
  35.     $class .= "::dr";
  36.  
  37.     # not a 'my' since we use it above to prevent multiple drivers
  38.  
  39.     $drh = DBI::_new_drh($class, {
  40.         'Name' => 'ODBC',
  41.         'Version' => $VERSION,
  42.         'Err'    => \$DBD::ODBC::err,
  43.         'Errstr' => \$DBD::ODBC::errstr,
  44.         'State' => \$DBD::ODBC::sqlstate,
  45.         'Attribution' => 'ODBC DBD by Jeff Urlwin',
  46.         });
  47.  
  48.     $drh;
  49.     }
  50.  
  51.     1;
  52. }
  53.  
  54.  
  55. {   package DBD::ODBC::dr; # ====== DRIVER ======
  56.     use strict;
  57.  
  58.     sub connect {
  59.     my $drh = shift;
  60.     my($dbname, $user, $auth)= @_;
  61.  
  62.     # create a 'blank' dbh
  63.     my $this = DBI::_new_dbh($drh, {
  64.         'Name' => $dbname,
  65.         'USER' => $user, 
  66.         'CURRENT_USER' => $user,
  67.         });
  68.  
  69.     # Call ODBC logon func in ODBC.xs file
  70.     # and populate internal handle data.
  71.  
  72.     DBD::ODBC::db::_login($this, $dbname, $user, $auth) or return undef;
  73.  
  74.     $this;
  75.     }
  76.  
  77. }
  78.  
  79.  
  80. {   package DBD::ODBC::db; # ====== DATABASE ======
  81.     use strict;
  82.  
  83.     sub prepare {
  84.     my($dbh, $statement, @attribs)= @_;
  85.  
  86.     # create a 'blank' dbh
  87.     my $sth = DBI::_new_sth($dbh, {
  88.         'Statement' => $statement,
  89.         });
  90.  
  91.     # Call ODBC OCI oparse func in ODBC.xs file.
  92.     # (This will actually also call oopen for you.)
  93.     # and populate internal handle data.
  94.  
  95.     DBD::ODBC::st::_prepare($sth, $statement, @attribs)
  96.         or return undef;
  97.  
  98.     $sth;
  99.     }
  100.  
  101.     sub tables {
  102.     my($dbh) = @_;        # XXX add qualification
  103.  
  104.     # create a "blank" statement handle
  105.     my $sth = DBI::_new_sth($dbh, { 'Statement' => "SQLTables" });
  106.  
  107.     # XXX use qaulification(s) (qual, schema, etc?) here...
  108.     DBD::ODBC::st::_tables($dbh,$sth, "")
  109.         or return undef;
  110.  
  111.     $sth;
  112.     }
  113.  
  114. }
  115.  
  116.  
  117. {   package DBD::ODBC::st; # ====== STATEMENT ======
  118.     use strict;
  119.  
  120. }
  121. 1;
  122. __END__
  123.