I had this problem with Oracle as well, and someone passed along the useful code 
snippet included below.

This question comes up fairly frequently on this list.  Is there a FAQ somewhere that 
this could be added to if it isn't already there?

-dpf-

------------------------------------------------
This tip courtesy of Tim Bunce:

   use DBI qw(:sql_types);
   $sth->bind_param(1, $value, SQL_CHAR);

The problem is that OCI "smartly" strips trailing blanks off a bind value of 
type VARCHAR2.  Explicitly casting it to a CHAR datatype avoids this 
"intelligence".
------------------------------------------------


-----------------------
David P. Fannin
Database Administrator                                  [EMAIL PROTECTED]
UM-Rolla Computing and Information Services      FAX (573) 341-4216
URL  http://www.umr.edu/~dpf                   PHONE (573) 341-4841
-----------------------


-----Original Message-----
From: Jeff Hunter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 28, 2002 10:41 AM
To: [EMAIL PROTECTED]
Subject: Whitespace being truncated with Oracle



I am using perl 5.6.1 on Solaris 2.8.  My DBI version is DBI-1.21 and my 
DBD version is DBD-Oracle-1.12.  My Oracle version is 8.1.7.2 and my 
Oracle OCI version is 8.1.7.0.0.

I have setup a query that retrieves VARCHAR2(10) values from a table 
into a bound variable.  The values in the table are right padded with 
spaces.  When I retrieve the values, I can print them out exactly as 
they are in the table.  However, when I insert them into another table, 
the spaces at the end of the variable are stripped off.  I think the 
spaces are being truncated in the bind_param method.  Is this a bug with 
the DBD I am using?


Reply via email to