CREATE OR REPLACE PROCEDURE INITDATA ( Addr IN NUMBER , Value IN NUMBER ) AS BEGIN if exists (select Addr from BeginEletricity where BeginEletricity.Addr = Addr) then update BeginEletricity set BeginEletricity.Value = Value, State = 0 where (BeginEletricity.Addr = Addr and BeginEletricity.Value <> Value); else insert into BeginEletricity values(Addr, Value, 0); end if; END INITDATA;