|
|
Archives of the TeradataForum
Message Posted: Thu, 22 Jun 2000 @ 21:39:47 GMT
Subj: | | Re: C Preprocessor2 Alternatives |
|
From: | | Mark Landry |
I've attached a sample program so you can see how it works.
#!/usr/local/bin/perl
# sample code to access Teradata tables using ODBC from NT or Unix
use DBI;
use DBD::ODBC;
$DSN = "Teradata (4750:NSDW)"; # configured with ODBC Administrator
$dbh = DBI->connect("dbi:ODBC:$DSN", "myTDname", "myTDpassword",
{RaiseError => 1}) or die;
$sth = $dbh->prepare("select * from dbc.databases");
$sth->execute;
$, = "\t"; # tab-delimited output
print "@{$sth->{NAME}}\n"; # print the column names
# print each row
while ( @row = $sth->fetchrow ) {
print "@row\n";
}
$sth->finish;
$dbh->disconnect;
1;
| |