NAME
DBD::Sybase - Sybase database driver for the DBI module
SYNOPSIS
use DBI;
$dbh = DBI->connect("dbi:Sybase:", $user, $passwd);
# See the DBI module documentation for full details
DESCRIPTION
DBD::Sybase is a Perl module which works with the DBI module to provide access to Sybase databases.
Connecting to Sybase
The interfaces file
The DBD::Sybase module is built on top of the Sybase Open Client Client Library API. This library makes use of the Sybase interfaces file (sql.ini on Win32 machines) to make a link between a logical server name (e.g. SYBASE) and the physical machine / port number that the server is running on. The OpenClient library uses the environment variable SYBASE to find the location of the interfaces file, as well as other files that it needs (such as locale files). The SYBASE environment is the path to the Sybase installation (eg '/usr/local/sybase'). If you need to set it in your scripts, then you must set it in a BEGIN{}
block:
BEGIN {
$ENV{SYBASE} = '/opt/sybase/11.0.2';
}
$dbh = DBI->connect('dbi:Sybase', $user, $passwd);
Specifying the server name
The server that DBD::Sybase connects to defaults to SYBASE, but can be specified in two ways.
You can set the DSQUERY environement variable:
$ENV{DSQUERY} = "ENGINEERING";
$dbh = DBI->connect('dbi:Sybase:', $user, $passwd);
Or you can pass the server name in the first argument to connect():
$dbh = DBI->connect("dbi:Sybase:server=ENGINEERING", $user, $passwd);
Specifying other connection specific parameters
It is sometimes necessary (or beneficial) to specify other connection properties. Currently the following are supported:
- charset
-
Specify the character set that the client uses.
$dbh = DBI->connect("dbi:Sybase:charset=iso_1", $user, $passwd);
- language
-
Specify the language that the client uses.
$dbh = DBI->connect("dbi:Sybase:language=us_english", $user, $passwd);
- packetSize
-
Specify the network packet size that the connection should use. Using a larger packet size can increase performance for certain types of queries. See the Sybase documentation on how to enable this feature on the server.
$dbh = DBI->connect("dbi:Sybase:packetSize=8192", $user, $passwd);
These different parameters (as well as the server name) can be strung together by separating each entry with a semi-colon:
$dbh = DBI->connect("dbi:Sybase:server=ENGINEERING;packetSize=8192;language=us_english;charset=iso_1",
$user, $pwd);
Handling Multiple Result Sets
Sybase's Transact SQL has the ability to return multiple result sets from a single SQL statement. For example the query:
select b.title, b.author, s.amount
from books b, sales s
where s.authorID = b.authorID
order by b.author, b.title
compute sum(s.amount) by b.author
which lists sales by author and title and also computes the total sales by author returns two types of rows. The DBI spec doesn't really handle this situation, nor the more hairy
exec my_proc @p1='this', @p2='that', @p3 out
where my_proc
could return any number of result sets (ie it could perform an unknown number of select
statements.
I've decided to handle this by returning an empty row at the end of each result set - but it you suspect that there may be more data from your current query, then you can call any of the fetch
routines again, and they will return the first row in the next result set if there is one, or an empty row it this really was the last row.
BUGS
Placeholders (ie setting up a query with '?' parameters to be filled in later) are not supported at the moment, so $sth->bind_param() is not implemented, the @bind_values argument to $sth->execute is ignored, and the %attr and @bind_values parameters to $dbh->do are also ignored. Placeholders will be implemented in a future version.
SEE ALSO
AUTHOR
DBD::Sybase by Michael Peppler
COPYRIGHT
The DBD::Sybase module is Copyright (c) 1997 Michael Peppler. The DBD::Sybase module is free software; you can redistribute it and/or modify it under the same terms as Perl itself with the exception that it cannot be placed on a CD-ROM or similar media for commercial distribution without the prior approval of the author.
ACKNOWLEDGEMENTS
Tim Bunce for DBI, obviously.
See also "ACKNOWLEDGEMENTS" in DBI.