pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFunction not return zero record
2+ messages / 2 participants
[nested] [flat]
* Function not return zero record
@ 2006-08-03 16:58 Sylvain Racine <syracine@sympatico.ca>
2006-08-03 17:29 ` Re: Function not return zero record Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 2+ messages in thread
From: Sylvain Racine @ 2006-08-03 16:58 UTC (permalink / raw)
To: pgsql-sql
Hello,
I wrote a simple function who checks in a table an address and returns
the id and coordinates of the corresponding address.
The problem is when I run separately the SQL query, it gives me zero (0)
entry when I submit a new address - it is what I want as result - and
when I run my function, it gives me 1 entry with the same address.
Note: I create a pseudo-type to return the result. Is that my problem?
I run Postgresql 7.4 on i686-pc-cygwin (Windows XP), with PostGIS 1.0.
CREATE TABLE adresses (
id int4 PRIMARY KEY DEFAULT nextval('seq_adresse'),
);
SELECT AddGeometryColumn('greffe1','adresses','geom', 4269, 'POINT', 2);
CREATE TYPE getCache AS (id integer,geocode double precision ARRAY[2]);
CREATE FUNCTION getCache(varchar)
RETURNS getCache AS '
SELECT id, ARRAY[x(geom),y(geom)] FROM adresses where adresse = $1;
' LANGUAGE sql;
Best regards
Sylvain Racine
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Function not return zero record
2006-08-03 16:58 Function not return zero record Sylvain Racine <syracine@sympatico.ca>
@ 2006-08-03 17:29 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2006-08-03 17:29 UTC (permalink / raw)
To: Sylvain Racine <syracine@sympatico.ca>; +Cc: pgsql-sql
Sylvain Racine wrote:
> Hello,
>
> I wrote a simple function who checks in a table an address and returns
> the id and coordinates of the corresponding address.
>
> The problem is when I run separately the SQL query, it gives me zero (0)
> entry when I submit a new address - it is what I want as result - and
> when I run my function, it gives me 1 entry with the same address.
>
> Note: I create a pseudo-type to return the result. Is that my problem?
The problem is the difference between a value of type getCache and a set
of values of type getCache.
Define your function as returning a SETOF getCache
Call it with SELECT * FROM getCache(...)
HTH
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-08-03 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-03 16:58 Function not return zero record Sylvain Racine <syracine@sympatico.ca>
2006-08-03 17:29 ` Richard Huxton <dev@archonet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox