|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Getting Command Text in CTLib
Date: Sep 10 1997 6:06PM
Dave.Cross@gb.swissbank.com wrote:
>
>
> I've got some CGI code that is written using DBLib and I'm converting
> it to CTLib.
>
> In DBLib we use dbstrcpy to get a copy of command which we display as
> part of the error screen. Under CTLib this function seems to have
> vanished. Can anyone tell me how I can simulate the same functionality
> in Sybase::CTlib?
I've tried to find ways to emulate that functionality myself. Sybooks
says that ct_debug() provides that functionality, but that means that
you need to link with the debug libraries.
Another option would be to write something like this (warning: typed
right into the mailer - no testing performed!):
package Sybase::CTlibPlus; :-)
use Sybase::CTlib;
use Exporter;
@ISA = qw(Exporter Sybase::CTlib);
@EXPORT = @Sybase::CTlib::EXPORT;
sub new {
my $package = shift;
my ($user, $pwd, $server) = @_;
my $self = new Syabse::DBlib $user, $pwd, $server, {Query => '', New
=> 1};
bless $package, $self;
$self;
}
sub DESTROY {
my $self = shift;
$self->SUPER::DESTROY;
}
sub ct_execute {
my $self = shift;
my $query = shift;
my $ret = $self->SUPER::ct_execute($query); # call the real one
$self->{Query} = $query;
$ret;
}
sub ct_command {
my $self = shift;
my $type = shift;
my $buffer = shift;
my $len = shift;
my $opt = shift;
if($self->{New}) {
$self->{Query} = '';
}
my $ret = $self->SUPER::ct_command($type, $buffer, $len, $opt);
$self->{Query} .= $query;
$self->{New} = 0;
$ret;
}
sub ct_send {
my $self = shift;
my $ret = $self->SUPER::ct_send();
$self->{New} = 1;
$ret;
}
sub ct_strcpy {
my $self = shift;
$self->{Query};
}
1;
__END__
Not really clean, and it may not catch all the cases (it certainly does
not catch things like rpc calls and the like), but it could
be a start...
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
|