Subject: | bind_param_inout swap return values |
Hi,
DBD::Oracle bind_param_inout swap return values if:
- $max_len is greater or equal then 3584
- minimum one bind_param
- minimum two bind_param_inout
- return value type is number, no matter which column typ
See example.pl for more details.
Cheers,
robert
Subject: | example.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use DBI;
my $dbh = DBI->connect();
my $table_name = 'bin_param_bug' . time();
$dbh->do(qq{
CREATE TABLE $table_name (
name varchar2(10),
col_one varchar2(10),
col_two varchar2(10)
)
});
$dbh->do(qq{
CREATE OR REPLACE TRIGGER ai_$table_name
BEFORE INSERT ON $table_name
FOR EACH ROW BEGIN
SELECT 1,2
INTO :new.col_one,:new.col_two
FROM dual;
END;
});
my $sth = $dbh->prepare(qq{
INSERT INTO $table_name(name) VALUES (:name)
RETURNING col_one, col_two INTO :col_one, :col_two
});
$sth->bind_param(":name", 'name');
# $max_len <= 3583
# $max_len >= 3584
$sth->bind_param_inout(":col_one", \my $col_one, 3584);
$sth->bind_param_inout(":col_two", \my $col_two, 100);
$sth->execute;
print "col_one should be 1 but is: $col_one\n";
print "col_two should be 2 but is: $col_two\n";
$dbh->do(qq{DROP TABLE $table_name CASCADE CONSTRAINTS});
__END__
> ./example.pl
col_one should be 1 but is: 2
col_two should be 2 but is: 1
Oracle Server Version:
PRODUCT VERSION STATUS
--------------------------------------- ---------- ----------------
NLSRTL 11.2.0.2.0 Production
Oracle Database 11g Enterprise Edition 11.2.0.2.0 64bit Production
PL/SQL 11.2.0.2.0 Production
TNS for Linux: 11.2.0.2.0 Production
4 rows selected (0.05 seconds)
DBD::Oracle: 1.32
Oracle client version: 10204c_i386
Client OS:
ProductName: Mac OS X
ProductVersion: 10.7.2
BuildVersion: 11C74
Perl Version:
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
Platform:
osname=darwin, osvers=11.0, archname=darwin-thread-multi-2level
uname='darwin fifth.apple.com 11.0 darwin kernel version 11.0.0: sun may 29 13:02:55 pdt 2011; root:xnu-1699.22.44~4release_x86_64 x86_64 '
config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=llvm-gcc-4.2'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='llvm-gcc-4.2', ccflags ='-arch x86_64 -arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include',
optimize='-Os',
cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='llvm-gcc-4.2 -mmacosx-version-min=10.7', ldflags ='-arch x86_64 -arch i386 -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=, so=dylib, useshrplib=true, libperl=libperl.dylib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
USE_REENTRANT_API
Locally applied patches:
/Library/Perl/Updates/<version> comes before system perl directories
installprivlib and installarchlib points to the Updates directory
Built under darwin
Compiled at Jun 13 2011 14:45:32
%ENV:
PERL5LIB="/Users/rbo/Perl/main-ll/lib/perl5/darwin-thread-multi-2level:/Users/rbo/Perl/main-ll/lib/perl5"
PERL_AUTOINSTALL_PREFER_CPAN="1"
PERL_LOCAL_LIB_ROOT="/Users/rbo/Perl/main-ll"
PERL_MB_OPT="--install_base /Users/rbo/Perl/main-ll"
PERL_MM_OPT="INSTALL_BASE=/Users/rbo/Perl/main-ll"
@INC:
/Users/rbo/Perl/main-ll/lib/perl5/darwin-thread-multi-2level
/Users/rbo/Perl/main-ll/lib/perl5/darwin-thread-multi-2level
/Users/rbo/Perl/main-ll/lib/perl5
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12
.