On 11/24/2004 05:07 AM, Hardy Merrill said:
Tim, can you elaborate a little? I've tried to find the referenced documentation but can't. I don't quite understand how a CHAR datatype can cause this problem.
CHAR column values are padded with spaces to the length of the column. When compared with a literal ('PAYMENT'), the SQL engine automatically adds the padding to the literal. When compared with a placeholder, the blank padded semantics are not available unless the placeholder type is CHAR.
The reference Tim gave describes this, look for comparison semantics in the Oracle SQL Reference for more information.
Tim Bunce <[EMAIL PROTECTED]> 11/24/04 07:35AM >>>
On Tue, Nov 23, 2004 at 10:13:30PM +0000, Bart Kelsey wrote:
I'm having some trouble with DBD::Oracle... When I execute this code: ***
$sth = $dbh->prepare("select * from abbrev where type = ?"); $sth->execute("PAYMENT"); while((@row) = $sth->fetchrow_array) { print(join(", ", @row), "\n"); } $sth->finish;
[Don't call finish at the end of fetch loops. See the docs.]
... no rows are returned. However, when I execute this code here:
$sth = $dbh->prepare("select * from abbrev where type =
'PAYMENT'");
... it correctly returns a row. Does anyone know what the problem
might be
I'd guess the "type" column is a CHAR field.
Try: use DBD::Oracle qw(:ora_types); ... $dbh->{ora_ph_type} = ORA_CHAR
before the prepare(). See http://search.cpan.org/~timb/DBD-Oracle-1.16/Oracle.pm#Database_Handle_Attributes
See also the String Comparison section in the Datatypes chapter of the Oracle OCI manual for more details.
-- Mac :}) ** I usually forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Cthulhu in 2004. Don't settle for the lesser evil.
