#!/usr/bin/perl use DBI; use strict; use warnings; use Data::Dumper; use feature 'say'; use ExtUtils::Installed; my @modules; my $installed = ExtUtils::Installed->new(); if (scalar(@ARGV) > 0) { @modules = @ARGV; } else { @modules = $installed->modules(); if (grep (/^DBD::ODBC/i, @modules)) { say "DBD::ODBC\t" . $installed->version('DBD::ODBC'); } } my $user = 'root'; my $pasw = 'root'; my @dsns = DBI->data_sources('ODBC'); foreach my $dsn (@dsns) { say $dsn; my $dbh = DBI->connect($dsn, $user, $pasw, {RaiseError => 1}, ) or die($DBI::errstr); my $table = 'sampleTable'; my $sth = $dbh->prepare("SELECT * FROM `$table`") or die($DBI::errstr); $sth->execute() or die($DBI::errstr); my $column = 'floatNumber'; while (my $row = $sth->fetchrow_hashref) { print Dumper $row; say "floatNumber = $$row{$column}"; } $sth = $dbh->column_info( undef, undef, $table, $column ); my $hash_ref = $sth->fetchall_hashref('TYPE_NAME'); print Dumper $hash_ref; } __END__ $ perl test.pl DBD::ODBC 1.60 dbi:ODBC:my-connector $VAR1 = { 'floatNumber' => '1.2345', 'Id' => 1 }; floatNumber = 1.2345 $VAR1 = { 'double' => { 'CHAR_OCTET_LENGTH' => undef, 'TABLE_NAME' => 'sampleTable', 'DECIMAL_DIGITS' => undef, 'BUFFER_LENGTH' => 8, 'SQL_DATETIME_SUB' => undef, 'TABLE_CAT' => '', 'NUM_PREC_RADIX' => undef, 'IS_NULLABLE' => 'NO', 'COLUMN_SIZE' => 15, 'REMARKS' => '', 'TABLE_SCHEM' => undef, 'COLUMN_DEF' => '0', 'TYPE_NAME' => 'double', 'NULLABLE' => '0', 'SQL_DATA_TYPE' => '8', 'ORDINAL_POSITION' => 1, 'DATA_TYPE' => '8', 'COLUMN_NAME' => 'floatNumber' } }; #### 1.49_3 2014-05-01 [CHANGE IN BEHAVIOUR] As warned years ago, this release removes the odbc_old_unicode attribute. If you have a good reason to use it speak up now before the next non-development release. [BUG FIXES] Fix rt89255: Fails to create test table for tests using PostgreSQL odbc driver. Change test suite to fallback on PRECISION if COLUMN_SIZE is not found. [ENHANCEMENTS] Added support for MS SQL Server Query Notification. See the new section in the pod. Added a currently undocumented (and experimental) odbc_describe_param method on a statement handle which takes a parameter number as the only argument and returns an array of the data type, parameter size, decimal digits and nullable (as per SQLDescribeParam). [DOCUMENTATION] Added FAQ on truncated column names with freeTDS. [MISCELLANEOUS] I have removed the "experimental" tag for odbc_getdiagfield and odbc_getdiagrec methods.