DBD-Oracle icon indicating copy to clipboard operation
DBD-Oracle copied to clipboard

use ora_type => ORA_NUMBER

Open NisSAM opened this issue 5 years ago • 1 comments

I found an error either in the documentation or in the code. According to the examples from the DBD :: Oracle documentation, it is allowed to { use ora_type => ORA_NUMBER } in the bind_param call. But actually it does not work as expected. One need to fix either the documentation or the code.

Below is a very simple test that shows what is happening.

use strict; use warnings;
use DBI;
use DBD::Oracle qw/:ora_types/;

my $dbh = DBI->connect('DBI:Oracle:odb2', 'scott', 'tiger'
  , {PrintError => 1, AutoCommit => 1, RaiseError => 1, PrintWarn => 1});

my $stmt = $dbh->prepare("select dump(:num) from dual");
   $stmt->bind_param(':num', 1234567890, { ora_type => ORA_NUMBER });
   $stmt->execute;
   print $stmt->fetch->[0], "\n\n";

   $stmt = $dbh->prepare("select :num + 1 from dual");
   $stmt->bind_param(':num', 1234567890, { ora_type => ORA_NUMBER });
   $stmt->execute;
   print $stmt->fetch->[0], "\n\n";

   $stmt = $dbh->prepare("select :num + 1 from dual");
   $stmt->bind_param(':num', 1234567890, { ora_type => SQLT_INT });
   $stmt->execute;
   print $stmt->fetch->[0], "\n\n";

NisSAM avatar May 18 '20 17:05 NisSAM

Good bug report, thanks for that

djzort avatar May 20 '20 17:05 djzort