# ST_WKBToSQL function

The ST_WKBToSQL function takes a well-known binary representation of a geometry and, optionally, a spatial reference system identifier as input parameters and returns the corresponding geometry.

If the given well-known binary representation is null, then null is returned.

The ST_GeomFromSDE function is identical to the ST_GeomFromWKB function. As well, ST_WKBToSQL(wkb) gives the same result as ST_Geometry(wkb,0). Using the ST_Geometry function is recommended over using ST_WKBToSQL because of its flexibility: ST_Geometry takes additional forms of input as well as the well-known binary representation.

## Syntax

## Parameter

- wkb
- A value of type BLOB(2G) that contains the well-known binary representation of the resulting geometry.
- srsId
- A value of type INTEGER that uniquely identifies the spatial reference system. The spatial reference system with the identifier 0 (zero) is used for the resulting geometry.

## Return type

db2gse.ST_Geometry

## Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.

```
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geometries
(id INTEGER, geometry ST_Geometry, wkb BLOB(32K) )
INSERT INTO sample_geometries (id, geometry)
VALUES (10, ST_Point ( 'point (44 14)', 0 ) ),
(11, ST_Point ( 'point (24 13)', 0 ) ),
(12, ST_Polygon ('polygon ((50 20, 50 40, 70 30, 50 20))', 0 ) )
UPDATE sample_geometries AS temp_correlated
SET wkb = ST_AsBinary(geometry)
WHERE id = temp_correlated.id
```

Use this SELECT statement to see the geometries in the
WKB column. ```
SELECT id, CAST( ST_AsText( ST_WKBToSQL(wkb) ) AS VARCHAR(120) ) GEOMETRIES
FROM sample_geometries
```

Results: ```
ID GEOMETRIES
----------- -------------------------------------------------------------
10 POINT ( 44.00000000 14.00000000)
11 POINT ( 24.00000000 13.00000000)
12 POLYGON (( 50.00000000 20.00000000, 70.00000000 30.00000000,
50.00000000 40.00000000, 50.00000000 20.00000000))
```