overwriting default path for data sources

  • dattaani

    I am having trouble overwriting the default path where unixODBC database manager tries to look for the odbc.ini and odbcinst.ini for the list of data sources from which to connect to a database to.

    I read in various docs that one could overwrite the default paths using the ODBCINI and ODBCSYSINI env variables.

    I have .NET code calling a CGI script which in turn calls a perl script to access the database.

    Some snippt of code is provided below :

    CGI script making call to the setup.env file  (exports necessary env variables) and the perl script

    system(". $RISK_ENV/env/setup.env; $RISK_ENV/bin/timeseries/bundle_audit_rpt_nz.pl $date $entityid");

    setup.env file which adds the two env variables to overwrite the data sources' path

    set -a
    ODBCINI = "/home/adatta/.odbc.ini"
    ODBCSYSIN = "/home/adatta'
    set +a

    The perl script tries to make a connection to the database using the perl DBI -> connect routine

    my $dbh =  DBI->connect("dbi:ODBC:$srvr", $dblogin , $dbpass)|| &mail_and_exit(-1, "Database connection not made: $DBI::errstr");

    Upon test, the code always fails when trying to connect to the database as it cant find the required data source.

    ERROR:  - DBI connect('NZSQL','scenario',…) failed: Server and/or port attributes are empty (SQL-HY000)

    Would really appreciate anyone who could provide some pointers as to what I may be doing wrong !

  • dattaani

    There was a typo in the setup.env code snippet. ODBCSYSIN should be ODBCSYSINI