On Mon, 26 Aug 2002 23:43:00 -0700 Mark Dedlow <[EMAIL PROTECTED]> wrote:

> > >    $c = $dbh->prepare( 'insert into ct (COL) values (?)');
> > >    $c->execute('bind ');
> > > 
> > > The trailing blank doesn't make it to the db.  Doing the functional
> > > equivalent using native oracle tools works correctly.
> > > 
> > > Anyone know where this problem lies?
> > 
> > It's because DBD::Oracle passes strings as VARCHAR by default.  Add the
> > following to your script:
> > 
> >    # Near top
> >    use DBD::Oracle qw( :ora_types );
> > 
> >    # After prepare()
> >    # This only needs to be done once per prepare,
> >    #    to tell DBI what type the parameter is.
> >    #    You can pass the actual values via execute(), if you want.
> >    $c -> bind_param( 1, 'bind ', { "ora_type" => ORA_CHAR } );
>
> Thanks much. That solves the problem, although it doesn't explain
> why VARCHARs are blank truncated before being bound.  Is this
> just a DBI convention, or some SQL thing that I'm not aware of?  

There are several choices available for how to convert C character arrays
to VARCHAR in OCI.  The one chosen for DBD::Oracle removes trailing
whitespace.

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to