[svn:dbd-oracle] r15006 - in dbd-oracle/trunk: . examples lib/DBD/Oracle
[email protected] Fri, 18 Nov 2011 11:39:33 -0800 (PST)
| Newsgroups | perl.dbd.oracle.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: yanick
Date: Fri Nov 18 11:39:31 2011
New Revision: 15006
Added:
dbd-oracle/trunk/.gitignore
dbd-oracle/trunk/examples/inserting_longs.pl
dbd-oracle/trunk/examples/read_long_via_blob_read.pl
Modified:
dbd-oracle/trunk/Changes
dbd-oracle/trunk/MANIFEST
dbd-oracle/trunk/MANIFEST.SKIP
dbd-oracle/trunk/Oracle.pm
dbd-oracle/trunk/lib/DBD/Oracle/Troubleshooting.pm
Log:
Merge branch 'master' into HEAD
Conflicts:
Changes
MANIFEST
Oracle.pm
lib/DBD/Oracle/Troubleshooting.pm
Added: dbd-oracle/trunk/.gitignore
==============================================================================
--- (empty file)
+++ dbd-oracle/trunk/.gitignore Fri Nov 18 11:39:31 2011
@@ -0,0 +1,13 @@
+pm_to_blib
+MYMETA.yml
+Makefile
+Makefile.old
+Oracle.bs
+Oracle.c
+Oracle.o
+Oracle.xsi
+blib
+MYMETA.json
+dbdimp.o
+mk.pm
+oci8.o
Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes (original)
+++ dbd-oracle/trunk/Changes Fri Nov 18 11:39:31 2011
@@ -1,6 +1,6 @@
Revision history for DBD::Oracle
-Changes in DBD-Oracle XXX
+Changes in DBD-Oracle 1.35_00 (18-11-2011)
[BUG FIXES]
- if bind_col is called with a TYPE but no bind attributes like
@@ -12,7 +12,7 @@
and no data was returned (Martin J. Evans)
- Fix test so it works with perl compiled with -Duselongdouble [RT71852]
- Apply patch from Charles Jardine for better building against a full
- Oracle 11 install [72463] (Martin J. Evans)
+ Oracle 11 install [RT72463] (Martin J. Evans)
[DOCUMENTATION]
- Added notes to bind_col documenting the fact that setting a TYPE
@@ -21,6 +21,7 @@
- fix typo (thanks to Julián Moreno Patiño) [RT72038]
- shuffle POD around to improve documentation flow [RT72252]
- major tidying up of the connect() documentation. (by Gwen Shapira)
+ - Moved LONG examples out of POD and into examples/
[OTHER]
- Commented out some functions in oci8.c which were not used to
Modified: dbd-oracle/trunk/MANIFEST
==============================================================================
--- dbd-oracle/trunk/MANIFEST (original)
+++ dbd-oracle/trunk/MANIFEST Fri Nov 18 11:39:31 2011
@@ -82,3 +82,6 @@
examples/ora_explain.pl
t/00versions.t
lib/DBD/Oracle/Troubleshooting.pm
+examples/inserting_longs.pl
+examples/read_long_via_blob_read.pl
+t/rt13865.t
Modified: dbd-oracle/trunk/MANIFEST.SKIP
==============================================================================
--- dbd-oracle/trunk/MANIFEST.SKIP (original)
+++ dbd-oracle/trunk/MANIFEST.SKIP Fri Nov 18 11:39:31 2011
@@ -17,3 +17,15 @@
~$
^\.git
^xt
+dbdimp.o
+Makefile.old
+mk.pm
+MYMETA.json
+MYMETA.yml
+oci8.o
+Oracle.bs
+Oracle.c
+Oracle.o
+Oracle.xsi
+pm_to_blib
+
Modified: dbd-oracle/trunk/Oracle.pm
==============================================================================
--- dbd-oracle/trunk/Oracle.pm (original)
+++ dbd-oracle/trunk/Oracle.pm Fri Nov 18 11:39:31 2011
@@ -7,7 +7,7 @@
require 5.006;
-$DBD::Oracle::VERSION = '1.33_00';
+$DBD::Oracle::VERSION = '1.35_00';
my $ORACLE_ENV = ($^O eq 'VMS') ? 'ORA_ROOT' : 'ORACLE_HOME';
@@ -5306,6 +5306,7 @@
and even get to 10. I am not sure what the 11g client can connect to.
=back
+
=head1 BUGS AND LIMITATIONS
There is a known problem with the 11.2g Oracle client and the
Added: dbd-oracle/trunk/examples/inserting_longs.pl
==============================================================================
--- (empty file)
+++ dbd-oracle/trunk/examples/inserting_longs.pl Fri Nov 18 11:39:31 2011
@@ -0,0 +1,43 @@
+#!perl
+
+use strict;
+use warnings;
+
+use DBI;
+
+my $db = DBI->connect( 'dbi:Oracle:mydb', 'username', 'password' );
+
+my $table = 'TABLE';
+my %clauses;
+my %attrib;
+my @types;
+my $longrawtype;
+my @row;
+
+# Assuming the existence of @row and an associative array (%clauses) containing the
+# column names and placeholders, and an array @types containing column types ...
+
+my $ih = $db->prepare("INSERT INTO $table ($clauses{names})
+ VALUES ($clauses{places})")
+ or die "prepare insert into $table: " . $db->errstr;
+
+$attrib{'ora_type'} = $longrawtype; # $longrawtype == 24
+
+##-- bind the parameter for each of the columns
+for my $i ( 0..$#types ) {
+
+ ##-- long raw values must have their type attribute explicitly specified
+ if ($types[$i] == $longrawtype) {
+ $ih->bind_param($i+1, $row[$i], \%attrib)
+ || die "binding placeholder for LONG RAW " . $db->errstr;
+ }
+ ##-- other values work OK with the default attributes
+ else {
+ $ih->bind_param($i+1, $row[$i])
+ || die "binding placeholder" . $db->errstr;
+ }
+}
+
+$ih->execute || die "execute INSERT into $table: " . $db->errstr;
+
+
Added: dbd-oracle/trunk/examples/read_long_via_blob_read.pl
==============================================================================
--- (empty file)
+++ dbd-oracle/trunk/examples/read_long_via_blob_read.pl Fri Nov 18 11:39:31 2011
@@ -0,0 +1,31 @@
+#!perl
+
+use strict;
+use warnings;
+
+use DBI;
+
+my $dbh = DBI->connect( 'dbi:Oracle:mydb', 'username', 'password' );
+
+$dbh->{RaiseError} = 1;
+$dbh->{LongTruncOk} = 1; # truncation on initial fetch is ok
+
+my $sth = $dbh->prepare("SELECT key, long_field FROM table_name");
+$sth->execute;
+
+while ( my ($key) = $sth->fetchrow_array) {
+ my $offset = 0;
+ my $lump = 4096; # use benchmarks to get best value for you
+ my @frags;
+ while (1) {
+ my $frag = $sth->blob_read(1, $offset, $lump);
+ last unless defined $frag;
+ my $len = length $frag;
+ last unless $len;
+ push @frags, $frag;
+ $offset += $len;
+ }
+ my $blob = join "", @frags;
+ print "$key: $blob\n";
+}
+
Modified: dbd-oracle/trunk/lib/DBD/Oracle/Troubleshooting.pm
==============================================================================
--- dbd-oracle/trunk/lib/DBD/Oracle/Troubleshooting.pm (original)
+++ dbd-oracle/trunk/lib/DBD/Oracle/Troubleshooting.pm Fri Nov 18 11:39:31 2011
@@ -63,78 +63,10 @@
Oracle technical support (and not the dbi-users mailing list).
-=head1 LONGS
+=head1 USING THE LONG TYPES
-Some examples related to the use of LONG types.
-
-For complete working code, take a look at the t/long.t file.
-
-You must fetch the row before you can fetch the longs associated with
-that row. In other words, use the following algorithm...
-
- 1) login
- 2) prepare( select ... )
- 3) execute
- 4) while rows to fetch do
- 5) fetch row
- 6) repeat
- 7) fetch chunk of long
- 8) until have all of it
- 9) done
-
-If your select selects more than one row the need for step 4 may
-become a bit clearer... the blob_read always applies to the row
-that was last fetched.
-
-=head2 Example for reading LONG fields via blob_read
-
- $dbh->{RaiseError} = 1;
- $dbh->{LongTruncOk} = 1; # truncation on initial fetch is ok
- $sth = $dbh->prepare("SELECT key, long_field FROM table_name");
- $sth->execute;
- while ( ($key) = $sth->fetchrow_array) {
- my $offset = 0;
- my $lump = 4096; # use benchmarks to get best value for you
- my @frags;
- while (1) {
- my $frag = $sth->blob_read(1, $offset, $lump);
- last unless defined $frag;
- my $len = length $frag;
- last unless $len;
- push @frags, $frag;
- $offset += $len;
- }
- my $blob = join "", @frags;
- print "$key: $blob\n";
- }
-
-=head2 Example for inserting LONGS
-
- # Assuming the existence of @row and an associative array (%clauses) containing the
- # column names and placeholders, and an array @types containing column types ...
-
- $ih = $db->prepare("INSERT INTO $table ($clauses{names})
- VALUES ($clauses{places})")
- || die "prepare insert into $table: " . $db->errstr;
-
- $attrib{'ora_type'} = $longrawtype; # $longrawtype == 24
-
- ##-- bind the parameter for each of the columns
- for ($i = 0; $i < @types; $i++) {
-
- ##-- long raw values must have their type attribute explicitly specified
- if ($types[$i] == $longrawtype) {
- $ih->bind_param($i+1, $row[$i], \%attrib)
- || die "binding placeholder for LONG RAW " . $db->errstr;
- }
- ##-- other values work OK with the default attributes
- else {
- $ih->bind_param($i+1, $row[$i])
- || die "binding placeholder" . $db->errstr;
- }
- }
-
- $ih->execute || die "execute INSERT into $table: " . $db->errstr;
+Some examples related to the use of LONG types are available in
+the C<examples/> directory of the distribution.
=head1 LINUX