Set Up ODBC for Perl Connectivity on Linux - Aster Client

Teradata Aster® Client Guide

Product
Aster Client
Release Number
7.00
Published
May 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
hki1475000360386.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-2005
lifecycle
previous
Product Category
Software
To install the Aster Database ODBC driver and configure your environment to allow Perl scripts to connect to the database through the driver, follow these steps. These instructions assume you have installed Perl on your workstation, and that the Aster Database queen is reachable on the network. Follow these steps to provide an Aster Database connection your Perl scripts can use:
  1. Set up your /etc/resolv.conf and /etc/nsswitch.conf for accessing the Aster Database queen.
  2. The server connection information is set in the odbc.ini file, as explained earlier in this chapter. On Windows, the server connection information is set using the ODBC Data Source Administrator tool as explained in Set up ODBC for PHP.
  3. In /root type
    $ perl -eshell -MCPAN
  4. Get the latest packages and install them by entering:
    $ install Bundle::CPAN
    $ install DBI
  5. Rebuild and install DBD::ODBC.
    $ export LD_LIBRARY_PATH=/home/beehive/toolchain/x86_64-unknown-
linux-gnu/unixODBC-2.3.1/lib
    $ export PATH=$PATH:/home/beehive/toolchain/x86_64-unknown-linux-
gnu/unixODBC-2.3.1/bin
    $ which odbc_config
    /home/beehive/toolchain/x86_64-unknown-linux-gnu/unixODBC-2.3.1/
bin/odbc_config
    $ odbc_config --cflags -DHAVE_UNISTD_H -DHAVE_PWD_H 
-DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG=8
    $ perl -eshell -MCPAN
    cpan[1]> force install DBD::ODBC
  6. Run odbcinst -j to see where the .ini files are being picked up:
    $ odbcinst -j
  7. Run the following Perl script to check your installation.

    If everything is set correctly, it will run without an error. If you encounter problems, check the data source name (“DSN”) in the connect statement. In the example below, the username and password of the database are “beehive” and “beehive”:

    #!/usr/bin/perl
    use DBI;
    use DBD::ODBC;
    
    # Connect to ODBC DSN and turn off AutoCommit
    my $dbh = DBI->connect('dbi:ODBC:nc',"beehive","beehive",{AutoCommit => 0});
    
    $dbh->do("BEGIN");
    $dbh->do("set random_page_cost to '4'");
    $dbh->do("set enable_seqscan to 'off'");
    $dbh->disconnect;