I want create a procedure (for copying the values of one table(mover_location
) to another table(mover_history
) on updation) ,and want to call up on that on a trigger in postgresql with phppgadmin.
Here is what i have tried :
PROCEDURE :-
CREATE OR REPLACE FUNCTION log_mover_location()
RETURNS trigger AS
BEGIN
INSERT INTO mover_history(reg_id,last_seen_lat,last_seen_long,last_seen_location_geog,last_updated_at)
VALUES(SELECT
mover_location.reg_id,mover_location.last_seen_lat,mover_location.last_seen_long,mover_location.last_seen_location_geog,mover_location.last_updated_at FROM mover_location) WHERE mover_history.reg_id =
@mover_location.reg_id;
END;
TRIGGER :-
CREATE TRIGGER update_mover_history
AFTER UPDATE
ON mover_location
FOR EACH ROW
EXECUTE PROCEDURE log_mover_location();
Trigger created successfully ,
But it give me a error as follows when executing the procedure:
ERROR: syntax error at or near "BEGIN"
LINE 4: BEGIN
^
the Procedure that you're created is incorrect, for example