|
|
sybperl-l Archive
Up Prev Next
From: "McCarthy, John" <JMcCarthy at citistreetonline dot com>
Subject: RE: using CTlib callbacks
Date: Oct 2 2001 3:53PM
Below are the errors and the module :
Errors:
----------------------
Bareword "CS_SUCCEED" not allowed while "strict subs" in use at JMc.pm line
52.
Bareword "CS_CLIENTMSG_CB" not allowed while "strict subs" in use at JMc.pm
line 66.
Bareword "CS_SERVERMSG_CB" not allowed while "strict subs" in use at JMc.pm
line 67.
Execution of JMc.pm aborted due to compilation errors.
----------------------
Module:
----------------------
#!/usr/local/apps/perl-5.6.0/bin/perl -w
use strict;
require 'ctime.pl';
use Sybase::CTlib;
package JMc;
sub BEGIN {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time());
$mon += 1;
$year += 1900;
$JMc::TimeStamp = sprintf
"%4.4d.%2.2d%2.2d.%2.2d:%2.2d",${year},${mon},${mday},${hour},${min};
}
sub GetJobTime {
return $JMc::TimeStamp;
}
my ($User, $Server, $First, $BIN, $File);
sub GetPassWord {
# code removed for brevity
}
sub OpenConn {
my $self = shift;
my $Appname = shift or die "You have not provided Appname - cannot
continue";
my $Server = shift or die "You have not provided Server - cannot
continue";
my $User = shift or die "You have not provided User - cannot
continue";
my $Password = JMc->GetPassWord ($Server,$User)
or die "Could not get password\n";
my $dbh = new Sybase::CTlib $User, $Password, $Server, $Appname
or die "could not make connection\n" or die "could not get
connection";
return $dbh;
}
sub RunSql {
my $self = shift;
my $dbh = shift or die "Requires connection handle";
my $Sql = shift or die "Requires sql query command";
my $Rows = $dbh->ct_sql($Sql) or die "could not get results";
return $Rows;
}
sub msg_cb {
my ($layer, $origin, $severity, $number, $msg, $osmsg, $dbh) = @_;
printf STDERR "\nOpen Client Message: (In msg_cb)\n";
printf STDERR "Message Number: LAYER = (%1d) ORGIN = (%1d) ",
$layer, $origin;
printf STDERR "SEVERITY = (%1d) NUMBER = (%1d)\n",
$severity, $number;
printf STDERR "Message String: %s\n", $msg;
if (defined($osmsg)) {
printf STDERR "O.S. Error: %s\n", $osmsg;
}
CS_SUCCEED;
}
sub srv_cb {
my ($dbh, $number, $severity, $state, $line, $server, $proc, $msg) =
@_;
printf STDERR "\nServer Msg: (In srv_cb)\n";
printf STDERR "Message number: %1d, Severity %1d, ", $number,
$severity;
printf STDERR "State %1d, Line %1d\n", $state, $line;
printf STDERR "Server '%s'\n", $server if (defined($server)) ;
printf STDERR "Proc '%s'\n", $server if (defined($proc)) ;
printf STDERR "Message string: %s\n", $msg;
CS_SUCCEED;
}
ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
ct_callback(CS_SERVERMSG_CB, \&srv_cb);
1;
----------------------
|