PolyFromShapeÀº À¯Çü ´Ù°¢Çü ¸ð¾ç°ú °ø°£ ÂüÁ¶ ½Ã½ºÅÛ ½Äº°ÀÚ¸¦ ÃëÇØ ´Ù°¢ÇüÀ» ¸®ÅÏÇÕ´Ï´Ù.
±¸¹®
db2gse.PolyFromShape (ShapePolygon Blob(1M), SRID db2gse.coordref)
¸®ÅÏ À¯Çü
db2gse.ST_Polygon
¿¹
ÇÁ·Î±×·¥ Á¶°¢Àº SENSITIVE_AREAS Å×À̺íÀ» »óÁÖ½Ãŵ´Ï´Ù. ¹°À½Ç¥´Â ·±Å¸Àӽà °Ë»öµÉ id, name, size, type ¹× zone °ªµé¿¡ ´ëÇÑ ¸Å°³º¯¼ö Ç¥½Ã¹®ÀÚ¸¦ ³ªÅ¸³À´Ï´Ù.
SENSITIVE_AREAS Å×ÀÌºí¿¡´Â ÇØ´ç ±â°üÀÇ ´Ù°¢Çü ±âÇϸ¦ ÀúÀåÇÏ´Â zone Ä÷³ ¿Ü¿¡µµ À§Çù¹Þ´Â ±â°üÀ» ¼¼úÇÏ´Â ¿©·¯ Ä÷³µéÀÌ Æ÷ÇԵ˴ϴÙ.
CREATE TABLE SENSITIVE_AREAS (id integer, name varchar(128), size float, type varchar(10), zone db2gse.ST_Polygon); /* id, name, size, type ¹× zoneÀ» »óÁÖ½Ã۱â À§ÇÑ SQL insert¹®À» ÀÛ¼ºÇÕ´Ï´Ù. ¹°À½Ç¥´Â ¸Å°³º¯¼ö Ç¥½Ã¹®ÀÚÀ̸ç, ÀÌ´Â ·±Å¸ÀÓ¿¡ °Ë»öµÇ´Â id, name, size, type ¹× zone °ªÀ» ÁöÁ¤ÇÕ´Ï´Ù. */ strcpy (shp_sql,"insert into SENSITIVE_AREAS (id, name, size, type, zone) values (?,?,?,?, db2gse.PolyFromShape (cast(? as blob(1m)), db2gse.coordref()..srid(0)))"); /* SQL¹® Çڵ鿡 ´ëÇÑ ¸Þ¸ð¸®¸¦ ÇÒ´çÇϰí, ¸í·É¹® ÇÚµéÀ» ¿¬°á ÇÚµé°ú °áÇÕÇÕ´Ï´Ù. */ rc = SQLAllocStmt (handle, &hstmt); /* ½ÇÇàÇÒ SQL¹®À» ÁغñÇÕ´Ï´Ù. */ rc = SQLPrepare (hstmt, (unsigned char *)shp_sql, SQL_NTS); /* ID Á¤¼ö °ªÀ» ù¹øÂ° ¸Å°³º¯¼ö¿¡ ¹ÙÀεåÇÕ´Ï´Ù. */ pcbvalue1 = 0; rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTEGER, SQL_INTEGER, 0, 0, &site_id, 0, &pcbvalue1); /* name varchar °ªÀ» µÎ ¹øÂ° ¸Å°³º¯¼ö¿¡ ¹ÙÀεåÇÕ´Ï´Ù. */ pcbvalue2 = name_len; rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, name, 0, &pcbvalue2); /* size float¸¦ ¼¼ ¹øÂ° ¸Å°³º¯¼ö·Î ¹ÙÀεåÇÕ´Ï´Ù. */ pcbvalue3 = 0; rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_FLOAT, SQL_REAL, 0, 0, &size, 0, &pcbvalue3); /* type varcharÀ» ³× ¹øÂ° ¸Å°³º¯¼ö¿¡ ¹ÙÀεåÇÕ´Ï´Ù. */ pcbvalue4 = type_len; rc = SQLBindParameter (hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, type_len, 0, type, type_len, &pcbvalue4); /* zone ´Ù°¢ÇüÀ» ´Ù¼¸¹øÂ° ¸Å°³º¯¼ö¿¡ ¹ÙÀεåÇÕ´Ï´Ù. */ pcbvalue5 = zone_len; rc = SQLBindParameter (hstmt, 5, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BLOB, zone_len, 0, zone_shp, zone_len, &pcbvalue5); /* »ðÀÔ¹®À» ½ÇÇàÇÕ´Ï´Ù. */ rc = SQLExecute (hstmt);