|
|
sybperl-l Archive
Up Prev Next
From: "Sheree Hemphill" <sah18 at po dot cwru dot edu>
Subject: very basic db connection question
Date: Feb 9 1999 9:06PM
Hello. I am new to Sybperl, and I would like to use CTlib to connect to a
database. I can only seem to find code examples which connect to the Master
database, but none which show how to connect to a user-defined database.
Can someone give me an example of the syntax for this?
Thank you in advance!
Sheree
ps: The main sample code that I am trying to model after is listed below.
It was taken from "Sybperl 2.0: Using the Sybase::CTlib module" by Michael
Peppler. It worked perfectly for me.
#!/usr/local/bin/perl
# Load the Sybase::CTlib module:
use Sybase::CTlib;
# Allocate a new Database 'handle';
$dbh = new Sybase::CTlib 'sa', 'oracle8', 'helix';
# Send the query to the server:
$dbh->ct_execute("select uid, name from sysusers");
# Retrieve the result sets
while($dbh->ct_results($restype) == CS_SUCCEED) {
# Skip non-fetchable results:
next unless $dbh->ct_fetchable($restype);
# Retrieve actual data rows:
while(($uid, $name) = $dbh->ct_fetch) {
print "$uid - $name\n";
}
}
|