se query */ checkerr(errhp, OCIStmtPrepare(stmthp, errhp, (text *)query, (ub4)strlen(query), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT));
/* define GID and spatial ADT object */ checkerr(errhp, OCIDefineByPos(stmthp, &defn1p, errhp, (ub4)1, (dvoid *)global_gid, (sb4)sizeof(OCINumber), SQLT_VNU, (dvoid *)0, (ub2 *)0, (ub2 *)0, (ub4)OCI_DEFAULT));
checkerr(errhp, OCIDefineByPos(stmthp, &defn2p, errhp, (ub4)2, (dvoid *)0, (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0, (ub2 *)0, (ub4)OCI_DEFAULT));
checkerr(errhp, OCIDefineObject(defn2p, errhp, geom_tdo, (dvoid **)global_geom_obj, (ub4 *)0, (dvoid **)global_geom_ind, (ub4 *)0));
/* execute */ status = OCIStmtExecute(svchp, stmthp, errhp, (ub4)ARRAY_SIZE, (ub4)0, (OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4)OCI_DEFAULT);
if (status == OCI_SUCCESS_WITH_INFO || status == OCI_NO_DATA) has_more_data = FALSE; else { has_more_data = TRUE; checkerr(errhp, status); }
/* process data */ checkerr(errhp, OCIAttrGet((dvoid *)stmthp, (ub4)OCI_HTYPE_STMT, (dvoid *)&rows_fetched, (ub4 *)0, (ub4)OCI_ATTR_ROW_COUNT, errhp)); rows_to_process = rows_fetched - rows_processed;
process_data(num_dimensions, id_column, rows_to_process, &rows_processed);
while (has_more_data) { status = OCIStmtFetch(stmthp, errhp, (ub4)ARRAY_SIZE, (ub2)OCI_FETCH_NEXT, (ub4)OCI_DEFAULT);
if (status != OCI_SUCCESS) has_more_data = FALSE;
/* process data */ checkerr(errhp, OCIAttrGet((dvoid *)stmthp, (ub4)OCI_HTYPE_STMT, (dvoid *)&rows_fetched, (ub4 *)0, (ub4)OCI_ATTR_ROW_COUNT, errhp)); rows_to_process = rows_fetched - rows_processed;
process_data(num_dimensions, id_column, rows_to_process, &rows_processed); }
if (status != OCI_SUCCESS_WITH_INFO && status != OCI_NO_DATA) checkerr(errhp, status); }
/******************************************************************************* ** ** Routine: sc_ops_geom_null ** ** Description: Retruns 1 if the geometry object is NULL. ** *******************************************************************************/ int WReadAndWriteGeometry::sc_ops_geom_null (void)
{ return (m_geom_ind->_atomic == OCI_IND_NULL); }
/******************************************************************************* ** ** Routine: sc_ops_init_geometry ** ** Description: Initializaton routine. ** This must be called for a geometry before you call any ** any other routines in sc_ops... ** *******************************************************************************/ void WReadAndWriteGeometry::sc_ops_init_geometry (SDO_GEOMETRY_TYPE *geom, SDO_GEOMETRY_ind *geom_ind, int num_dimensions)
{ m_geom_obj = geom; m_geom_ind = geom_ind; if (!sc_ops_geom_null()) { /* Get the size of the sdo_elem_info array */ checkerr(errhp, OCICollSize(envhp, errhp, ( OCIColl *)(m_geom_obj->sdo_elem_info), &global_nelems));
/* Get the size of the ordinates array */ checkerr(errhp, OCICollSize(envhp, errhp, (OCIColl *)(m_geom_obj->sdo_ordinates), &global_nords));
global_elem_index = 0; global_first_elem = 1; global_ending_offset = -1; global_num_dimensions = num_dimensions; } }
/******************************************************************************* ** ** Routine: sc_ops_get_gtype ** ** Description: Prints the gtype field. ** *******************************************************************************/ void WReadAndWriteGeometry::sc_ops_get_gtype (void)
{ int gtype;
checkerr(errhp, OCINumberToInt(errhp, &(m_geom_obj->sdo_gtype), (uword)sizeof(int), OCI_NUMBER_SIGNED, (dvoid *)>ype));
printf("-- gtype: %d \n", gtype); }
/******************************************************************************* ** ** Routine: sc_ops_get_sdo_point ** ** Description: Prints the SDO_POINT field. ** Routine checks for NULL sdo_point field and ** NULL x, y and z fields. ** *******************************************************************************/ void WReadAndWriteGeometry::sc_ops_get_sdo_point (void)
{ double x, y, z;
if (m_geom_ind->sdo_point._atomic == OCI_IND_NOTNULL) { if (m_geom_ind->sdo_point.x == OCI_IND_NOTNULL) { checkerr(errhp, OCINumberToReal(errhp, &(m_geom_obj->sdo_point.x), (uword)sizeof(double), (dvoid *)&x));
printf("-- sdo_point.X: %.9lf \n", x); }
if (m_geom_ind->sdo_point.y == OCI_IND_NOTNULL) { checkerr(errhp, OCINumberToReal(errhp, &(m_geom_obj->sdo_point.y), (uword)sizeof(double), (dvoid *)&y));
printf("-- sdo_point.Y: %.9lf \n", y); }
if (m_geom_ind->sdo_point.z == OCI_IND_NOTNULL) { checkerr(errhp, OCINumberToReal(errhp, &(m_geom_obj->sdo_point.z), (uword)sizeof(double), (dvoid *)&z));
printf("-- sdo_point.Z: %.9lf \n", z); } } else printf ("-- sdo_point IS NULL\n"); }
/******************************************************************************* ** ** Routine: sc_ops_next_elem ** ** Description: Go to the next element in this geometry. ** Returns 1 if there are more elements. ** Returns 0 if there are no more elements. ** *******************************************************************************/ int WReadAndWriteGeometry::sc_ops_next_elem (void)
{ int more_elems = 1;
if (global_first_elem) global_first_elem = 0; else global_elem_index = global_elem_index + 3;
return global_elem_index < global_nelems; }
/******************************************************************************* ** ** Routine: sc_ops_get_element_type ** ** Description: Prints the element_type for current element. ** *******************************************************************************/ ub4 WReadAndWriteGeometry::sc_ops_get_element_type ()
{ boolean exists; OCINumber *oci_number; ub4 element_type;
checkerr(errhp, OCICollGetElem(envhp, errhp,   上一页 [1] [2] [3] [4] [5] 下一页 没有相关教程
|