|
|
sybperl-l Archive
Up Prev Next
From: Andrew dot Crossland at citicorp dot com
Subject: Callbacks in Sybase::Simple
Date: Jan 15 2001 4:27PM
I have a problem which I hope someone out there can help me with. I have
extended the Sybase::Simple class and provided a new one for my
application called DBConnection as per code below:-
package DBConnection;
@ISA = qw(Sybase::Simple Exporter);
sub new
{
....
my $type = shift;
....
my $self = Sybase::Simple->new ($user, $passwd, $server);
....
Sybase::Simple::ct_callback(CS_SERVERMSG_CB, \&serverCBH);
bless $self, $type;
}
sub ExecSql
{
my $self=shift;
....
$retRef = $self->SUPER::ExecSql(@_);
....
}
sub printCallback()
{
my $self = shift;
my ($dbh, $number, $severity, $state, $line, $server, $proc, $msg) =
@_;
print "printCallback: $number $msg\n";
}
# NB: Not called as a method
sub serverCBH
{
my ($dbh, $number, $severity, $state, $line, $server, $proc, $msg) = @_;
....
$dbh->printCallback(@_);
}
If I run the following code:-
{
my $dbh = DBConnection->new ($user, $passwd, $server);
$dbh->ExecSql("use mydatabase");
$dbh->ExecSql("some sql that causes an insert of a duplicate row into a
table");
}
I get the following results:
printCallback: 5701 Changed database context to 'mydatabase'.
Can't locate auto/Sybase/CTlib/printCallback.al in @INC (@INC
contains: /apps/perl/PA-
RISC1.1 /apps/perl /apps/CEDEV/CEDEV_RUN_MENU/release
/apps/CEDEV/CEDEV_RUN_MENU/perl /home01/acrossla/lib /apps/perl/lib/site_p
erl/PA-RISC1.1 /apps/perl/lib/site_perl /opt/perl5/lib/PA
-RISC1.1/5.00404 /opt/perl5/lib /opt/perl5/lib/site_perl/PA-
RISC1.1 /opt/perl5/lib/site_perl .) ...propagated at /apps/CEDEV/CEDEV_R
UN_MENU/perl/CEProcessor.pm line 111, chunk 7.
If I run the code in debug and stop in DBConnection::serverCBH and do
a 'print $dbh' then I get DBConnection=HASH(0x40555fe0) for the first
ExecSql and Sybase::CTlib=HASH(0x405608d4) for the second ExecSql. So, I'm
a little confused at to how/why perl thinks that $dbh is a DBConnection
object one time and a Sybase::CTlib object the second time. Does anyone
have any help, please!!! Should I be downcasting in someway? I have looked
through the OO stuff and can't find any information. The best way I can
make it work is to change the line in serverCBH to
$dbh->DBConnection::printCallback(@_)
Thanks V.much,
Andrew.
|