Error in PostgreSQL trigger - UPDATE

0

I have a question for you. I am developing a database in which I have a table called "currencies", which has a field called dvs_local (boolean) which indicates which is the local currency of the system (only one of the table - TRUE, the rest must be FALSE ). For which I have implemented the following trigger:

CREATE TRIGGER divisas_local_2_trg
BEFORE UPDATE
ON privado.divisas
FOR EACH STATEMENT
EXECUTE PROCEDURE privado.divisas_local_2_fnc();

The function is as follows:

CREATE OR REPLACE FUNCTION privado.divisas_local_2_fnc()
RETURNS trigger AS
$BODY$
declare
    filtro varchar(150);
begin
    filtro := old.dvs_nombre;
    update privado.divisas set dvs_local = not(new.dvs_local) where dvs_nombre <> filtro;
    return new;
end
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION privado.divisas_local_2_fnc()
  OWNER TO costos_industriales;

When I try to update some of the records I get the following error:

  

The registration -old- has not been assigned yet.

     

The structure of the row of a record not yet assigned is not   determined.

Thank you very much for everything. Greetings.

    
asked by gabrieldrv 04.07.2018 в 01:47
source

0 answers