Get Column value of previous row in postgres “cannot use window function in UPDATE”
问题 When i is greater than or equal to 3, I am trying to fetch the previous row value of that column and trying to use it in the current row calculation and I have tried using Lag function to do so but was not successful,was getting the error as "cannot use window function in UPDATE". Could some one help me out.Thanks! CREATE OR REPLACE FUNCTION vin_calc() RETURNS text AS $BODY$ DECLARE r res%rowtype; i integer default 0; x text; curs2 CURSOR FOR SELECT * FROM res; BEGIN open curs2; -- FOR r IN