SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create function korektaCenyNalisnika(idnalesnika int) returns void as
  2. $$
  3. declare
  4. float avg;
  5. begin
  6.   create temp table times as select id_bazowego_nalesnika as id_nalesnika,count(*) as sztuk from kompozycje group by id_nalesnika;
  7.  
  8.   select avg(sztuk) into avg from times;
  9.  
  10.   update bazowe_nalesniki b
  11.       set koszt = case
  12.               when avg<sztuk  then koszt*1.05
  13.               else koszt *0.95 end
  14.  
  15.       from times t
  16.       where t.id_nalesnika = b.id_nalesnika and b.id_nalesnika=idnalesnika;
  17.  
  18.   drop table times;
  19. end;
  20. $$
  21. language plpgsql;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top