dreman has asked for the wisdom of the Perl Monks concerning the following question:

Hello group, I'm wondering if theres a simple way to connect to Sybase server without knowing the indepth knowledge of the ctlib or Sybperl. If so, all I want to do is run a stored procedure and capture the data. Thanks. dreman
  • Comment on Simpler way to connect to Sybase server

Replies are listed 'Best First'.
Re: Simpler way to connect to Sybase server
by mpeppler (Vicar) on Nov 27, 2001 at 23:21 UTC
    use Sybase::Simple; my $dbh = new Sybase::Simple $user, $pwd, $server; my $data = $dbh->ArrayOfHash("exec my_stored_proc"); # $data is an arrayref, where each row is a row from the proc. # This will also cleanly handle multiple result sets from # the same proc.
    You can of course do the same thing with DBI/DBD::Sybase, but I've not verified that the fetchall_*() routines actually fetch multiple result sets for you.

    Michael

Re: Simpler way to connect to Sybase server
by davorg (Chancellor) on Nov 27, 2001 at 22:14 UTC

    The DBI module together with the DBD::Sybase database driver will be a lot easier than using ctlib of Sybperl.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      There is a good example of using the Sybase DBI library on CPAN. Go to the script section and look for a script called sqlgui. I used to work with the author and this script contains a lot of excellent tricks for database programming.
Re: Simpler way to connect to Sybase server
by Biker (Priest) on Nov 27, 2001 at 21:35 UTC

    If you really, really, really don't want to learn how to program against a Sybase server (using ctlib/Sybperl/DBI/DBD) then you may consider executing the existing command line tool isql from inside your Perl script.

    f--k the world!!!!
    /dev/world has reached maximal mount count, check forced.

      Hehehehe... the very first version of sybperl (back in 1990) used two-way pipes over pseudo-ttys to talk to isql...

      :-)

      Michael

      thanks, but what would be a good reference to learn the basic of sybperl. Thanks

        Well, mpeppler the author of both Sybperl and DBD::Sybase is occasionally in the monastery, so he might jump in on this thread at any time.

        But my opinion (as someone who spent many years using Sybperl] is that the DBI interface is much easier to understand. There's a good book on it called Programming the Perl DBI.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you don't talk about Perl club."

Re: Simpler way to connect to Sybase server
by data64 (Chaplain) on Nov 28, 2001 at 07:09 UTC

    This actually depends on which type of sybase server you are trying to connect to. I know of the following 3 types:

    1. Sybase Adaptive Server Enterprise aka ASE (formerly known as Sybase SQL Server)
    2. iAnywhere SQL Anywhere aka ASA (formerly known as Adaptive Server Anywhere and way way back as Watcom SQL)
    3. Sybase IQ server


    Most people on this site seem to be familiar ASE. This is the enterprise category server meant to handle really large databases. It has support for hot standby and load balancing, etc. It does need a trained DBA to maintain though. If that's the server you are trying to connect to follow the suggestions from mpeppler.

    ASA is the smaller cousin. It is meant for slightly smaller databases. Its focus is to provide good performance out of the box and does not need a dba to maintain. Its great for mobile applications. If you are trying to connect to ASA, then Sybperl will not work. You have two options, get the ASA DBD driver from http://www.ianywhere.com at this page or use DBD::ODBC. I have used both with no problems.

    IQ is meant for OLAP like stuff. I believe it uses ASA under the covers.

      You're mostly right ;-)

      IQ does not use ASA 'under the covers'. It uses ASE or ASA for it's metadata and handles the data by itself.

      I'd suggest to fetch DBD::ASAny from CPAN to have a common source for all modules and make installation easier.