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 >
Wrap
Text File
|
1996-02-24
|
726b
|
28 lines
# NOTE: Derived from lib/DB2CLI.pm. Changes made here will be lost.
package DB2CLI;
sub Connect
{
my ($class, $database, $user, $pw) = @_;
my ($henv, $hdbc, $rc);
if ($rc = SQLAllocEnv($henv)) {
warn "SQLAllocEnv failed with rc=$rc\n";
return undef;
}
if ($rc = SQLAllocConnect($henv, $hdbc)) {
iMessage($henv, undef, undef, "SQLAllocConnect", $rc);
SQLFreeEnv($henv);
return undef;
}
my $connRef = bless { HENV => $henv, HDBC => $hdbc, DATABASE => $database };
if ($rc = SQLConnect($hdbc, $database, $user, $pw)) {
$connRef->Message("SQLConnect to $database", $rc);
SQLFreeConnect($hdbc);
SQLFreeEnv($henv);
return undef;
}
return $connRef;
}
1;