469,086 Members | 1,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,086 developers. It's quick & easy.

postgress [42883]: ERROR

1
i tried create storeprocedure in postgress 13, when i set up with parameter and call. there is some error 42883

CREATE OR REPLACE PROCEDURE public.logavlunit(pavl_unit_id character varying, pvehicle_id integer, pvehicle_number character varying, pregistration_number character varying, pdevice_type smallint, pserver_port integer, pserver_address character varying DEFAULT NULL::character varying(50))
LANGUAGE plpgsql
AS $procedure$

DECLARE
v_LogId int;
v_RegistrationNumber varchar(50);
v_VehicleId int;
v_VehicleNumber varchar(50);
v_DeviceType smallint;
v_DateTime timestamp(3);
BEGIN

v_DateTime := NOW();

SELECT id, registration_number, vehicle_id, vehicle_number, device_type INTO v_LogId, v_RegistrationNumber, v_VehicleId, v_VehicleNumber, v_DeviceType
FROM avl_unit_log
WHERE avl_unit_id=pavl_unit_id AND existing=1;

IF v_VehicleId = pvehicle_id AND v_VehicleNumber = pvehicle_number AND v_RegistrationNumber = pregistration_number AND v_DeviceType = pdevice_type
THEN
UPDATE avl_unit_log
SET last_report_time=v_DateTime, server_port=pserver_port, server_address=pserver_address
WHERE id=v_LogId;
ELSE
IF v_LogId IS NOT NULL
THEN
UPDATE avl_unit_log SET existing=0
WHERE avl_unit_id=pavl_unit_id AND existing=1;
END IF;
INSERT INTO avl_unit_log (avl_unit_id, vehicle_id, vehicle_number, registration_number,
device_type, first_report_time, last_report_time, server_port, server_address, existing)
VALUES (pavl_unit_id, pvehicle_id, pvehicle_number, pregistration_number,
pdevice_type, v_DateTime, v_DateTime, pserver_port, pserver_address, 1);
END IF;
END
$procedure$
;


CALL public.logavlunit('354018111122143',34637914,'TM10 ','19.232529.7',5000,60109,null)
Jul 26 '21 #1
0 2496

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Greg Lindstrom | last post: by
1 post views Thread by Liza | last post: by
5 posts views Thread by Enos Meroka | last post: by
2 posts views Thread by Gregory | last post: by
7 posts views Thread by p | last post: by
67 posts views Thread by Bob Powell | last post: by
1 post views Thread by Praveen | last post: by
3 posts views Thread by Manuel | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.