Seitenanfang

Connecting to Sybase ASE with Perl's DBI

Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.


CPAN has everything. Nearly everything and one of the modules is DBD::Sybase which connects to Microsoft SQL servers as well as Sybase ASE and iAnywhere servers, but there's a trick.

Every Sybase ASE server has a name (which is NOT the hostname!), assinged during installation. It's written to the /opt/sybase/interfaces file on the server and prepended to the service names (_XP, _BS and others). The file may be in another location if you changed the Sybase home directory during installation. Here is the content of my interfaces file:

SYASE	master tcp ether ase 5000	query tcp ether ase 5000

SYASE_BS master tcp ether ase 5001 query tcp ether ase 5001

SYASE_MS master tcp ether ase 5002 query tcp ether ase 5002

SYASE_XP master tcp ether ase 5003 query tcp ether ase 5003

SYASE_JSAGENT master tcp ether ase 4900 query tcp ether ase 4900

My server is called SYASE and this server name has to be part of the DBI connect string. Here is a sample:
dbi:Sybase:server=SYASE;host=ase.project.internal;port=5000;database=db_name;tdsLevel=CS_TDS_50;language=us_english
The TDS level should be optional, it may be left from the times where I used FreeTDS instead of Sybase OpenClient and the language is important if the server doesn't know your OS or login default language. The other parts are:
  • SYASE - the server's name as shown above
  • ase.project.internal - the servers's hostname or IP address
  • 5000 - the port where the server is listening for incoming connections. 5000 is Sybase default, I think.
  • db_name - the database name which should be opened on the server
 

You may also copy the interfaces file to your clients Sybase home directory (environment variable SYBROOT ), but you may have to update the server's hostname. The host and port options should become optional when using a correct interfaces file.

PS: Thanks to mattp and riba for asking the question which made me write this answer.

 

Noch keine Kommentare. Schreib was dazu

Schreib was dazu

Die folgenden HTML-Tags sind erlaubt:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>