Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBD-Oracle CPAN distribution.

Report information
The Basics
Id: 76639
Status: rejected
Priority: 0/
Queue: DBD-Oracle

People
Owner: Nobody in particular
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: CHAR bind differences
The following queries are different: CREATE TABLE tester (NODE CHAR(5 BYTE)); INSERT INTO tester (node) values ('abcd'); ------------------------------------------------ use DBI; use Data::Dumper; my $dbh = DBI->connect("dbi:Oracle:", 'who', 'cares'); my $aref; my $aref = $dbh->selectall_arrayref("SELECT * FROM tester WHERE node = ?", undef, 'abcd'); print Dumper($aref); my $aref = $dbh->selectall_arrayref("SELECT * FROM tester WHERE node = 'abcd'"); print Dumper($aref); $dbh->disconnect(); ------------------------------------------------ $VAR1 = []; $VAR1 = [ [ 'abcd ' ] ];
Subject: Re: [rt.cpan.org #76639] CHAR bind differences
Date: Tue, 17 Apr 2012 15:19:08 -0400
To: bug-DBD-Oracle [...] rt.cpan.org
From: Yanick Champoux <champoux [...] pythian.com>
Fair warning: I'm having a bad case of the flu and am drugged to the gills on cold syrup, but doesn't Show quoted text
> my $aref = $dbh->selectall_arrayref("SELECT * FROM tester WHERE node = > ?", undef, 'abcd');
actually means "SELECT * FROM tester WHERE node = '' " by virtue of the first argument being undef? -- -- Attending Collaborate12 Apr 22-26? Catch Pythian’s stellar roster of speakers presenting on a wide array of hot Oracle technology topics. More at pythian.com/news
On Tue Apr 17 15:19:30 2012, PYTHIAN wrote: Show quoted text
> Fair warning: I'm having a bad case of the flu and am drugged to the > gills on cold syrup, but doesn't > >
> > my $aref = $dbh->selectall_arrayref("SELECT * FROM tester WHERE node
= Show quoted text
> > ?", undef, 'abcd');
> > actually means "SELECT * FROM tester WHERE node = '' " by virtue
of Show quoted text
> the first argument being undef?
Since you've got flu we'll let you off. The 2nd arg to selectall_arrayref is a hashref of attributes. Martin -- Martin J. Evans Wetherby, UK
Reproduced, I will look in to it. Martin -- Martin J. Evans Wetherby, UK
You need to read http://search.cpan.org/~pythian/DBD-Oracle- 1.42/lib/DBD/Oracle.pm#SPACES_AND_PADDING and] http://search.cpan.org/~pythian/DBD-Oracle- 1.42/lib/DBD/Oracle.pm#ora_ph_type The following works: use strict; use warnings; use DBI qw(:sql_types); use Data::Dumper; my $h = DBI->connect(); eval { $h->do(q/drop table mje/); }; $h->do(q/create table mje (a char(5))/); $h->do(q/insert into mje values(?)/, undef, 'abcd'); my $s = $h->prepare(q/select * from mje where a = ?/); $s->bind_param(1, 'abcd', {TYPE => SQL_CHAR} # <----- this make it work ); $s->execute; #my $x = $h->selectall_arrayref(q/select * from mje where a = ?/, undef, 'abcd'); # <--- this does not work my $x = $s->fetchall_arrayref; print Dumper($x); my $y = $h->selectall_arrayref(q/select * from mje where a = 'abcd'/); print Dumper($y); As does setting ora_ph_type => ORA_CHAR} in the connect call in which case you can still use selectall_arrayref. Funny, I knew Oracle had changed behaviour wrt to trailing spaces but I've never come across this myself before. I'm not sure if there is anything reasonable DBD::Oracle can do to avoid this without potentially breaking a lot of existing code. Blame Oracle for changing semantics. Martin -- Martin J. Evans Wetherby, UK
On Thu Apr 19 08:36:57 2012, MJEVANS wrote: Show quoted text
> Funny, I knew Oracle had changed behaviour wrt to trailing spaces but > I've never come across this myself before. I'm not sure if there is > anything reasonable DBD::Oracle can do to avoid this without
potentially Show quoted text
> breaking a lot of existing code. Blame Oracle for changing semantics.
Actually, I do know why I never see this - we ALWAYS use varchar not char. Martin -- Martin J. Evans Wetherby, UK