How to access sybase with PERL

Here is what I have so far. I can not create the db connection.

#!/usr/local/bin/perl
require "sybutil.pl";
use Sybase::DBlib;
use DBI;
my $dbhandle=&opendb;
sub opendb{
    my $server ="abc.nam.aa.net";
    my $user = "sam";
    my $password = "abc123";
    #print "Connecting to $server as $user and $password\n";
    my $dbfh= new Sybase::DBlib($user, $password, $server);
    if(!defined($dbfh)) {
        die("Cannot connect to server.\n");
    }
    printf "Open database '%s' with id '%s' successful\n", $server, $user;
    return $dbfh;
}

How do I access sybase with PERL?

Answers


As I recall, the format for $server, should be the the same as the entry in the interfaces file ($SYBASE/interfaces or %SYBASE%/sql.ini) for that particular server. It's ususally the same value as returned by the query select @@servername

The hostname/ip and port are listed in the interfaces file, and the Sybase libraries will use that file to do the lookup.

More information on this as well as code samples can be found at Michael Peppler's site. Michael maintains the Sybperl mailing list, and really has a great amount of information on his site.


Need Your Help

Include blank values in array from foreach statement

javascript php mysql arrays

EDIT: I tried to simplify it before but I think I'll just lay it all out there as it may clear up some confusion as to what I am trying to achieve.

How to update the cells of a table from a combobox?

java swing jtable jcombobox

import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComponent;

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.