Handle assign/append of NULL values to collections correctly. Now

works consistently with how the rest of the library operates.  If
the value passed in is a null string, the value is set to null
This commit is contained in:
Andy Sautins 2001-09-11 21:03:58 +00:00
parent 919e7e9f69
commit 23fea6461d

View File

@ -4458,6 +4458,7 @@ PHP_FUNCTION(ocicollappend)
OCINumber num;
OCIString *ocistr = (OCIString *)0;
OCIInd new_ind = OCI_IND_NOTNULL;
OCIInd null_ind = OCI_IND_NULL;
OCIDate dt;
int inx;
double ndx;
@ -4472,6 +4473,26 @@ PHP_FUNCTION(ocicollappend)
WRONG_PARAM_COUNT;
}
/*
* Handle NULLS. For consistency with the rest of the OCI8 library, when
* a value passed in is a 0 length string, consider it a null
*/
convert_to_string_ex(arg);
if((*arg)->value.str.len == 0) {
CALL_OCI_RETURN(connection->error, OCICollAppend(
OCI(pEnv),
connection->pError,
(dword *)0,
&null_ind,
coll->coll));
if (connection->error) {
oci_error(connection->pError, "OCICollAppend - NULL", connection->error);
RETURN_FALSE;
}
RETURN_TRUE;
}
switch(coll->element_typecode) {
case OCI_TYPECODE_DATE:
convert_to_string_ex(arg);
@ -4719,6 +4740,7 @@ PHP_FUNCTION(ocicollassignelem)
oci_collection *coll;
OCINumber num;
OCIInd new_ind = OCI_IND_NOTNULL;
OCIInd null_ind = OCI_IND_NULL;
ub4 ndx;
int inx;
OCIString *ocistr = (OCIString *)0;
@ -4743,6 +4765,29 @@ PHP_FUNCTION(ocicollassignelem)
oci_error(connection->pError, "OCICollAssignElem", connection->error);
RETURN_FALSE;
}
/*
* Handle NULLS. For consistency with the rest of the OCI8 library, when
* a value passed in is a 0 length string, consider it a null
*/
convert_to_string_ex(val);
if((*val)->value.str.len == 0) {
CALL_OCI_RETURN(connection->error, OCICollAssignElem(
OCI(pEnv),
connection->pError,
ndx,
(dword *)0,
&null_ind,
coll->coll));
if (connection->error) {
oci_error(connection->pError, "OCICollAssignElem - NULL", connection->error);
RETURN_FALSE;
}
RETURN_TRUE;
}
switch(coll->element_typecode) {
case OCI_TYPECODE_DATE:
convert_to_string_ex(val);