in reply to Help with DBD::Oracle Blobs

By default, you need to go through bind_param for each parameter, and then call execute with no args. However, the DBI is explicitly built for subclassing, (see http://search.cpan.org/~timb/DBI/DBI.pm#Subclassing_the_DBI) so writing your own little wrapper is pretty easy:
# MyDBI subclasses DBI to make execute more friendly # to users who have to pass strange options to bind_param use strict; package MyDBI; use DBI; use vars qw(@ISA); @ISA = qw(DBI); package MyDBI::db; use vars qw(@ISA); @ISA = qw(DBI::db); package MyDBI::st; use vars qw(@ISA); @ISA = qw(DBI::st); sub execute { my ($sth, @args) = @_; my $paramspot = 1; while(@args) { my $p = shift @args; my $n = (@args)?$args[0]:''; if (ref($p) eq 'ARRAY') { $sth->bind_param($paramspot++, @$p) or return; } elsif (!ref($p) and ref($n) eq 'HASH') { shift @args; $sth->bind_param($paramspot++, $p, $n) or return; } else { $sth->bind_param($paramspot++, $p) or return; } } $sth->SUPER::execute(); }
Now in your main code, just use MyDBI->connect instead of DBI->connect (or pass the RootClass attribute as shown in the documentation), and then you can call execute as:
my $sth = $dbh->prepare(<<''); INSERT INTO sometable (x, y, z, blobby) VALUES (?, ?, ?, ?) $sth->execute('x', 'y', 'z', $blobdata, { ora_type => ORA_BLOB });
Or, if pulling off neighboring parameters as attributes offends your sensibilities, do:
$sth->execute('x', 'y', 'z', [$blobdata, { ora_type => ORA_BLOB }] );
-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/