OK I think this is to do with the default type that the column is being
bound to. I assume that name is a varchar column.
By default varchar's remove trailing spaces so insead of the implicit bind
what if you do...?

$sth->bind_param(1,'Mario ', {TYPE => SQL_CHAR});
$sth->execute;

This should preserve the trailing space and allow the select to find the
required record. 
I would have to say that trailing spaces should never be stored in the DB
and all character columns should be varchars but hey that's just my opinion
:)

Ken.

-----Original Message-----
From: Roland Lammel [mailto:[EMAIL PROTECTED]]
Sent: 03 April 2002 11:11
To: Amr Awadallah
Cc: Bart Lateur; [EMAIL PROTECTED]
Subject: Re: BUG: Perl DBI truncates Trailing Spaces from Placeholder
Bind Variables.


Does it work when using single quotes around the placeholder?

Instead of
  $sth->prepare('Select * From Employee Where Name = ?');
try
  $sth->prepare("Select * From Employee Where Name = '?'");

Cheers

+rl


Amr Awadallah wrote:
> 
> yes, this works:
> 
> Select * From Employee Where Name = 'Mario '
> 
> but this does not work:
> 
> $sth->prepare('Select * From Employee Where Name =
> ?');
> 
> and then you $sth->execute('Mario ');
> 
> (no offense to Mario of course)
> 
> -- Amr
> 
> --- Bart Lateur <[EMAIL PROTECTED]> wrote:
> > On Tue, 2 Apr 2002 23:16:47 -0800 (PST), Amr
> > Awadallah wrote:
> >
> > >Diagnosis: DBI removes trailing spaces from values
> > >before passing them through hence the query becomes
> > >
> > >  Select * From Employee Where Name = 'Mario'
> > >
> > >instead of the intended
> > >
> > >  Select * From Employee Where Name = 'Mario '
> >
> > You're sure
> >
> >       Select * From Employee Where Name = 'Mario '
> >
> > (no use of placeholders) does indeed work?
> >
> > --
> >       Bart.
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/

Reply via email to