pme has asked for the wisdom of the Perl Monks concerning the following question:
database core encoding: WE8MSWIN1252
NLS_LANG was set like this:
And it works as expected after NLS_LANG is unset like this:export NLS_LANG='AMERICAN_AMERICA.AL32UTF8'
Update: Runnable code sample is in 'readmore'unset NLS_LANG
At work I have an issue related to bind_param_inout(). If I use it just like in this example -- what is from 'man DBD::Oracle' -- then it works well.
My filename is inout.pl. If I run it as ./inout.pl then it works well. But run it as ./inout.pl 1 it fails miserably. The case is based on the sample given in the manual of DBD::Oracle. In the seconds case the array is loaded from Oracle with output of a select statement.
But if the array is created „dynamically” then execute() gives Oracle error.
Oracle error message:
./inout.pl 1
$VAR1 = [ 'abc', 'efg', 'hij' ]; input: $VAR1 = [ 'abc', 'efg', 'hij' ]; DBD::Oracle::st execute failed: ORA-06550: line 4, column 16: PLS-00382: expression is of wrong type ORA-06550: line 4, column 9: PL/SQL: Statement ignored ORA-06550: line 8, column 21: PLS-00382: expression is of wrong type ORA-06550: line 8, column 9: PL/SQL: Statement ignored (DBD ERROR: error possibly near <*> indicato +r at char 70 in 'DECLARE tbl SYS.DBMS_SQL.VARCHAR2_TABLE; BEGIN tbl := <*>:mytable; :cc := tbl.count(); tbl(1) := 'def'; tbl(2) := 'ijk'; :mytable := tbl; END; ') [for Statement "DECLARE tbl SYS.DBMS_SQL.VARCHAR2_TABLE; BEGIN tbl := :mytable; :cc := tbl.count(); tbl(1) := 'def'; tbl(2) := 'ijk'; :mytable := tbl; END; " with ParamValues: :cc=undef, :mytable=ARRAY(0x2519238)] at ./inout.p +l line 58. Use of uninitialized value $cc in print at ./inout.pl line 60. Result: cc= arr=$VAR1 = [];
#!/usr/local/bin/perl use strict; use warnings; use feature qw/say/; use Data::Dumper; use DBI; use DBD::Oracle qw(:ora_types); $| = 1; $Data::Dumper::Sortkeys = 1; my $dbh = DBI->connect('dbi:Oracle:...', '...', '...'); $dbh->do("alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'" +); $dbh->do("alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI +:SS.FF'"); my $aref = $dbh->selectcol_arrayref( <<EOD ); select 'abc' from dual union select 'efg' from dual union select 'hij' from dual EOD say Dumper($aref); my @arr; if (@ARGV) { @arr = @$aref; } else { @arr = ("abc", "efg", "hij"); } say 'input: ', Dumper(\@arr); #--------------------------------------------------------------------- +---- my $statement = <<EOD; DECLARE tbl SYS.DBMS_SQL.VARCHAR2_TABLE; BEGIN tbl := :mytable; :cc := tbl.count(); tbl(1) := \'def\'; tbl(2) := \'ijk\'; :mytable := tbl; END; EOD my $sth = $dbh->prepare($statement); $sth->bind_param_inout(":mytable", \\@arr, 10, { ora_type => ORA_VARCHAR2_TABLE, ora_maxarray_numentries => 100, } ) ; my $cc; $sth->bind_param_inout(":cc", \$cc, 100); $sth->execute(); print "Result: cc=", $cc, "\n", "\tarr=", Data::Dumper::Dumper(\@arr), "\n"; exit 0;
My perl version is 5.26 and DBD::Oracle version is v1.74.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD::Oracle bind_param_inout() issue
by choroba (Cardinal) on Jul 16, 2020 at 16:51 UTC | |
by pme (Monsignor) on Jul 17, 2020 at 07:58 UTC |