Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

cannot form my shape with polygon data type in mysql. Please help SET @g =ST_geo

ID: 3887855 • Letter: C

Question

cannot form my shape with polygon data type in mysql. Please help

SET @g =ST_geometryFromText( 'POLYGON((9 8,9 3,4 1,2 2,1 3,3 5,3 6,2 6,2 9,5 9,5 10,6 11,7 11,7 10,6 9,7 8,7 9,8 9,8 8,9 8))');
INSERT INTO `homework2cst325`.`boundary` (`Boundary_path`) VALUES (ST_geometryfromtext(@g),SHAPE);

ERROR 3037: 3037: Invalid GIS data provided to function st_geometryfromtext.
SQL Statement:
INSERT INTO `homework2cst325`.`boundary` (`Boundary_path`) VALUES (ST_geometryfromtext('@g'))

ERROR 1136: 1136: Column count doesn't match value count at row 1
SQL Statement:
INSERT INTO `homework2cst325`.`boundary` (`Boundary_path`) VALUES (ST_geometryfromtext('@g'),SHAPE)

ERROR 1136: 1136: Column count doesn't match value count at row 1
SQL Statement:
INSERT INTO `homework2cst325`.`boundary` (`Boundary_path`) VALUES (ST_geometryfromtext(@g),SHAPE)

ERROR 1136: 1136: Column count doesn't match value count at row 1
SQL Statement:
INSERT INTO `homework2cst325`.`boundary` (`Boundary_path`) VALUES (ST_geometryfromtext(@g),SHAPE)

Explanation / Answer

Please the SQL as below :

SET @g = 'POLYGON((9 8,9 3,4 1,2 2,1 3,3 5,3 6,2 6,2 9,5 9,5 10,6 11,7 11,7 10,6 9,7 8,7 9,8 9,8 8,9 8))';


INSERT INTO homework2cst325.boundary (Boundary_path) VALUES (ST_GeomFromText(@g),SHAPE);

Please let me know if you face any difficulty understanding the query.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote