Boa Tarde Pessoal, Criamos uma FUNCTION com o seguinte código:
CREATE OR REPLACE FUNCTION public.atualizar_cbo ( "piFamilia" integer = 0, "piCBO" integer = 0, "psDescricao" text = ''::text ) RETURNS boolean AS $body$ DECLARE viCBO INTEGER; BEGIN -- raise notice 'chegou aqui finalmente'; if piCBO = 0 then -- raise notice 'chegou aqui2'; PERFORM * from glb.cbofamilia cbof where cbof.idcbofamilia = piFamilia; if not found then insert into glb.cbofamilia (idcbofamilia, descricao) values (piFamilia, CAST(psDescricao AS VARCHAR)); end if; else PERFORM * from glb.cbo cbo where cbo.idcbofamilia = piFamilia and cbo.idcbo = piCBO; if not found then insert into glb.cbo (idcbofamilia, idcbo, descricao) values (piFamilia, piCBO, CAST(psDescricao AS VARCHAR)); end if; end if; RETURN True; END; $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER COST 100; Mais quando vamos fazer um SELECT... exemplo de SELECT select public.atualizar_cbo (2521,0,'ADMINISTRADORES'); ele da o seguinte erro: ERROR: column "picbo" does not exist LINE 1: SELECT piCBO = 0 ^ QUERY: SELECT piCBO = 0 CONTEXT: PL/pgSQL function "atualizar_cbo" line 7 at IF Gostaria de saber se existe alguma coisa de errada na criação dessa FUNCTION, se sim qual é o erro que estamos cometendo. Obrigado Att Torres
_______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral