PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #1725

sysdate, to_date, fail on autoExecute with Oracle

Details

Submitted2004-06-26 04:35 UTC
Fromflinn at activeintra dot net
Assigneddanielc
StatusWont fix
PackageDB
PHP Version4.3.6
OSSolaris (SunOS 5.8)
Roadmaps(Not assigned)

Comments

[2004-06-26 04:35 UTC] flinn at activeintra dot net

Description:
------------
Oracle's sysdate and to_date functions do not work with
the date data type when trying to autoExecute on Oracle.
Since the DB class uses ocibindbyname with a variable
size of -1 when creating the autoExecute statement the
DB class inherits a problem with the function. The
issue is described in a user note on the PHP Manual:

yepster at hotmail dot com
09-Mar-2004 03:32
If you get ora-01460 you might want to check whether the
OCIBindByName was done with -1 on a date field, which on
bind time (not execute time) was bound to a php variable
with size 0. (e.g.: $var=""; bind var to date with
length -1; loop; $var=realdate; execute will give ora
-01460 -> unreasonable or unimplemented conversion).
Changing the initial $var to a good length, or do the
bind with the right size of your date in string format
representation instead of -1 will solve it.

Reproduce code:
---------------
$arr = array('somedate' => 'sysdate');

$irecord = $DB->autoExecute('sometable', $arr, DB_AUTOQUERY_INSERT);

if (PEAR::isError($DB)) {
$DB->getDebugInfo();
} else {
echo "no errors";
}

Expected result:
----------------
no errors

Actual result:
--------------
[nativecode=ORA-01858: a non-numeric character was found
where a numeric was expected]