Doc #68537 [Asn]: oci_bind_by_name() should provide unity length description

From: Date: Thu, 04 Dec 2014 10:12:39 +0000
Subject: Doc #68537 [Asn]: oci_bind_by_name() should provide unity length description
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11721@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68537&edit=1 ID: 68537 User updated by: ikonta at yandex dot ru Reported by: ikonta at yandex dot ru Summary: oci_bind_by_name() should provide unity length description Status: Assigned Type: Documentation Problem Package: Documentation problem Operating System: Gentoo GNU/Linux PHP Version: 5.4.35 Assigned To: sixd Block user comment: N Private report: N New Comment: > The PHP OCI8 bind lengths are bytes, as you noted. The underlying > Oracle OCI C library documents this appropriately "This size is > always expected to be the size in bytes". > (http://docs.oracle.com/database/121/LNOCI/oci16rel003.htm#LNOCI17140) Not always. Depending on NLS settings I can reproduce another result. At least for currently used =dev-db/oracle-instantclient-basic-11.2.0.4 (and the same server). Although, documentation may describe as it _should_ work, but not as it really works. Or it wasn't properly updated to correctly describe UTF8 handling in Oracle 11g yet. If web-server is started in default locale, with also UTF8 charset: NLS_LANG=AMERICAN_AMERICA.UTF8 the quoted test script succeed. I.e. 9 chars, eight of which are two-byte length, are binded into variable with length limit 9 (unit, which should mean "byte"). Previous Comments: ------------------------------------------------------------------------ [2014-12-02 22:25:55] sixd@php.net The PHP OCI8 bind lengths are bytes, as you noted. The underlying Oracle OCI C library documents this appropriately "This size is always expected to be the size in bytes". (http://docs.oracle.com/database/121/LNOCI/oci16rel003.htm#LNOCI17140) The PHP OCI8 doc needs to have similar wording. There are no plans to allow PHP OCI8 specify the size in characters. ------------------------------------------------------------------------ [2014-12-02 08:32:49] ikonta at yandex dot ru Description: ------------ After migrating to UTF8, database provides two-way semantics for text data types: byte (for single byte encodings is a synonim of char) and char. http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT012 Length field in oci_bind_by_name() function forcely expect byte data size. For now we should update documentation noting it. For future development, ma be it is reasonable to add a modifier to switch between char and byte semantics. SQL> CREATE TABLE EXAMPLE ( MESSAGE VARCHAR2(16 CHAR) NOT NULL ); Oracle's client locale is: NLS_LANG=RUSSIAN_RUSSIA.AL32UTF8 Test script: --------------- <?php require_once("../inc/conn.inc"); $conn = conn("UPO"); $var = "тест-тест"; $stid = oci_parse($conn, 'INSERT INTO EXAMPLE VALUES (:bv)'); oci_bind_by_name($stid, ':bv', $var, 9); if (oci_execute($stid)) { echo ("insert OK"); oci_free_statement($stid); oci_close($conn); } else echo ("insert failed"); ?> Expected result: ---------------- If client's locale is NLS_LANG=RUSSIAN_CIS.CL8ISO8859P5 properly encoded (translated from UTF8 back to ISO-8859-5) script works fine. I expect the same for modern UTF8 locale. Or at least proper description of issued function: what and how should be corrected. Actual result: -------------- If client is configured to use UTF8 locale, quoted script failes with ORA-01461 (can bind a LONG value only for insert into a LONG column) error. Originally it was find for binding output variables for call of PL/SQL procedure. In that case the error message was ORA-06525: Length Mismatch for CHAR or RAW data ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68537&edit=1

« previous php.doc.bugs (#11721) next »