http://qs1969.pair.com?node_id=11134291

Bod has asked for the wisdom of the Perl Monks concerning the following question:

There seems to be a shortage of information available about spatial datatypes but I can create and update POINT data without placeholders. I am struggling to find the right way to do it with placeholders.

my $st = Site::Point->new($st_lat, $st_lng); my $ed = Site::Point->new($ed_lat, $ed_lng); print "$uid - ". $st->sql . " - " . $ed->sql . "\n"; $dbh->do("UPDATE Sector SET start = ?, end = ? WHERE uid = ?", undef, +$st->sql, $ed->sql, $uid); if ($dbh->err) { print "ERROR: " . $dbh->errstr; exit; }

In the above code, start and end are both POINT datatypes. The print statement produces this:
NC33-341 - ST_GeomFromText( ' POINT ( -4.75513748886666 58.2553702983331 ) ', 4326 ) - ST_GeomFromText( ' POINT ( -4.67682813534559 58.3335955352018 ) ', 4326 )

If the query is executed directly without placeholders, it works.
UPDATE Sector SET start = ST_GeomFromText( ' POINT ( -4.75513748886666 58.2553702983331 ) ', 4326 ), end = ST_GeomFromText( ' POINT ( -4.67682813534559 58.3335955352018 ) ', 4326 ) WHERE uid = 'NC33-341'

The error is: ERROR: Cannot get geometry object from data you send to the GEOMETRY field

It wouldn't be the end of the world if I didn't use placeholders here for the latitude and longitude as they are internally calculated and checked that they are numeric and within the vague boundaries of the UK. So, if only $uid used a placeholder there would not be a big risk. But I would rather do it properly if placeholders can be used with spatial datatypes.