Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

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 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;


    my $self = shift;


sub ct_execute {
    my $self = shift;
    my $query = shift;

    my $ret = $self->SUPER::ct_execute($query);  # call the real one

    $self->{Query} = $query;


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;


sub ct_send {
    my $self = shift;

    my $ret = $self->SUPER::ct_send();

    $self->{New} = 1;


sub ct_strcpy {
    my $self = shift;



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 Peppler       -||-  Data Migrations Inc.  -||-