阅读:1370回复:0
ArcSDE C-API 开发:添加新要素
<P>基本步骤:</P>
<OL> <LI class=kadov-p> <P >Connect to a database.</P> <LI class=kadov-p> <P >Initiate the insert statement on the stream.</P> <LI class=kadov-p> <P >For each row to be inserted<BR>{<BR> Set the data values.<BR> Insert row by executing statement.<BR>}</P> <LI class=kadov-p> <P >Disconnect from the database.</P></LI></OL> <P>代码:</P> <P>* Define the columns to be filled in on insert */</P> <P >num_cols = 4;</P> <P >attrs = (CHAR **) malloc (num_cols * sizeof(CHAR *));</P> <P >attrs[0] = "city_name";</P> <P >attrs[1] = "area";</P> <P >attrs[2] = "population";</P> <P >attrs[3] = "boundary";</P> <P > </P> <P >/* Tell the stream that you are inserting new records into the table */</P> <P >rc = SE_stream_insert_table (Stream, "cities", num_cols, attrs);</P> <P >/* See Error handling section for check_error function code. */</P> <P >check_error(NULL, Stream, rc, "SE_stream_insert_table");</P> <P > </P> <P >/* For each record to be inserted into the table */</P> <P >while (more data exists for insert;ldots;)</P> <P >{</P> <P > rc = SE_stream_set_string (Stream, 1, city_name);</P> <P > check_error(NULL, Stream, rc, "SE_stream_set_string");</P> <P > </P> <P > rc = SE_stream_set_double (Stream, 2, area);</P> <P > check_error(NULL, Stream, rc, "SE_stream_set_double");</P> <P > </P> <P > rc = SE_stream_set_integer (Stream, 3, population);</P> <P > check_error(NULL, Stream, rc, "SE_stream_set_integer");</P> <P > </P> <P > rc = SE_stream_set_shape (Stream, 4, shape);</P> <P > check_error(NULL, Stream, rc, "SE_stream_set_shape");</P> <P > </P> <P > rc = SE_stream_execute (Stream);</P> <P > check_error(NULL, Stream, rc, "SE_stream_execute");</P> <P >}</P> |
|
|