Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/04/2010, 12:12
Avatar de calakra
calakra
 
Fecha de Ingreso: septiembre-2009
Mensajes: 182
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: arbol jerarquico

bueno, pues voy avanzando un poco a poco con esto del arbol. espero terminarlo y lo pondre por aqui.
mientras me atore con un renglón

digamos que tenemos esto


CREATE or replace FUNCTION suma ( ) RETURNS text AS '
DECLARE

id_responde record; -- s declara el array

criterio text='''';
auxcriterio text='''';

BEGIN
FOR id_responde IN select id_org from org_int where id_parent =prueba::bigint AND id_company=3 AND id_company=3 LOOP
if criterio<>'''' then
criterio:=criterio||'','';
end if;
criterio:=criterio|| RTRIM( LTRIM( id_responde::text , ''('') ,'')'');

END LOOP;

--////////////////////////////
if criterio<>'''' then
ban:=1;
auxcriterio:=criterio;
criterio:='''';
end if;
criterio := ''select id_org from org_int where id_parent in (''||auxcriterio||'') AND id_company=3 AND id_company=3'';

FOR id_responde IN criterio loop
end loop;




return criterio;
END;
' LANGUAGE 'plpgsql';

en la parte de color es donde esta mi error, ya que postgresql no lle lo que tiene la variable criterio, si no que solo la identifica como variable.
io quiero que ahi no vea la variable como tal, sino que lea lo que trae la variable. espero me puedan ayudar