私はpostgreSQLのパラメータに従って0または1を返す関数を持っていますが、この関数にアクセスするメソッドがありますが、実行するとエラーが発生し、現在の設定に問題がありますタイムスタンプの日付。私はsimpleDataFormatなどのパターンを追加しようとしましたが、それ以外の多くのことはできませんでした。前もって感謝します!デシベルでタイムスタンプで今日の日付を取得する
ERROR: function inserir_posicao(numeric, bigint, double precision, double precision, numeric) does not exist
Dica: No function matches the given name and argument types. You might need to add explicit type casts.
目的球:
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, timestamp without time zone, double precision, double precision, bigint)
OWNER TO postgres;
方法:
public int inserirPosicao(BigInteger tagId, BigInteger gadoId, double lat, double lon) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Query qry = manager.createNativeQuery("select inserir_posicao(:tag,:data,:lat,:lng,:gado)");
qry.setParameter("tag", tagId);
qry.setParameter("data", timestamp.getTime());
qry.setParameter("lat", lat);
qry.setParameter("lng", lon);
qry.setParameter("gado", gadoId);
return (int) qry.getSingleResult();
}
可能な複製(http://stackoverflow.com/questions/39106041/get-time-without-time -zone-in-java) –
問題は次の行にあります。qry.setParameter( "data"、timestamp.getTime());私の答えをチェックしてください。 – Christian