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@/

In reply to Re: Help with DBD::Oracle Blobs by fizbin
in thread Help with DBD::Oracle Blobs by merlyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.