欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap 谈天说地
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
ArcSDE C-API 开发:读取属性数据
07-11-14 00:00:00 作者: 出处:

SE_CONNECTION Connection;

SE_STREAM Stream;

SE_SQL_CONSTRUCT *sqlc

SE_ERROR Connect_error;

LONG rc, population;

SHORT num_cols;

LFLOAT area;

CHAR *server, *instance, *database, *user, *passwd;

CHAR **attrs, *name;

 

/* Connect to ArcSDE */

rc = SE_connection_create

(server, instance, database, user, passwd, &Connect_error, &Connection);

/* See Error handling section for check_error function code. */

check_error(Connection, NULL, rc, "SE_connection_create");

 

/* Create a stream for the query */

rc = SE_stream_create (Connection, &Stream);

check_error(Connection, NULL, rc, "SE_stream_create");

 

/* Allocate an SE_SQL_CONSTRUCT */

rc = SE_sql_construct_alloc (1, &sqlc);

check_error(Connection, NULL, rc, "SE_sql_construct_alloc");

 

/* Fill in the details of the SQL query */

sqlc->where = malloc(20);

sqlc->num_tables = 1;

strcpy (sqlc->tables[0], "cities");

strcpy (sqlc->where, "population < 10000");

 

/* Define the number and names of the table columns to be returned */

num_cols = 3;

attrs = (CHAR **) malloc (num_cols * sizeof(CHAR *));

attrs[0] = "city_name";

attrs[1] = "area";

attrs[2] = "population";

 

/* Define the stream query */

rc = SE_stream_query (Stream, num_cols, attrs, sqlc);

check_error(NULL, Stream, rc, "SE_stream_query");

 

rc = SE_stream_execute (Stream);

/* Iterate over the results */

while (rc == SE_SUCCESS)

{

rc = SE_stream_fetch (Stream);

if (rc == SE_SUCCESS)

{

rc = SE_stream_get_string (Stream,1,name);

check_error(NULL, Stream, rc, "SE_stream_get_string");

 

rc = SE_stream_get_double (Stream,2,&area);

check_error(NULL, Stream, rc, "SE_stream_get_double");

 

rc = SE_stream_get_integer (Stream,3,&population);

check_error(NULL, Stream, rc, "SE_stream_get_integer");

 

/* Now do something with the name, area and population */

}

}

 

/* Release the stream when it is no longer needed */

rc = SE_stream_free (Stream);

free (attrs);

free (sqlc->where);

undefined undefined undefined undefinedSE_sql_construct_free (sqlc);

 

/* Disconnect from ArcSDE */

undefined undefined undefined undefinedSE_connection_free (Connection);


(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  

    关于我们 友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.

                   滇ICP备05006901号