#!/usr/bin/perl # # DBCInfo Query Based on Cannonical Perl DBI connection to Mysql. ############################################################################## use strict; use warnings; use DBI; use DBD::Proxy; use DBD::Teradata; my $host = "Host.Address"; # = "localhost", the server your are on. my $db = "User"; # your username (= login name = account name ) my $user = $db; # your Database name is the same as your account name. my $pwd = 'Password'; # Your account password # connect to the database. print(__PACKAGE__ . ':' . __LINE__ . ":Connecting...\n"); my $dbh = DBI->connect( "DBI:Proxy:hostname=Proxy.Server.Address;port=8080;dsn=DBI:Teradata:$host", $user, $pwd) or die "Connecting : $DBI::errstr\n "; print(__PACKAGE__ . ':' . __LINE__ . ":Connected.\n"); my $sql = "SELECT * FROM DBC.DBCInfo"; # executing the SQL statement. my $sth = $dbh->prepare($sql) or die "preparing: ",$dbh->errstr; $sth->execute or die "executing: ", $dbh->errstr; print "content-type: text/html\n\n"; # one of the functions to retrieve data from the table results # check perldoc DBI for more methods. while (my $row = $sth->fetchrow_hashref) { foreach(sort(keys(%$row))) { print("$_:\[$row->{$_}\]\n"); } }