php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14922 OCIBindByName forcing length to 1, even though 0 is a valid length
Submitted: 2002-01-07 18:37 UTC Modified: 2002-01-08 14:54 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: alester at flr dot follett dot com Assigned:
Status: Closed Package: OCI8 related
PHP Version: 4.1.0 OS: Solaris
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alester at flr dot follett dot com
New email:
PHP Version: OS:

 

 [2002-01-07 18:37 UTC] alester at flr dot follett dot com
It seems that the when oci8.c forces value_sz to 1 if it's 0 is bypassing a perfectly valid use of a length of 0: To signify a null.  

See:  http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a89857/oci03typ.htm

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-08 14:27 UTC] alester at flr dot follett dot com
Thies sent this to me:

    to pass a null thru a bound variable simply assign the
    special value NULL to the bound php-variable. the size
    supplied to ocibindbyname is simple the max-length of the
    inbound variable.

    ocibindbyname($stmt,"NAME",$name,32);
    $name = NULL;
    ociexecute($stmt);

    -> ":NAME" will have the value null in the query 

    please verify and close the report.

It seems incorrect to me to tweak a value that the underlying API expects to be able to handle.

Also, this handling of NULL should be documented in the OCIBindByName doc.
 [2002-01-08 14:54 UTC] thies@php.net
i'm pretty sure that the "If the value_sz parameter is zero, Oracle treats the bind variable as a null" is a 
new feature > 8.0. the "old" way is to set the indicator to -1 in the bind-in callback, which is what the 
oci8.c does.

i also believe that it makes way more sense to make the decision in the ociexecute (by looking at the actual 
php-variable) and not during bind for various reasons (think of mass inserts using bound variables).


BTW: you are welcome to contribute the documentation for NULL binds.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 23:01:29 2025 UTC