On Mon, Mar 10, 2003 at 10:55:26PM -0500, Matthew O. Persico wrote:
> I am calling bind_param like this:
> 
> $sth->bind_param($col_idx,
>                                                       $value,
>                                                       {TYPE =>?DBI::SQL_VARCHAR});
> 
> for a column defined as varchar(8), not null
> 
> When $value == ' ' (one space)  or $value == ' ?' (two spaces), ?I get the error:
> 
> DBD::Oracle::st execute failed: ORA-01400: cannot insert NULL into
> ("AMGDEV"."AM_BILLING_PS_INTERFACE"."DOC_SEQ_NBR") (DBD ERROR:
> OCIStmtExecute)
> at am_billing_dd_load.pl line 1185.
> 
> When I hardcode a ' ' into the query (no binding), I don't get an
> error. When I hardcode '' into the query, I get the error.
> 
> Conclusion: somewhere in bind_param or whatever it is that it
> invokes, trailing blanks are being stripped before the call to the OCI.
> 
> I was able to get around this by using
> 
> $sth->bind_param($col_idx,
>                                                       $value,
>                                                       {TYPE =>?DBI::SQL_CHAR});
> 
> So, my question is, why is the DBI apparently taking it upon itself to enforce 
> string trimming for varchars?

It isn't. Oracle is.

> Shouldn't the server be responsible? And shouldn't the DBI behave
> the same for th same value whether it is bound or constant? Or is
> there something stupid I am missing?

Not stupid. Subtle. Check google for

        dbi ora_type char spaces

Tim.

Reply via email to