Em Sexta-feira, 6 de Janeiro de 2017 11:46, 
"[email protected]" <[email protected]> 
escreveu:
 

 CREATE OR REPLACE FUNCTION "GerarTeste"()  RETURNS BOOL  AS  $BODY$ DECLARE  
inicio date; fim date; rResult record;  BEGIN FOR rResult IN  SELECT DISTINCT  
lote  FROM  fatura  ORDER BY lote LOOP SELECT   MIN(fatura.inicio) INTO inicio  
 ,MAX(fatura.inicio) into fim FROM fatura WHERE lote = rResult.lote;  RAISE 
NOTICE '%',inicio;
 END LOOP; RETURN true; END;$BODY$LANGUAGE 'plpgsql'; 

    Em Sexta-feira, 6 de Janeiro de 2017 11:16, Rafael Fialho 
<[email protected]> escreveu:
 

 Em 6 de janeiro de 2017 11:10, <[email protected]> escreveu:

Entendi, no caso é um postgres 9.4 em um Centos.
Dei uma debugada e quando deixo apenas o MIN funciona, mas MIN e MAX juntos 
tenho o seguinte erro ( isso já de cara, na hora de criar a function) :
[Err] ERRO:  "max" não é uma variável conhecida

SELECT   MIN(fatura.inicio) INTO inicioFROM fatura
WHERE lote = r.lote;-- Funciona
SELECT   MIN(fatura.inicio) INTO inicio                ,MAX(fatura.inicio) INTO 
termino
FROM fatura
WHERE lote = r.lote; -- Não funciona

Poderia postar o todo o corpo da função? 

   

   
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a