NateTut has asked for the wisdom of the Perl Monks concerning the following question:

Brethren;
I am trying to get DBI & DBD-Teradata working at a new site. I have worked with this stuff before and it has worked great for me. Now however I'm stumped. I took the canonical DBI connect example and modified it for Teradata & my site:
#!/usr/bin/perl # # DBCInfo Query Based on Cannonical Perl DBI connection to Mysql. ###################################################################### +######## use DBI; $host = "Host Address"; # = "localhost", the server your are on. $db = "My User Name"; # your username (= login name = account n +ame ) $user = $db; # your Database name is the same as your accoun +t name. $pwd = "Password"; # Your account password # connect to the database. print(__PACKAGE__ . ':' . __LINE__ . ":Connecting...\n"); $dbh = DBI->connect( "DBI:Teradata:$host", $user, $pwd) or die "Connecting : $DBI::errstr\n "; print(__PACKAGE__ . ':' . __LINE__ . ":Connected.\n"); $sql = "SELECT * FROM DBC.DBCInfo"; # executing the SQL statement. $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 ($row = $sth->fetchrow_hashref) { foreach(sort(keys(%$row))) { print("$_:\[$row->{$_}\]\n"); } }
Of course the appropriate Host, user & password are filled in on the real script. When run it just tries to connect and dies. It doesn't come back from the connect back to the main program. No error messages or warnings either. I have traced it as far as I'm able and it seems to be getting a session number in Teradata.pm but the $dbh seems to be empty.
I'm using DBI v1.48, DBD-Teradata v1.20, Crypt-Blowfish v2.09 and Teradata V2R5.01
Any Ideas?

Replies are listed 'Best First'.
Re: Unable to Connect using DBI & DBD-Teradata
by jfroebe (Parson) on Aug 03, 2005 at 13:07 UTC

    Hi,

    First you will want to add "use warnings;" and "use strict;". According to http://www.tek-tips.com/viewthread.cfm?qid=577057, you need to explicitly use the DBD:Teradata module.

    use DBI; use DBD::Teradata; ....

    That's just my opinion though,

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: Unable to Connect using DBI & DBD-Teradata
by NateTut (Deacon) on Aug 03, 2005 at 12:54 UTC
    Ok, I know that Teradata is pretty obscure and the lack of error messages makes this tougher, but can anyone give me some tips on degugging this DBI/DBD problem?
Re: Unable to Connect using DBI & DBD-Teradata
by NateTut (Deacon) on Aug 04, 2005 at 15:19 UTC
    Well I still haven't given up on this, I will be screwed if I can't use Perl & Teradata! I thought the problem might be with our proxy server so I looked up DBD::Proxy. Here's my latest version with the DBD::Proxy stuff included:
    #!/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 acc +ount 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"); } }
    I had to install RPC::PlClient to get DBD::Proxy to work, and when I first tried my new version it complained about maxmessage size being too small. I had to increase that a bunch in RPC::PlClient to get DBD::Proxy to work, but when it did I got right back to the problem I started with which is my DBI::connect statemnent doesn't return. No error messages or warnings.

    Another weird thing is that I can connect to a local demo Teradata database just fine with Perl (it is TD V2R5.0) but I can't connect to our two servers here (TD V2R5.1). I have had Perl working in the past to V2R5.1 servers, but not on this PC or at this location.

    I'm running Windoze XP, ActiveState Perl 5.8.7, DBI 1.48 & DBD-Teradata 1.20

    Don't make me have to go back to VB! HELP! Update: I've traced it back to DBI::_new_handle. In this function another is called DBI::_setup_handle which doesn't seem to exist (at least I can't find it). Does anyone know what is going on here?