Boa tarde pessoal,
se possível, por favor me auxiliem nesta função:
CREATE OR REPLACE FUNCTION public.tarefa_agendada_ai (
)
RETURNS trigger AS
$body$
DECLARE
rec record;
BEGIN
FOR rec IN
select date
from generate_series(new.dtinicial::timestamp,
new.dtfinal, '1 day') date
where extract(dow from date) not in (0,6)
LOOP
INSERT INTO tarefa_itens (id, id_tarefaag, data_horafin,
data_horaexec, executada)
VALUES ((select coalesce((max(ti.id) + 1), 1)
chave from tarefa_itens ti),
new.id,
null,
rec.date -- Aqui
'N');
END LOOP;
return new;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
Estou tentando um insert que pega os valores do novo registro da tabela
tarefa (After Insert) e gera os valores da tabela tarefa_itens. Com a
função generate_series dentro do for loop armazeno num tipo Record, mas no
momento da execução recebo um erro de que o schema rec não existe. O que
estou fazendo de errado?
ERROR: schema "rec" does not exist
LINE 7: rec.date
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral