Easysoft ODBC-ODBC Bridge

Do I have to set DBI_DSN, DBI_USER and DBI_PASS environment variables before running my Perl script?

Article:
00114
Last Reviewed:
25th November 2011
Revision:
2

Not unless your Perl script uses these environment variables.

The DBD::ODBC installation and test procedure requires these environment variables to be set because it calls DBI->connect without any arguments. From the DBI documentation:

=====
$dbh = DBI->connect($data_source, $username, $password, \%attr)

The $data_source value should begin with "dbi:driver_name:". The driver_name specifies the driver that will be used to make the connection. (Letter case is significant.)

As a convenience, if the $data_source parameter is undefined or empty, the DBI will substitute the value of the environment variable DBI_DSN. If just the driver_name part is empty (i.e., the $data_source prefix is "dbi::"), the environment variable DBI_DRIVER is used. If neither variable is set, then connect dies.

If $username or $password are undefined (rather than just empty), then the DBI will substitute the values of the DBI_USER and DBI_PASS environment variables, respectively. The DBI will warn if the environment variables are not defined.

=====
The documentation also suggests that using these environment variables is not recommended for security reasons and that this mechanism is intended to simplify testing. To avoid using the DBI_xyz environment variables specify the values directly in the call to DBI->Connect:

DBI->Connect('dbi:ODBC:dsn_name', 'username', 'password')

Obviously you can prompt for the username/password.

Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)


Oracle is a registered trademark of Oracle Corporation and/or its affiliates.