Y
Y
yuki2020-11-02 10:41:17
PostgreSQL
yuki, 2020-11-02 10:41:17

old entry not set to postgresql?

I have a function

create function tr_ar_skl() returns trigger
    language plpgsql
as
$$
    begin
        raise notice 'old: %', old;
        insert into "arcSklad" (id_sklad, date_plan, fact_prodaj, id_arc_plan, plan_postav, fact_postav, plan_prodaj) VALUES
        (old.id_sklad, old.date_plan, old.fact_prodaj, old.id_plan, old.plan_postav, old.fact_postav, old.plan_prodaj);
    end;
$$;

alter function tr_ar_skl() owner to postgres;

Got a trigger
create trigger trigger_skl
    before delete
    on "objPSklad"
execute procedure tr_ar_skl();

Before/after deleting a row from objPSklad, you need to transfer the values ​​to arcSklad (objPSklad - warehouse plan, arcSklad - warehouse archive). When you try to delete a value from the warehouse plan, you get the error "record 'old' has not been assigned a value". Please help fix it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question