[postgis-users] insert into a geometry field from 4gl

Paul Ramsey pramsey at refractions.net
Wed Feb 22 11:08:56 PST 2006


Fay,

geomfromtext() is a function.  In preparing your statement ahead of  
time, then executing into it, the cursor is probably treating the  
value you stick in as a string literal instead, which is not a valid  
geometry.  Try just doing this:
  LET sql_stmt = "INSERT INTO gps_log  (uid,geom_pt) Values (?,?)"

  PREPARE insert_gps_tb FROM sql_stmt

  LET Uid=”test”

  LET gps_point = “POINT(1870391 320462)”

  EXECUTE insert_gps_tb USING uid, gps_point

The geom_in function in PostGIS should hopefully automagically figure  
out the right thing to do.

P.


On 22-Feb-06, at 9:33 AM, Fay Du wrote:

> Hi all:
>
>
>
> I have to insert from 4gl to a postgresql database. What I did in  
> postGIS is:
>
> INSERT INTO gps_log (uid, geom_pt) values ('test1', geomfromtext 
> ('POINT(1870391 320462)',-1));
>
>     It works perfect.
>
>
>
> In 4gl,  I did followings:
>
>
>
>   -- initialize insert into gps log table cursor
>
>    LET sql_stmt = "INSERT INTO gps_log  (uid,geom_pt) Values (?,?)"
>
>    PREPARE insert_gps_tb FROM sql_stmt
>
>
>
> LET Uid=”test”
>
> LET gps_point = “geomfromtext('POINT(1870391 320462)',-1)”
>
> EXECUTE insert_gps_tb USING uid, gps_point
>
>
>
> I got error -6372.
>
>
>
>  Thanks in advance for any help
>
>
>
> Fay
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list