Sybase::CTlib

Sybase::CTlib is a Sybase Client Library API.
Download

Sybase::CTlib Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Michael Peppler
  • Publisher web site:
  • http://search.cpan.org/~mewp/

Sybase::CTlib Tags


Sybase::CTlib Description

Sybase::CTlib is a Sybase Client Library API. SYNOPSIS use Sybase::CTlib; $dbh = Sybase::CTlib->new('user', 'pwd', 'server'); $dbh->ct_execute("select * from master..sysprocesses"); while($dbh->ct_results($restype) == CS_SUCCEED) { if($restype == CS_CMD_FAIL) { warn "Command failed!"; next; } next unless $dbh->ct_fetchable($restype); while(@data = $dbh->ct_fetch) { print "@datan"; } }Sybase::CTlib implements a subset of the Sybase Open Client Client Library API. For the most part the syntax is the same or very similar to the C language version, though in some cases the syntax varies a little to make the life of the perl programmer a little easier.It is a good idea to have the Sybase Client Library reference manual available when writing Sybase::CTlib programs. The Sybase manuals are available on-line at http://sybooks.sybase.com/. This manual is not a replacement for the Sybase manuals of Client Library - it is mostly aimed at illustrating the differences between the Perl and C versions of the API and to give a basic understanding of the APIs.General InformationThe basic philosphy of Client Library (CTlib) is to send a command to the server, and then process any results and fetch data as needed. Commands can be sent as plain SQL with one or more statements, or they can be sent as Remote Procedure Calls (RPCs).CTlib can connect and interact with any type of server that understands Sybase's Tabular Data Stream (TDS) protocol. This means that you can use CTlib to connect to a Sybase database server, a replication server, or any other type of server that was built with the Open Server API.A typical database request starts with a call to ct_execute() with the SQL command to be executed. This sends the request to the server. You the call ct_results($restype) in a loop until it stops returning CS_SUCCEED. ct_results() sets the $restype (the result type) for each result set. Some of the result types do not include any fetchable rows, hence the ct_fetchable() routine that returns TRUE if a $restype value is one that includes fetchable data: $dbh->ct_execute("select * from master..sysprocesses"); while($dbh->ct_results($restype) == CS_SUCCEED) { if($restype == CS_CMD_FAIL) { warn "Command failed!"; next; } next unless $dbh->ct_fetchable($restype); while(@data = $dbh->ct_fetch) { print "@datan"; } }ct_execute() will return CS_FAIL if there is an error on the client side. Errors that occur on the server will be reported via the server message callback handler (see ct_callback()), and will in most cases result in a $restype value of CS_CMD_FAIL.In the case of an error occuring inside a stored procedure or trigger the error is NOT reported via a CS_CMD_FAIL $restype. Instead the return status of the stored procedure ($restype of CS_STATUS_RESULT) is set to -4.It is a good idea to check for error conditions in-line (i.e. check the return value of all API calls), to check the value of $restype returned from ct_results() for a possible CS_CMD_FAIL status, to check any stored procedure status value (CS_STATUS_RESULT result set) for a negative value (which generally indicates that an error occured in the stored procedure), and install server and client error handlers via ct_callback() to flag any errors (server or client messages where the $severity value is greater than 10). Requirements: · Perl


Sybase::CTlib Related Software