column type description including name More...
#include <ocipl.h>


Public Member Functions | |
| ColumnType () | |
| void | init (OCIError *errh, dvoid *handle) |
| tstring | get_type_str (bool show_null=false) const |
Public Attributes | |
| tstring | _name |
| ub2 | _data_type |
| ub2 | _width |
| ub1 | _char_semantics |
| sb1 | _scale |
| sb2 | _precision |
| ub1 | _nullable |
column type description including name
Definition at line 1182 of file ocipl.h.
| OCIPL::ColumnType::ColumnType | ( | ) | [inline] |
Definition at line 1187 of file ocipl.h.
{
_data_type = 0;
_width = 0;
_char_semantics = 0;
_precision = 0;
_scale = -127;
_nullable = false;
}
| tstring OCIPL::ColumnTypeInfo::get_type_str | ( | bool | show_null = false ) |
const [inherited] |
Definition at line 863 of file ocipl.cpp.
References OCIPL::ColumnTypeInfo::_data_type, OCIPL::ColumnTypeInfo::_nullable, OCIPL::ColumnTypeInfo::_precision, OCIPL::ColumnTypeInfo::_scale, OCIPL::ColumnTypeInfo::_width, and TEXT.
{
tostringstream str;
switch(_data_type) {
case OCI_TYPECODE_CHAR:
str << TEXT("CHAR(") << _width << TEXT(")");
break;
case OCI_TYPECODE_VARCHAR:
str << TEXT("VARCHAR(") << _width << TEXT(")");
break;
case OCI_TYPECODE_VARCHAR2:
str << TEXT("VARCHAR2(") << _width << TEXT(")");
break;
case OCI_TYPECODE_NUMBER:
if (_precision == 0)
str << TEXT("NUMBER");
else if (_scale == -127) {
if (_precision == 126)
str << TEXT("FLOAT");
else
str << TEXT("FLOAT(") << (int)_precision << TEXT(")");
} else if (_scale)
str << TEXT("NUMBER(") << (int)_precision << TEXT(",") << (int)_scale << TEXT(")");
else
str << TEXT("NUMBER(") << (int)_precision << TEXT(")");
break;
#ifdef SQLT_BFLOAT
case OCI_TYPECODE_BFLOAT:
str << TEXT("BINARY_FLOAT");
break;
case OCI_TYPECODE_BDOUBLE:
str << TEXT("BINARY_DOUBLE");
break;
#endif
case OCI_TYPECODE_DATE:
str << TEXT("DATE");
break;
#if ORACLE_VERSION>=81
case OCI_TYPECODE_TIMESTAMP:
str << TEXT("TIMESTAMP");
break;
#endif
case OCI_TYPECODE_BLOB:
str << TEXT("BLOB");
break;
case OCI_TYPECODE_BFILE:
str << TEXT("BFILE");
break;
case OCI_TYPECODE_CLOB:
str << TEXT("CLOB");
break;
case OCI_TYPECODE_CFILE:
str << TEXT("CFILE");
break;
case SQLT_LNG:
str << TEXT("LONG");
break;
default:
str << TEXT("unknown");
}
if (show_null)
if (!_nullable)
str << TEXT(" NOT NULL");
else
str << TEXT(" NULL");
return str.str();
}
| void OCIPL::ColumnType::init | ( | OCIError * | errh, |
| dvoid * | handle | ||
| ) |
Definition at line 1249 of file ocipl.cpp.
References OCIPL::ColumnTypeInfo::_char_semantics, OCIPL::ColumnTypeInfo::_data_type, _name, OCIPL::ColumnTypeInfo::_nullable, OCIPL::ColumnTypeInfo::_precision, OCIPL::ColumnTypeInfo::_scale, OCIPL::ColumnTypeInfo::_width, OCIPL::oci_check_error(), and TCHAR.
Referenced by OCIPL::SqlStatement::get_column_type().
{
// get column name
TOraText* pcol_name = NULL;
ub4 size = sizeof(pcol_name);
sword res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &pcol_name, &size, OCI_ATTR_NAME, errh);
oci_check_error(errh, res);
_name.assign((const TCHAR*)pcol_name, size);
// get column data type
size = sizeof(_data_type);
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_data_type, &size, OCI_ATTR_DATA_TYPE, errh);
oci_check_error(errh, res);
// get NULL-ability flag
size = sizeof(_nullable);
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_nullable, &size, OCI_ATTR_IS_NULL, errh);
oci_check_error(errh, res);
#if ORACLE_VERSION>=90
// retrieve the length semantics for the column
size = sizeof(_char_semantics);
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_char_semantics, &size, OCI_ATTR_CHAR_USED, errh);
if (res != OCI_SUCCESS)
_char_semantics = 0;
size = sizeof(_width);
if (_char_semantics)
// get the column width in characters
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_width, &size, OCI_ATTR_CHAR_SIZE, errh);
else
#endif
// get the column width in bytes
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_width, &size, OCI_ATTR_DATA_SIZE, errh);
oci_check_error(errh, res);
switch(_data_type) {
default: //case OCI_TYPECODE_VARCHAR:
_precision = 0;
_scale = -127;
break;
case OCI_TYPECODE_NUMBER:
#ifdef SQLT_BFLOAT
case OCI_TYPECODE_BFLOAT:
case OCI_TYPECODE_BDOUBLE:
#endif
size = sizeof(_precision);
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_precision, &size, OCI_ATTR_PRECISION, errh);
oci_check_error(errh, res);
size = sizeof(_scale);
res = OCIAttrGet(handle, OCI_DTYPE_PARAM, &_scale, &size, OCI_ATTR_SCALE, errh);
oci_check_error(errh, res);
break;
case OCI_TYPECODE_DATE:
#if ORACLE_VERSION>=81
//case OCI_TYPECODE_TIME:
//case OCI_TYPECODE_TIMESTAMP:
#endif
_precision = 0;
_scale = -127;
break;
}
}


ub1 OCIPL::ColumnTypeInfo::_char_semantics [inherited] |
ub2 OCIPL::ColumnTypeInfo::_data_type [inherited] |
Definition at line 1168 of file ocipl.h.
Referenced by OCIPL::ColumnTypeInfo::get_type_str(), init(), and OCIPL::SqlVariantArray::SqlVariantArray().
ub1 OCIPL::ColumnTypeInfo::_nullable [inherited] |
Definition at line 1173 of file ocipl.h.
Referenced by OCIPL::ColumnTypeInfo::get_type_str(), and init().
sb2 OCIPL::ColumnTypeInfo::_precision [inherited] |
Definition at line 1172 of file ocipl.h.
Referenced by OCIPL::ColumnTypeInfo::get_type_str(), and init().
sb1 OCIPL::ColumnTypeInfo::_scale [inherited] |
Definition at line 1171 of file ocipl.h.
Referenced by OCIPL::ColumnTypeInfo::get_type_str(), and init().
ub2 OCIPL::ColumnTypeInfo::_width [inherited] |
Definition at line 1169 of file ocipl.h.
Referenced by OCIPL::ColumnTypeInfo::get_type_str(), init(), and OCIPL::SqlVariantArray::SqlVariantArray().
1.7.2