Setting ODBC Connection Parameters in Perl
To set ODBC connection parameters, replace the DSN name with a semicolon delimited list of parameter name and value pairs in the source data string. Use the DSN parameter to tell DBD::ODBC which DSN to use, then add in other the other ODBC parameters you want to set. For example, the following code connects using a DSN named VerticaDSN and sets the connection's locale to en_GB.
#!/usr/bin/perl -w use strict; use DBI; # Instead of just using the DSN name, use name and value pairs. my $dbh = DBI->connect("dbi:ODBC:DSN=VerticaDSN;Locale=en_GB@collation=binary","ExampleUser","password123"); unless (defined $dbh) { # Conection failed. die "Failed to connect: $DBI::errstr"; } print "Connected!\n"; $dbh->disconnect();
See Data Source Name (DSN) Connection Properties for a list of the connection parameters you can set in the source data string.