#! /usr/bin/perl

# pl-dbi -- using DBI to access data in databases...
# $Id$
# Carlos Duarte <cgd@mail.teleweb.pt>, 990704/990808

use DBI; 

my $db_source = "dbi:Sybase:server=MY_SERVER;database=MY_DB"; 
my $db_user   = "my_user"; 
my $db_pass   = "my_pass"; 

my $dbh = DBI->connect($db_source, $db_user, $db_pass)	
			or die "can not connect: $DBI::errstr.";

my $sth = $dbh->prepare(qq{
	select SourceID 
	from tbl_QuoteSource 
	where Description = "foo"
}) or die "can not prepare: $DBI::errstr.";
$sth->execute or die "can not execute: $DBI::errstr."; 
while (my @a = $sth->fetchrow_array) {
	my $source_id = $a[0]; 
	# ...
}
$sth->finish; 
$dbh->disconnect; 
