PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Vlad Markov <vlad dot dvoichenko-markov at bellatlantic dot COM>
Subject: CTlib and host_name() function
Date: Jun 3 1998 12:43PM

I have a stored proc that makes a call to the Sybase system function 
host_name().  When I run the stored proc using CTlib, the host_name() 
function returns null.  Other system functions such as host_id() and 
user_name() work fine.

Does anyone know how to make host_name() and Sybase::CTlib work 
correctly? Thanks.

---------------------------------------------------------------------
My test version of the stored proc is as follows:

use database
go

if exists (select * from sysobjects where name = 'host_test')
        drop proc host_test
go

create proc host_test
as

declare @host_test_name  varchar(30),
        @tmp             varchar(255)

select @host_test_name = host_name()
select @tmp = "value from host_name() function is " + @host_test_name
print @tmp

select @host_test_name = host_id()
select @tmp = "value from host_id() function is " + @host_test_name
print @tmp

select @host_test_name = user_name()
select @tmp = "value from user_name() function is " + @host_test_name
print @tmp

return 0
go

grant exec on host_test to common
go

---------------------------------------------------------------------
The Sybase::CTlib test script is as follows:

#!/usr/local/perl/bin/perl

use strict;
use Sybase::CTlib;
use CmaCTlib;           # module containing local functions

my ($uid) = "myName";
my ($passwd) = "myPass";
my ($dbServer) = "HARPO";
my ($dbName) = "myDB";
my ($dbh);
my ($resultStat) = 0;
my ($resType) = 0;

ct_callback (CS_CLIENTMSG_CB, \&CmaCTlib::clientMS_cb);
ct_callback (CS_SERVERMSG_CB, \&CmaCTlib::serverMSG_cb);

$dbh = Sybase::CTlib->ct_connect($uid, $passwd, $dbServer);
$dbh->ct_execute("use $dbName");
while (($resultStat = $dbh->ct_results($resType)) == CS_SUCCEED) {};

$dbh->ct_execute("exec host_test");
while (($resultStat = $dbh->ct_results($resType)) == CS_SUCCEED)
{
        $dbh->ct_cancel(CS_CANCEL_ALL);
}

---------------------------------------------------------------------
Output is the following (note that value returned 
from host_name() is empty):

Server message: (IN serverMSG_cb)
Message Number: 5701, Severity 10, State 2, Line 1
Server: 'HARPO'
Message String: Changed database context to 'master'.


Server message: (IN serverMSG_cb)
Message Number: 5701, Severity 10, State 1, Line 1
Server: 'HARPO'
Message String: Changed database context to 'job_md'.


Server message: (IN serverMSG_cb)
Message Number: 0, Severity 10, State 1, Line 10
Server: 'HARPO'
 Procedure: 'host_test'
Message String: value from host_name() function is 

Server message: (IN serverMSG_cb)
Message Number: 0, Severity 10, State 1, Line 14
Server: 'HARPO'
 Procedure: 'host_test'
Message String: value from host_id() function is 3627                          

Server message: (IN serverMSG_cb)
Message Number: 0, Severity 10, State 1, Line 18
Server: 'HARPO'
 Procedure: 'host_test'
Message String: value from user_name() function is dbo

---------------------------------------------------------------------