[postgis-users] PostGIS and prepared statement, data_type problem

Marco Boeringa marco at boeringa.demon.nl
Sat Apr 9 06:58:14 PDT 2022


I finally got this to work by switching to WKB and "ST_GeomFromWKB" and 
specifying data_type for the column as 'geometry'.

Op 9-4-2022 om 11:47 schreef Marco Boeringa:
> Hi all,
>
> Reading this PostgreSQL page about prepared SQL statements:
>
> https://www.postgresql.org/docs/current/sql-prepare.html
>
> it suggests that 'data_type' is optional, and "will be inferred from 
> the context in which the parameter is first referenced" if unspecified.
>
> Now I have attempted to create a prepared SQL statement for doing 
> INSERTs, which includes an "ST_GeometryFromText()" function call that 
> will get WKT inserted in the geometry field of the target table.
>
> However, this fails with a "could not determine data type of parameter 
> $1" error for the geometry field.
>
> Is there something PostGIS functions do not expose to PostgreSQL that 
> causes PostgreSQL to fail to "infer from context" the field type? Or 
> is this a general issue with PREPAREd statements if they include any 
> function call, whether PostGIS or core PostgreSQL, and are you always 
> required to specify data type in this context?
>
> Marco
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users


More information about the postgis-users mailing list