The SE_PointFromShape() function

The SE_PointFromShape() function creates an ST_Point from a shape of type point and a spatial reference ID.

Syntax

SE_PointFromShape(s1 lvarchar, SRID integer)

Return type

ST_Point

Example

The hazardous sites are stored in the hazardous_sites table created with the CREATE TABLE statement that follows. The location column, defined as a point, stores a location that is the geographic center of each hazardous site:
CREATE TABLE hazardous_sites (site_id   integer,
                              name      varchar(40),
                              location  ST_Point);
The program fragment populates the hazardous_sites table:
/* Create the SQL insert statement to populate the hazardous_sites
     * table. The question marks are parameter markers that indicate
     * the column values that will be inserted at run time. */
    sprintf(sql_stmt,
            "INSERT INTO hazardous_sites (site_id, name, location) "
            "VALUES(?, ?, SE_PointFromShape(?, %d))", srid);

    /* Prepare the SQL statement for execution. */
    rc = SQLPrepare (hstmt, (unsigned char *)sql_stmt, SQL_NTS);

    /* Bind the site_id to the first parameter. */
    pcbvalue1 = 0;
    rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
                           SQL_INTEGER, 0, 0,
                           &site_id, 0, &pcbvalue1);

    /* Bind the name 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 geometry to the third parameter. */
    pcbvalue3 = location_shape_len;
    rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
                           SQL_INFX_UDT_LVARCHAR, location_shape_len, 0,
                           location_shape_buf, location_shape_len, &pcbvalue3);

    /* Execute the insert statement. */
    rc = SQLExecute (hstmt);