[postgis-users] PL/PgSQL and PostGIS
CYW
cyw at dls.net
Sat Jun 10 12:34:39 PDT 2006
Thanks.
The point_table is in fact like (integer,.. geometry).
Is it true that I can not use ROWTYPE if I have a Geometry column? I
actually need to get all columns. I need to read the document about Record.
_cyw_
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Michael
Fuhr
Sent: Saturday, June 10, 2006 7:26 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] PL/PgSQL and PostGIS
On Sat, Jun 10, 2006 at 01:30:19AM -0500, CYW wrote:
> I am trying a PL/PgSQL script below, and getting the following error:
> invalid input syntax for integer: "Point(111.000 999.22)"
> Context: PL/pgSQL function "testxy" line # 12 at fecth
>
> Any suggestions?
> ====================================================================
> CREATE OR REPLACE FUNCTION testxy() RETURNS text AS $$
> DECLARE
> thisrow point_table%ROWTYPE;
> rid integer DEFAULT 1;
> msg text;
> cur CURSOR(key integer) FOR SELECT AsText(geom) as geom
> FROM point_table WHERE guid=rid ORDER BY measure ASC;
> BEGIN
> OPEN cur(rid);
> FETCH cur INTO thisrow ;
You've declared thisrow to be point_table%ROWTYPE, which is presumably
something like (integer, ..., geometry). The cursor's select list
has a single text column; FETCH INTO is trying to store that text
column in thisrow's first column (an integer) so you get a type
mismatch. Declare thisrow to be of type record, or declare it to
be text and return thisrow instead of thisrow.geom. Examples:
DECLARE
thisrow record;
or
DECLARE
thisrow text;
...
RETURN thisrow;
--
Michael Fuhr
_______________________________________________
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