FW: DBD::ODBC fetch is returning string for integer

"Manikantan, Madhunapanthula_Naaga" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <1485868F0AD5AC4EB1A9047C9D6FFCE03B651296@MAILHYDMB1A.winmail.deshaw.com>
Forwarding this to DBI dev as well. Any help is very much appreciated !!

Thanks

_____________________________________________
From: Manikantan, Madhunapanthula_Naaga
Sent: Friday, May 18, 2012 7:11 PM
To: [email protected]
Cc: [email protected]
Subject: DBD::ODBC fetch is returning string for integer


Hello Evans/DBi-users,

DBD::ODBC is returning strings for integers.  This results in incorrect values for  bit wise operators.  (for ex:- $e='16'; $f = '32'  print $e & $f returns 12 instead of zero ). Is there a setting that can help us return integers as 'integers'.

I am using EasySoft Driver via DBD::ODBC to connect to Microsoft SQL Server 2008 R2 from Linux RHEL 6.2.

Version information
---
Perl  : 5.10.1
DBI   : 1.609
DBD::ODBC : 1.30_5

Please use the below code to reproduce the issue and let me know if I you need more information.

Help much appreciated !!

Thanks



# Create temp_check and inserted one row with values (100, 10.234 and 'test')

CREATE TABLE temp_check
( a int,
  b float,
  c varchar (100)
)
INSERT INTO temp_check VALUES (100, 10.234000, 'test')


PERL snippet
----------------------

use DBI;
use Data::Dumper;

$dbh = DBI->connect('dbi:ODBC:DSN=SERVER1','***','***');
$dbh->{TraceLevel}=15;

$sth = $dbh->prepare('select * from sandbox..temp_check where a=100');
#$sth = $dbh->prepare('select * from sandbox..temp_check where a=100', {odbc_describe_parameters => 0});

$sth->execute();

for ($i = 1; $i <= $sth->{NUM_OF_FIELDS}; $i++) {
    print "Column $sth->{NAME}->[$i -1] is of type $sth->{TYPE}->[$i -1]\n";
}

$rows = $sth->fetchall_arrayref();
print Dumper($rows);

Column a is of type 4
Column b is of type 6
Column c is of type 12

$VAR1 = [
          [
            '100',
            '10.234',
            'test'
          ]
        ];
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.