RE: CREATE OR REPLACE FUNCTION

From: Mariela Martinez <mmartinez(at)movilmaster(dot)cl>
To: Estéfano Castillo <ecastillo(at)crecic(dot)cl>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: RE: CREATE OR REPLACE FUNCTION
Date: 2004-10-13 16:21:27
Message-ID: MIEBIKDDFCOKJAEGEPGICEDHCBAA.mmartinez@movilmaster.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


Probé la función que me envías, antes intenté con algo parecido %ROWTYPE
pero sin FOR LOOP, pero lamentablemente el error fué el mismo con ambas
funciones.

WARNING: plpgsql: ERROR during compile of selectcalles near line 0
ERROR: cache lookup for type 0 of callesstgo.........pg.dropped.2........
failed

Con esto traté antes:
REATE OR REPLACE FUNCTION selectcalles(text, text)
RETURNS text AS
'DECLARE
res record;
reg callesstgo%ROWTYPE;
BEGIN
select * from into reg callesstgo where
distance(GeometryFromText(''POINT('' || $1 || '' '' || $2 || '')
'',-1),the_geom) < 25;
return reg.nombre || reg.comuna;
END;'

-----Original Message-----
From: Estéfano Castillo [mailto:ecastillo(at)crecic(dot)cl]
Sent: Miércoles, 13 de Octubre de 2004 10:57 p.m.
To: 'Mariela Martinez'
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: RE: [pgsql-es-ayuda] CREATE OR REPLACE FUNCTION

Prueba con este ejemplo(está adaptado a tu función por ende debieras llegar
y ejecutarlo), puesto que en plpgsql la consulta por si sola no te retorna
datos...debes usar una variable rowtype y luego con un loop retornar los
registros.

CREATE OR REPLACE FUNCTION selectcalles(text, text) RETURNS callesstgo AS
'DECLARE
res text;
v_retval callesstgo%ROWTYPE;
BEGIN
FOR v_retval IN
select * from callesstgo where distance(GeometryFromText(''POINT('' ||
$1 || '' '' || $2 || '') '',-1),the_geom) < 25;
LOOP
RETURN NEXT v_retval;
END LOOP;
RETURN;
END;'
LANGUAGE 'plpgsql' VOLATILE;

Estéfano Ariel Castillo Estrada
Técnico Universitario en Computación e Informática
Analista Programador de Sistemas CRECIC S.A.
Fono: (56)(41)240002 - Anexo 724
Celular: 93850119
Concepción - Chile

-----Mensaje original-----
De: pgsql-es-ayuda-owner(at)postgresql(dot)org
[mailto:pgsql-es-ayuda-owner(at)postgresql(dot)org] En nombre de Mariela Martinez
Enviado el: Miércoles, 13 de Octubre de 2004 10:45
Para: pgsql-es-ayuda(at)postgresql(dot)org
Asunto: [pgsql-es-ayuda] CREATE OR REPLACE FUNCTION

Por favor, necesito ayuda con esta función:

CREATE OR REPLACE FUNCTION selectcalles(text, text) RETURNS callesstgo AS
'DECLARE
res text;
BEGIN
select * from callesstgo where distance(GeometryFromText(''POINT('' ||
$1
|| '' '' || $2 || '') '',-1),the_geom) < 25; END;'
LANGUAGE 'plpgsql' VOLATILE;

Necesito traer un conjunto de registros, pero cuando la ejecuto me trae el
siguiente error:
ERROR: SELECT query has no destination for result data.
If you want to discard the results, use PERFORM instead.

Estoy trabajando con PostGreSQL 7.3

---------------------------(end of broadcast)---------------------------
TIP 9: el optimizador ignorará el uso de recorridos de índice si los
tipos de datos de las columnas no coinciden

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mario A. Soto Cordones 2004-10-13 16:37:52 parametros en triggers
Previous Message Mariela Martinez 2004-10-13 14:45:19 CREATE OR REPLACE FUNCTION