#14013 [Com]: ocibindbyname strips trailing spaces

From: Date: Mon, 18 Aug 2003 16:52:37 +0000
Subject: #14013 [Com]: ocibindbyname strips trailing spaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46126@lists.php.net to get a copy of this message
ID: 14013 Comment by: m dot ford at lmu dot ac dot uk Reported By: az at i7 dot com dot au Status: Closed Bug Type: OCI8 related Operating System: Linux 2.2, Solaris 2.6 PHP Version: 4.0.6 New Comment: My mistake -- it's Closed, not Open ("green means Closed, green means Closed!"), but, to my mind, still without satisfactory explanation. Cheers! Previous Comments: ------------------------------------------------------------------------ [2003-08-18 11:49:55] m dot ford at lmu dot ac dot uk There still doesn't seem to be a satisfactory explanation posted here, and it's still Open, so could someone please address the salient issue: If the database column is defined as VARCHAR2, why does this strip trailing blanks on the inserted value: $text = " this line has spaces "; $st = ociparse($db, "insert into test values (:text)"); ocibindbyname($st, ":text", &$text, 2000); ociexecute($st); whilst this does not: $text = " this line has spaces "; $st = ociparse($db, "insert into test values '$text')"); ociexecute($st); ------------------------------------------------------------------------ [2003-01-31 09:36:03] jens dot reibiger at rp dot vaw dot com It seems, that I have the same problem using PHP 4.3.0 on Apache 1.3.22 with Oracle 8.1.7: When I use a OciBindByName, the string is trimed at the end. This small program uses the DUAL from Oracle just to return the input: $conn = OciLogon ("x","y","z"); $val = " X X "; // last letter is a " " (blank) // direct way without a bind variable $stm1 = OciParse($conn, "select '".$val."' from dual"); OciExecute($stm1); OciFetch($stm1); echo "<b>", OciResult($stm1, 1), "</b><br>\n"; // now using a bind variable: $stm2 = OciParse($conn, "select :input from dual"); OciBindByName($stm2, ":input", &$val, 10); OciExecute($stm2); OciFetch($stm2); echo "<b>", OciResult($stm2, 1), "</b><br>\n"; OciLogoff($conn); The output is: <b> X X </b><br> <b> X X</b><br> But I want to get the same output for the direct way and when I use a bind variable. Thank you for any idea how to get the string with tailing spaces right into Oracle using a bind variable. Best wishes, Jens ------------------------------------------------------------------------ [2002-04-13 08:58:13] thies@php.net try storing in a varchar2 firld, if you use CHAR oracle will trim traing spaces. ------------------------------------------------------------------------ [2001-11-11 06:49:19] az at i7 dot com dot au Erm, yeah, that's supposed to be '$id = 666;'. ------------------------------------------------------------------------ [2001-11-11 03:28:34] az at i7 dot com dot au When inserting text using named binds, PHP will strip trailing spaces. The same query on the same database using the same Oracle client libraries. (All Oracle 8.1.6) $db = ocilogon("u", "p", "sid"); $st = ociparse($db, "insert into test values (:id, :text)"); ocibindbyname($st, ":text", &$text, 2000); ocibindbyname($st, ":id", &$id, 22); $text = " this line has spaces "; $node_id = 666; ociexecute($st); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=14013&edit=1

« previous php.bugs (#46126) next »