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: "Wechsler, Steven M" <WechslerSM at bernstein dot com>
Subject: Beginner question - doing async communications with Sybase
Date: Dec 4 1997 7:18PM

Greetings, all,

While I've been working with Sybase for years, this is my first foray
into the world of Open Client and/or Sybperl - if I ever get it
installed and working, that is.  I'm also relatively new to Perl, so
forgive me if my code looks amateurish.

Anyway, I'm looking to write a server monitor that will open connections
to a bunch of SQL servers at once, send some commands (like sp_who,
sp_lock, etc) and then retrieve the results once the commands are done
(or once they fail, if the server is down).

However, looking at the Sybperl CT-LIB documentation doesn't seem to
shed any light on how I can do this.  Sending commands and receiving
data back is fairly straightforward, but how can I tell that the SQL
server has sent the data before I start querying.  Can I do something
like this:


finished=1;	# flag
foreach $server (@dbh) { # dbh is an array of DB handles
  if (($rc = $server->ct_results(CS_CMD_DONE)) != CS_SUCCEED) {
    if ($rc == CS_FAIL) {
      # command failed; take appropriate action
    } elsif (($rc = $server->ct_results(CS_COMPUTE_RESULT)) ==
CS_SUCCEED {
      # does this mean that the command is still running?  if so,
      $finished=0;
      last; # in real life there'd be some sort of timeout, after
      # which we'd assume the server was down because it hadn't
      # responded in time.
    }
  }
}

if ($finished = 0) {
  # still need more time; go back and try again
}


Alternative suggestions are welcomed, especially if the one above won't
work.

Thanks,

Steve
--
Steven Wechsler/Sybase DBA/Sanford C. Bernstein 
WechslerSM@bernstein.com 

Support the Anti-SPAM amendment: http://www.cauce.org