Cannot Get Geometry Object from Data Sent to GEOMETRY Field – MySQL Fix

errorsMySQLspatial

The following simple test returns an error

CREATE TABLE track (
  position point NOT NULL
);
INSERT INTO track VALUES (
  position=ST_PointFromText('POINT(-45.62390335574153 -3.9551761173743847)')
);

Error:

ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field

What am I doing wrong?

Best Answer

Wrong syntax... Instead of

INSERT INTO track VALUES (
    position=ST_PointFromText(...)
);

use

INSERT INTO track SET
    position=ST_PointFromText(...);

Reference: https://dev.mysql.com/doc/refman/5.7/en/insert.html

Related Question