Here are the steps to make the DBD::ODBC module so that it will run with the DataDirect Connect for ODBC drivers on all Unix platforms:
1. Set up environment for ODBC.
- Source odbc.sh or odbc.csh in the ODBC install directory to add the ODBC libraries to the shared lib path
- Set ODBCINI variable to odbc.ini file
- Set ODBCHOME variable to the ODBC install directory(not the lib directory as specified in the DBD::ODBC documentation)
- Set DBI_DSN variable to dbi:ODBC:data_source_name, where data_souce_name is the name of the odbc.ini data source that you plan to use.
- Set DBI_USER variable to the database user
- Set DBI_PASS variable to the database password
2. Modify Makefile.PL and generate the Makefile
This file contains the following two lines by default:
$myodbc = 'intersolve'
if !$myodbc && -f "$odbchome/include/qeodbc.h"
You need to change these lines and move them so that they are ahead of the line:
$myodbc = 'unixodbc'
Change them to:
$myodbc = 'intersolve'
if -f '$odbchome/include/sqlunx.h';
If you do not move them ahead of the 'unixodbc' entry in the Makefile.PL script, then the script will think that you are using a generic Unix ODBC Driver Manager and the Makefile will not be generated correctly.
The file also contains:
elsif ($myodbc eq 'intersolve') {
$opts{DEFINE} = ""
print SQLH qq{#include <qeodbc.h>\n};
if (-f "$odbchome/include/sql.h") {
print "You seem to have the official header files.\n"
$opts{INC} .= " -I$odbchome/include"
print SQLH qq{#include <sql.h>\n#include <sqltypes.h>\n#include <sqlext.h>\n};
Change this to:
elsif ($myodbc eq 'intersolve') {
$opts{DEFINE} = ""
if (-f "$odbchome/include/sql.h") {
print "You seem to have the official header files.\n"
$opts{INC} .= " -I$odbchome/include"
print SQLH qq{#include <sql.h>\n#include <sqltypes.h>\n#include <sqlext.h>\n#include <sqlucode.h>\n};
Run the command:
perl Makefile.PL
If you run into an error like 'Makefile:90: *** missing separator. Stop.' try setting LANG=en_US.
NOTE: Make sure the line starting with "print SQLH qq..." and ending with <sqlucode.h>\n);" is one complete line with no line breaks; otherwise there will be problems with the resulting dbdodbc.h file.
3. Run the 'make' command to compile the DBD::ODBC module source code.
4. Issue the command 'make test' and all tests should complete successfully. The t/02simple test threw a 'String data, Right truncated' error on a fetch, but this did not appear in the corresponding ODBC trace.
5. Lastly, issue 'make install' to write the module to the perl directories.
After this is successful, you will be able to run all of the *.pl scripts in the mytest directory that came with the DBD::ODBC module.