1
I’m a beginner in pgsql... I use version 9.5.0 and need to update a column every time a new record is inserted. The column shall be filled in from the values entered in area_pol and area_ofi.
I am trying to create this Function to meet my need:
CREATE OR REPLACE FUNCTION sch_cap.fc_atualiza_dif_area()
RETURNS trigger AS
$$
BEGIN
UPDATE
sch_cap.tbl_cap
SET
dif_area = abs(100 - (tbl_cap.area_pol / (tbl_cap.area_ofi * 100)));
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER tg_update_dif_area BEFORE INSERT OR UPDATE ON sch_cap.tbl_cap FOR EACH ROW EXECUTE PROCEDURE sch_cap.fc_update_dif_area();
But when I try to enter a record, the following msg is shown: ERROR: stack Depth limit exceeded HINT: Increase the Configuration Parameter "max_stack_depth" (Currently 2048kB), after Ensuring the Platform’s stack Depth limit is adequate.
worked perfectly, thank you !
– Felipe Almeida