我具有以下功能:
create or replace function getEdit (farm bigint [], retreat bigint [], dateLot date)
returns integer as $$
declare
qtde bigint = 0;
begin
select sum (e.est_qtde) into qtde
from stocked and
left join catanimal c on c.can_chave = e.can_chave
left join farm f on f.faz_chave = e.faz_chave
where e.cfg_chave = 1922
and e.est_data <= $ 3
and COALESCE (c.can_situation, 0) = 0
and COALESCE (f.faz_situacao, 0) = 0
and e.faz_chave in ($1::bigint[])
and e.ret_key in ($2::bigint[]);
return qtde;
end;
$$ language plpgsql;
当您称呼它时:
select * from getSet (array [19220200006, 19220200005], array [19220200005, 19220200004], '2019-03-01')
我收到以下错误:
ERROR: operator does not exist: bigint = bigint []
LINE 8: and e.faz_chave in ($ 1 :: bigint [])
我要去哪里错了?
答案 0 :(得分:0)
对于数组,您需要使用ANY
运算符:
and e.faz_chave = ANY (farm)
and e.ret_key = ANY (retreat);
无需将参数强制转换为已声明的类型。