【发布时间】:2020-11-18 13:42:30
【问题描述】:
我正在尝试在 Scala 中使用 Anorm 创建此 SQL 语句。我正在使用 Postgres 数据库。
insert into my_table (coords) values (ST_GeomFromText('POINT(26.9484 24.03937)',4326)
我试过这段代码:
val lat = 26.9484
val long = 24.03937
val coords = s"ST_GeomFromText('POINT($lat $long)',4326)"
SQL"insert into my_table (coords) values (${coords})".executeInsert()
但我收到此错误:
[PSQLException: ERROR: subfield "coords" is of type geometry but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
【问题讨论】: