转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> ORACLE >> 正文
Oracle空间数据库的读取与写入         ★★★★

Oracle空间数据库的读取与写入

作者:闵涛 文章来源:闵涛的学习笔记 点击数:3472 更新时间:2009/4/22 22:06:16
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 *)&gtype));

  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]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台