|
|
sybperl-l Archive
Up Prev Next
From: Rich Koland <richk at minn dot net>
Subject: Help: Problems with return values from SYBPERL and CTLIB
Date: Dec 9 1998 7:57PM
Hi,
We are having some problems determining when SYBPERL and / or CTLIB are
failing on an insert or update. The problem is that we are getting the
same results back from successes and failures.
We have modified the code samples from the SYBPERL / CTLIB docs, but are
still unable to determine when an insert or update fails.
Some background, in the following sample program the database, user, and
server all exist but the table does not.
=============start code section=============
#!/usr/local/bin/perl -w
use Sybase::CTlib;
require ("ctutil.pl");
ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
ct_callback(CS_SERVERMSG_CB, "srv_cb");
my($database) = "dvl_tst";
my($table) = "t_rjk";
my($qry) = qq(select * from $table);
my($db_usr) = qq(foo);
my($db_pss) = qq(foo);
my($db_srvr) = qq(SYB_TST);
my($dbh) = ""; # db variables
my($rslt, $restype, $rtn_info, $data_row) = 0;
my(@rtn_parms);
# Create the database handle
$dbh = new Sybase::CTlib $db_usr, $db_pss, $db_srvr;
# Open the right database
$db_qry =qq(use $database);
# Send the database query to the server
$dbh->ct_execute($db_qry);
$restype = 0;
while (($rslt = $dbh->ct_results($restype)) == CS_SUCCEED) {
# Skip non-fetchable results
next if($restype == CS_CMD_DONE || $restype ==
CS_CMD_SUCCEED);
}
## Send the select query to the server
$dbh->ct_execute($qry);
## Check Return value
while (($rslt = $dbh->ct_results($restype)) == CS_SUCCEED) {
## Skip non-fetchable results
next if($restype == CS_CMD_DONE || $restype ==
CS_CMD_SUCCEED);
}
if ($restype == CS_CMD_FAIL) {
print "The insertion returned a result error \n";
print "\trslt => $rslt \n";
print "\trestype => $restype\n";
} elsif ($rslt == CS_FAIL) {
print "The insertion returned an error \n";
print "\trslt => $rslt \n";
print "\trestype => $restype\n";
} else {
print "The insertion succeded \n";
print "\trslt => $rslt \n";
print "\trestype => $restype \n";
}
1;
==============end code section==============
Here is the SYBASE error from the command line:
Message number:208, Severity 16, state 1, Line 1
Server 'SYB_TST'
Message String: t_rjk not found. Specifiy owner.objectname or use
sp_help to check whether the object exists (sp_help may produce lots of
output).
The program returns:
The insertion succededed
rslt => -205
restype => 4046
Please let me know if you see any problems, or if I am off base in my
logic.
Thanks
Rich Koland
Web PA
National Marrow Donor Program
rkoland@nmdp.org or
richk@minn.net
|