home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl502b.zip / lib / auto / DB2CLI / Connect.al < prev    next >
Text File  |  1996-02-24  |  726b  |  28 lines

  1. # NOTE: Derived from lib/DB2CLI.pm.  Changes made here will be lost.
  2. package DB2CLI;
  3.  
  4. sub Connect
  5. {
  6.     my ($class, $database, $user, $pw) = @_;
  7.     my ($henv, $hdbc, $rc);
  8.     if ($rc = SQLAllocEnv($henv)) {
  9.     warn "SQLAllocEnv failed with rc=$rc\n";
  10.     return undef;
  11.     }
  12.     if ($rc = SQLAllocConnect($henv, $hdbc)) {
  13.     iMessage($henv, undef, undef, "SQLAllocConnect", $rc);
  14.     SQLFreeEnv($henv);
  15.     return undef;
  16.     }
  17.     my $connRef = bless { HENV => $henv, HDBC => $hdbc, DATABASE => $database };
  18.     if ($rc = SQLConnect($hdbc, $database, $user, $pw)) {
  19.     $connRef->Message("SQLConnect to $database", $rc);
  20.     SQLFreeConnect($hdbc);
  21.     SQLFreeEnv($henv);
  22.     return undef;
  23.     }
  24.     return $connRef;
  25. }
  26.  
  27. 1;
  28.