Perl DBI Driver for Teradata on Linux


Perl DBI Driver for Teradata on Linux


I would like to know about a simple Perl DBI driver for Teradata (ODBC connection will do ) that can work from Linux. I could work with DBD::ODBC driver on Windows. However, the same does not work on Linux. I have tried downloading DBD-Teradata-1.52.tar.gz from the perl distribution sites, however the installation does not seem complete, as I still see an error that the driver is not found.

It would really help if someone can throw some light on how to connect to Teradata from Perl on Linux ( invoking bteq from perl is not the option that I am looking for).


Teradata Employee

Re: Perl DBI Driver for Teradata on Linux

DBD::OBDC module included in standard distributions is usually built against iODBC driver manager [iODBC]. Since Teradata ODBC driver is distributed with DataDirect driver manager, it is required to replace DBD::ODBC module with one built against DataDirect driver manager. Here is how to rebuild and replace DBD::ODBC module in ActivePerl distribution.

First, unpack:
cd /opt/ActivePerl-5.10/lib/auto/DBD
mkdir ODBC.original
mv ODBC/* ODBC.original
cd /tmp
tar -xvf DBD-ODBC-1.17.tar
cd DBD-ODBC-1.17

In order to build against DataDirect driver manager some changes in the building scripts are required. The makefile for the module is generated with Perl script in Makefile.PL file.

Update the lines in Makefile.PL:
$myodbc = 'intersolve'
if !$myodbc && -f "$odbchome/include/qeodbc.h";

As follows:
$myodbc = 'intersolve'
if !$myodbc && -f "$odbchome/include/sqlunx.h";

Move the updated lines before this line:
($myodbc, $odbclibdir) = find_iodbc($odbchome) if !$myodbc;

In addition, replace the following block:
print {$sqlhfh} qq{#include <qeodbc.h>\n};
if (-f "$odbcincdir/sql.h") {
print "You seem to have the official header files.\n";
$opts{INC} .= " -I$odbcincdir";
print {$sqlhfh} qq{#include <sql.h>\n#include <sqltypes.h>\n#include <sqlext.h>\n};

With this update:
$opts{DEFINE} = "";
if (-f "$odbchome/include/sql.h"){
print "You seem to have the official header files.\n";
$opts{INC} .= " -I$odbchome/include";
print {$sqlhfh} qq{#include <sql.h>\n#include <sqltypes.h>\n#include <sqlext.h>\n#include <sqlucode.h>\n};

Prepare the environment: variables:
export DBI_DSN=dbi:ODBC:Payroll
export DBI_USER= user
export DBI_PASS= password

Generate the makefile:
/opt/ActivePerl-5.10/bin/perl Makefile.PL

Finally, build and install:
make install

Re: Perl DBI Driver for Teradata on Linux

I'm using Perl 5.10.1 in production environement with 3 Teradata modules on AIX:

Teradata-SQL-0.08 ... small code, good perf, simplest
DBD-Teradata-1.52 ... for DBD compliant access
DBD-Teradata-12.001 ... for use to connect to Monitor

I've made several patches to Teradata-SQL given to the author