Problema con ltree

From: Mario Soto Cordones <msotocl(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Problema con ltree
Date: 2005-04-21 14:51:43
Message-ID: e9b17cde050421075156f4364f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola Lista, miren tengo el siguiente problema.

1.- una tabla llamada test con sus indices tipo gist

CREATE TABLE "public"."test" (
"activo" VARCHAR,
"path" "public"."ltree"
) WITH OIDS;

CREATE INDEX "path_gist_idx" ON "public"."test"
USING gist ("path");

CREATE INDEX "path_idx" ON "public"."test"
USING btree ("path");

2.- una consulta sql para consultar los datos:

select activo, path , nlevel(path) - nlevel('N027229') as level,
(select count(*)-1 from test where path <@ p.path) as hijos from
test p where path ~ 'N027229.*' order by path asc

Hasta este paso todo fnciona bien, entonces lo que hago es crear una
funcion para que me reemplace el sql del paso 2, para ello hagi lo
siguiente:

3.- Creo un tipo para retornar los datos

CREATE TYPE "public"."ty_refpahi" AS (
"activo" VARCHAR,
"path" public.ltree,
"level" INTEGER,
"hijos" INTEGER
);

4.- Creo la funcion

CREATE OR REPLACE FUNCTION public.find_refpahi (public.ltree,
public.lquery) RETURNS SETOF public.ty_refpahi AS'
select set_curcfg(''default'');
select activo, path, nlevel(path) - nlevel($1) as level,
(select count(*)-1 from test where path <@ p.path) as hijos from test
p where path ~ $2 order by path asc
'LANGUAGE 'sql' STABLE CALLED ON NULL INPUT SECURITY INVOKER;

Y ME ENTREGA EL SIGUIENTE ERROR:

ERROR: el tipo de retorno de funcion declarada para retornar
ty_refpahi no concuerda

Pero el tipo de retorno de los resultados si son correctos

Saludos

--
cordialmente,

Ing. Mario Soto Cordones
:

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Fernando Aguada 2005-04-21 15:11:25 Una Consulta sobre valores por defecto en una tabla
Previous Message Manuel Sugawara 2005-04-21 14:26:55 Re: Una Consulta sobre valores por defecto en una tabla