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? 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?

Perl 5.6.1
DBI 1.35
DBD::Oracle 1.12
Solaris 2.7

--
Matthew O. Persico


Reply via email to