0
I have the following error in a function
postgres SQL Error [42883]: ERROR: operator does not exist: integer = integer[]
I tried to convert the data to varchar
and text
but still I could not return the necessary data.
Follow code to analyze:
CREATE OR REPLACE FUNCTION public.ignicaoligada(datainicial timestamp, datafinal timestamp, idmot integer, id integer[])
RETURNS TABLE(bidataevento timestamp without time zone, monome character varying, bicodigo integer, biplaca character varying)
LANGUAGE plpgsql
AS $function$
declare
dataini timestamp;
nome text;
s varchar;
contador integer;
begin
contador = 0;
nome := monome;
for bidataevento, monome, bicodigo, biplaca in select bi.bidataevento, mo.mtnome, bi.bicodigo, bi.biplaca from bilhetes bi
join motoristas mo on mo.mtcodigo = bi.bimotorista
join veiculos on veplaca = bi.biplaca
where bi.bidataevento > '28/03/2017'
and bi.bidataevento < '29/03/2017'
and bi.biignicao = 1
and mo.mtcliente = 1
and vecodigo in (id)
order by bidataevento asc
LOOP
dataini := bidataevento;
if (select bl.biignicao from bilhetes bl where bl.bidataevento < dataini order by bl.bidataevento desc limit 1) = 0 THEN
RETURN NEXT;
contador := contador + 1;
END IF;
END LOOP;
RETURN;
end
$function$