cvs: /php4/ext/oci8 oci8.c php_oci8.h

From: Date: Fri, 03 Mar 2000 01:28:57 +0000
Subject: cvs: /php4/ext/oci8 oci8.c php_oci8.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-11417@lists.php.net to get a copy of this message
jymartin Thu Mar 2 17:28:57 2000 EDT Modified files: /php4/ext/oci8 oci8.c php_oci8.h Log: Added functions to retrieve scale, precision and raw oracle data type for columns. Index: php4/ext/oci8/oci8.c diff -u php4/ext/oci8/oci8.c:1.61 php4/ext/oci8/oci8.c:1.62 --- php4/ext/oci8/oci8.c:1.61 Wed Mar 1 00:17:33 2000 +++ php4/ext/oci8/oci8.c Thu Mar 2 17:28:27 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.61 2000/03/01 08:17:33 thies Exp $ */ +/* $Id: oci8.c,v 1.62 2000/03/03 01:28:27 jymartin Exp $ */ /* TODO list: * @@ -159,7 +159,10 @@ PHP_FUNCTION(ocicolumnisnull); PHP_FUNCTION(ocicolumnname); PHP_FUNCTION(ocicolumnsize); +PHP_FUNCTION(ocicolumnscale); +PHP_FUNCTION(ocicolumnprecision); PHP_FUNCTION(ocicolumntype); +PHP_FUNCTION(ocicolumntyperaw); PHP_FUNCTION(ociexecute); PHP_FUNCTION(ocifetch); PHP_FUNCTION(ocicancel); @@ -226,7 +229,10 @@ PHP_FE(ocicolumnisnull, NULL) PHP_FE(ocicolumnname, NULL) PHP_FE(ocicolumnsize, NULL) + PHP_FE(ocicolumnscale, NULL) + PHP_FE(ocicolumnprecision, NULL) PHP_FE(ocicolumntype, NULL) + PHP_FE(ocicolumntyperaw, NULL) PHP_FE(ociexecute, NULL) PHP_FE(ocicancel, NULL) PHP_FE(ocifetch, NULL) @@ -1273,6 +1279,32 @@ outcol->storage_size4 = outcol->data_size; outcol->retlen = outcol->data_size; + statement->error = + oci_error(statement->pError, + "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_SCALE", + OCIAttrGet((dvoid *)param, + OCI_DTYPE_PARAM, + (dvoid *)&outcol->scale, + (dvoid *)0, + OCI_ATTR_SCALE, + statement->pError)); + if (statement->error) { + return 0; /* XXX we lose memory!!! */ + } + + statement->error = + oci_error(statement->pError, + "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_PRECISION", + OCIAttrGet((dvoid *)param, + OCI_DTYPE_PARAM, + (dvoid *)&outcol->precision, + (dvoid *)0, + OCI_ATTR_PRECISION, + statement->pError)); + if (statement->error) { + return 0; /* XXX we lose memory!!! */ + } + statement->error = oci_error(statement->pError, "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_NAME", @@ -3034,10 +3066,65 @@ if (outcol == NULL) { RETURN_FALSE; } - RETURN_LONG(outcol->data_size); + + oci_debug("ocicolumnsize: %16s, retlen = %4d, retlen4 = %d, data_size = %4d, storage_size4 = %4d, indicator %4d, retcode = %4d", + outcol->name,outcol->retlen,outcol->retlen4,outcol->data_size,outcol->storage_size4,outcol->indicator,outcol->retcode); + + /* Handle data type of LONG */ + if(outcol->data_type == SQLT_LNG){ + RETURN_LONG(outcol->storage_size4); + }else{ + RETURN_LONG(outcol->data_size); + } } /* }}} */ +/* {{{ proto int OCIColumnScale(int stmt, int col) + Tell the scale of a column */ + +PHP_FUNCTION(ocicolumnscale) +{ + zval **stmt, **col; + oci_statement *statement; + oci_out_column *outcol; + + if (zend_get_parameters_ex(2, &stmt, &col) == FAILURE) { + WRONG_PARAM_COUNT; + } + + OCI_GET_STMT(statement,stmt); + + outcol = oci_get_col(statement, -1, col); + if (outcol == NULL) { + RETURN_FALSE; + } + RETURN_LONG(outcol->scale); +} + +/* }}} */ +/* {{{ proto int OCIColumnPrecision(int stmt, int col) + Tell the precision of a column */ + +PHP_FUNCTION(ocicolumnprecision) +{ + zval **stmt, **col; + oci_statement *statement; + oci_out_column *outcol; + + if (zend_get_parameters_ex(2, &stmt, &col) == FAILURE) { + WRONG_PARAM_COUNT; + } + + OCI_GET_STMT(statement,stmt); + + outcol = oci_get_col(statement, -1, col); + if (outcol == NULL) { + RETURN_FALSE; + } + RETURN_LONG(outcol->precision); +} + +/* }}} */ /* {{{ proto mixed OCIColumnType(int stmt, int col) Tell the data type of a column */ @@ -3046,7 +3133,7 @@ zval **stmt, **col; oci_statement *statement; oci_out_column *outcol; - + if (zend_get_parameters_ex(2, &stmt, &col) == FAILURE) { WRONG_PARAM_COUNT; } @@ -3097,6 +3184,29 @@ default: RETVAL_LONG(outcol->data_type); } +} + +/* }}} */ +/* {{{ proto mixed OCIColumnTypeRaw(int stmt, int col) + Tell the raw oracle data type of a column */ + +PHP_FUNCTION(ocicolumntyperaw) +{ + zval **stmt, **col; + oci_statement *statement; + oci_out_column *outcol; + + if (zend_get_parameters_ex(2, &stmt, &col) == FAILURE) { + WRONG_PARAM_COUNT; + } + + OCI_GET_STMT(statement,stmt); + + outcol = oci_get_col(statement, -1, col); + if (outcol == NULL) { + RETURN_FALSE; + } + RETVAL_LONG(outcol->data_type); } /* }}} */ Index: php4/ext/oci8/php_oci8.h diff -u php4/ext/oci8/php_oci8.h:1.6 php4/ext/oci8/php_oci8.h:1.7 --- php4/ext/oci8/php_oci8.h:1.6 Sat Feb 12 06:38:02 2000 +++ php4/ext/oci8/php_oci8.h Thu Mar 2 17:28:27 2000 @@ -143,6 +143,8 @@ oci_define *define; int piecewise; ub4 cb_retlen; + ub2 scale; + ub2 precision; } oci_out_column; typedef struct {

« previous php.version4 (#11417) next »