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

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

作者:闵涛 文章来源:闵涛的学习笔记 点击数:3473 更新时间:2009/4/22 22:06:16
nates for a type2 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type2 (void)

{
   int interp = get_interpretation ();

   get_ordinates (get_next_starting_offset(global_ending_offset == -1),
                  get_next_ending_offset (0));
}

/*******************************************************************************
**
** Routine:     sc_ops_get_type3
**
** Description: Print the ordinates for a type3 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type3 (void)

{
   int interp = get_interpretation (),
       start  = get_next_starting_offset(global_ending_offset == -1),
       end    = get_next_ending_offset(0);

   if (interp == 3) /* Rectangle, 2 po;ints */
     get_ordinates (start,
                    start + global_num_dimensions * 2 - 1);

   else if (interp == 4) /* Circle, 3 points */
     get_ordinates (start,
                    start + global_num_dimensions * 3 - 1);

   else if (interp == 1 || interp == 2) /* interpretation 1 or 2 */
     get_ordinates (start, end);
}


/*******************************************************************************
**
** Routine:     sc_ops_get_type4
**
** Description: Print the ordinates for a type4 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type4 (void)

{
  int interp = get_interpretation (),
      start,
      end,
      i;

  for (i = 0; i < interp; i++)
  {
     global_elem_index = global_elem_index + 3;
     start  = get_next_starting_offset(-1);
 
     if (i == interp - 1)
       end = get_next_ending_offset(0);
     else
       end = get_next_ending_offset(1);

     get_ordinates (start, end);
  }
}


/*******************************************************************************
**
** Routine:     sc_ops_get_type5
**
** Description: Print the ordinates for a type5 element.
**
*******************************************************************************/
void
WReadAndWriteGeometry::sc_ops_get_type5 (void)

{
  int interp = get_interpretation (),
      start,
      end,
      i;

  for (i = 0; i < interp; i++)
  {
     global_elem_index = global_elem_index + 3;
     start  = get_next_starting_offset(-1);
 
     if (i == interp - 1)
       end = get_next_ending_offset(0);
     else
       end = get_next_ending_offset(1);

     get_ordinates (start, end);
  }
}


/*******************************************************************************
**
** Routine:     write_geometries
**
** Description:
**
*******************************************************************************/
void WReadAndWriteGeometry::write_geometries ()
{
 int i;
 int starting_offset = 1;
 int element_type = 2;
 int interpretation = 1;
 OCINumber oci_number;
 OCIBind *bnd1p = NULL, *bnd2p = NULL;
 char query[500];

 for (i = 0; i < 1002; i++)
 {
  checkerr(errhp, OCINumberFromReal(errhp, (dvoid *)&(test_ordinates[i]),
      (uword)sizeof(double),&oci_number));

  checkerr(errhp, OCICollAppend(envhp, errhp,
      (dvoid *) &oci_number,
      (dvoid *)0, (OCIColl *)ordinates));
 }

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&starting_offset,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&element_type,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 checkerr(errhp, OCINumberFromInt(errhp, (dvoid *)&interpretation,
     (uword)sizeof(ub4), OCI_NUMBER_UNSIGNED,
     &oci_number));
 checkerr(errhp, OCICollAppend(envhp, errhp, (dvoid *)&oci_number,
     (dvoid *)0, (OCIColl *)elem_info));

 sprintf(query, "INSERT INTO %s (gid, %s) "
     "VALUES (1, %s(4, NULL, NULL, :elem_info, :ordinates))",
     "test_insert", "geometry", SDO_GEOMETRY);

 checkerr(errhp, OCIStmtPrepare(stmthp, errhp,
     (text *)query, (ub4)strlen(query),
     (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT));


 /* bind info_obj varray object */
 checkerr(errhp, OCIBindByName(stmthp, &bnd1p, errhp,
     (text *)":elem_info", (sb4)-1, (dvoid *)0,
     (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0,
     (ub2 *)0, (ub4)0, (ub4 *)0,
     (ub4)OCI_DEFAULT));
 checkerr(errhp, OCIBindObject(bnd1p, errhp, elem_info_tdo,
     (dvoid **)&elem_info, (ub4 *)0,
     (dvoid **)0, (ub4 *)0));
 /* bind coordinate varray object */
 checkerr(errhp, OCIBindByName(stmthp, &bnd2p, errhp,
     (text *)":ordinates", (sb4)-1, (dvoid *)0,
     (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0,
     (ub2 *)0, (ub4)0, (ub4 *)0,
     (ub4)OCI_DEFAULT));
 checkerr(errhp, OCIBindObject(bnd2p, errhp, ordinates_tdo,
     (dvoid **)&ordinates, (ub4 *)0,
     (dvoid **)0, (ub4 *)0));

 checkerr(errhp, OCIStmtExecute(svchp, stmthp, errhp, (ub4)1, (ub4)0,
     (OCISnapshot *)NULL, (OCISnapshot *)NULL,
     (ub4)OCI_DEFAULT));
}

上一页  [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……
    咸宁网络警察报警平台