使用者の手引きおよび解説書

PointFromShape

PointFromShape はポイント型の輪郭と地理情報参照システム ID を引き数とし、ポイントを戻します。

構文

db2gse.PointFromShape(db2gse.ShapePoint blob(1M), SRID db2gse.coordref)

戻りタイプ

db2gse.ST_Point

以下のプログラム断片では、HAZARDOUS_SITES 表にデータを入れます。

危険地帯は、以下の CREATE TABLE ステートメントを用いて作成される HAZARDOUS_SITES 表に格納されます。ポイントとして定義された location 列には、それぞれの危険地帯の地理上の中心の位置が格納されます。

CREATE TABLE HAZARDOUS_SITES (site_id   integer,
                             name       varchar(128),
                              location  db2gse.ST_Point); 
 
/* Create the SQL insert statement to populate the site_id, name and
   location. The question marks are parameter markers that indicate the
   site_id, name and location values that will be retrieved at runtime. */
strcpy (shp_sql,"insert into HAZARDOUS_SITES (site_id, name, location)
values (?,?, db2gse.PointFromShape (cast(? as blob(1m)), 
db2gse.coordref()..srid(0)))");
 
/* Allocate memory for the SQL statement handle and associate the 
   statement handle with the connection handle. */
rc = SQLAllocStmt (handle, &hstmt);
 
/* Prepare the SQL statement for execution. */
rc = SQLPrepare (hstmt, (unsigned char *)shp_sql, SQL_NTS);
 
/* Bind the site_id integer value to the first parameter. */
pcbvalue1 = 0; 
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTEGER,
     SQL_INTEGER, 0, 0, &site_id, 0, &pcbvalue1);
 
/* Bind the name varchar value to the second parameter. */
pcbvalue2 = name_len;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
   SQL_CHAR, 0, 0, name, 0, &pcbvalue2);
 
/* Bind the location shape to the third parameter. */
pcbvalue3 = location_len;
rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
     SQL_BLOB, location_len, 0, location_shape, location_len, &pcbvalue3);
 
/* Execute the insert statement. */
rc = SQLExecute (hstmt); 


[ ページのトップ | 前ページ | 次ページ | 目次 | 索引 ]