我在postgreSQL中有一个没有时区的时间列的函数。然后在我的方法中,设置参数时出现错误。它说这种类型是未知的。我该如何设置当前系统时间的这个参数?该方法的目的是验证寄存器是否存在于数据库中。在Java中没有时区的情况下得到时间
功能:
CREATE OR REPLACE FUNCTION public.inserir_posicao(
_tag bigint,
_data_hora timestamp without time zone,
_lat double precision,
_long double precision,
_gado_id bigint)
RETURNS integer AS
$BODY$declare
tagPesq BigInt;
begin
select tag into tagPesq from coordenadas where tag = $1;
if tagPesq is not null and tagPesq > 0 then
update coordenadas set pos_data = $2,
pos_latitude = $3,
pos_longitude = $4,
gado_id = $5
where tag_id = $1;
else
insert into coordenadas(pos_data,pos_latitude,pos_longitude,
tag_id, gado_id) values ($2,$3,$4,$1,$5);
end if;
return 1;
EXCEPTION WHEN RAISE_EXCEPTION THEN
BEGIN
return 0;
END;
end;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION public.inserir_posicao(bigint, time with time zone, double precision, double precision, bigint)
OWNER TO postgres;
方法:
public int insertPosicao(BigInteger tagId, BigInteger gadoId, double lat, double lon) {
Query qry = manager.createNativeQuery("select inserir_posicao(:tag,:data,:lat,:lng,:gado)");
qry.setParameter("tag", tagId);
qry.setParameter("data", ???); //this parameter.
qry.setParameter("lat", lat);
qry.setParameter("lng", lon);
qry.setParameter("gado", gadoId);
return (int) qry.getSingleResult();
}
_“我在postgreSQL中有一个函数”_ - 向我们展示函数。它期望什么类型?请访问[帮助]并阅读[问]以了解如何有效地使用StackOverflow。现在显示的是 –
。 –