CREATE OR REPLACE FUNCTION food600.skupiny_zmena()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
DECLARE
ret CHARACTER VARYING;
ret_master CHARACTER VARYING;
polia CHARACTER VARYING DEFAULT '';
polia_master CHARACTER VARYING DEFAULT '';
hodnoty CHARACTER VARYING DEFAULT '';
hodnoty_master CHARACTER VARYING DEFAULT '';
pocetzmien INTEGER DEFAULT 0;
robsync SMALLINT DEFAULT 0;
mp1 CHARACTER VARYING DEFAULT '';
mp2 CHARACTER VARYING DEFAULT '';
mp3 CHARACTER VARYING DEFAULT '';
mp4 CHARACTER VARYING DEFAULT '';
mp5 CHARACTER VARYING DEFAULT '';
mp6 CHARACTER VARYING DEFAULT '';
mp1_master CHARACTER VARYING DEFAULT '';
mp2_master CHARACTER VARYING DEFAULT '';
mp3_master CHARACTER VARYING DEFAULT '';
mp4_master CHARACTER VARYING DEFAULT '';
mp5_master CHARACTER VARYING DEFAULT '';
mp6_master CHARACTER VARYING DEFAULT '';
mojeid INTEGER;
mojtyp INTEGER;
mojmaster INTEGER;
sommaster INTEGER DEFAULT 0;
posunhore INTEGER DEFAULT 0;
idnazapis_slavom INTEGER;
idnazapis_mastrovi INTEGER;
BEGIN
IF (TG_OP = 'UPDATE') THEN
	update food600.vypocty set druh=new.druh where c_druh=old.c_druh;
	update food600.buffer set druh=new.druh where druh=old.druh;
	update food600.bufferzad set druh=new.druh where druh=old.druh;
	update food600.uexarchobraty set druh=replace(druh,old.druh,new.druh);
	update food600.u_ex_obr set druh=replace(druh,old.druh,new.druh);
	update food600.uexarchpolozky set druh=replace(druh,old.druh,new.druh);
	update food600.u_ex_pol set druh=replace(druh,old.druh,new.druh);
END IF;
SELECT idriadok, id_master INTO mojeid, mojmaster  FROM food600.sync_set WHERE tosomja>0;
IF mojeid IS NULL THEN
	--- V nastavovacej tabulke sa nenachadza moj zaznam, synchronizacia sa nerobi
	mojeid:=0;
	robsync:=0;
	mojmaster:=0;
	sommaster:=0;
ELSE 
	--- V nastavovacej tabulke sa nenachadza moj zaznam, nejako je vyplneny aj mojmaster
	SELECT idriadok INTO sommaster FROM food600.sync_set WHERE tosomja=0 AND id_master=mojeid;
	--- Zistim, ci som master pre nejaky iny server
	IF sommaster IS NULL THEN
		sommaster:=0;
	END IF;
	robsync:=sommaster+mojmaster;
	--- Synchronizaciu robim ak som master, alebo mam mastera
	IF robsync > 0 THEN 
		--- Este treba overit, ci tuto tabulku vobec treba synchronizovat
		SELECT smer INTO robsync FROM food600.sync_tables WHERE LOWER(BTRIM(tabulka))=LOWER(TG_TABLE_NAME);
		IF robsync IS NULL THEN
			robsync:=0;
		END IF;
	END IF;
END IF;       
IF (TG_OP = 'UPDATE') THEN
	NEW.zmena := current_timestamp;
	PERFORM food600.f_zmeny_tab('skupiny',NEW.zmena,NEW.c_data);
	IF robsync>0 THEN
		IF NEW.id_sync IS NULL OR NEW.id_sync=0 THEN
			--- Ak nebol vyplneny id_sync, islo o zaznam, ktory vznikol na tomto PC (z FoodManu)
			idnazapis_slavom:=mojeid;
			idnazapis_mastrovi:=mojeid;
		ELSE
			--- Ak bol id_sync vyplneny, musel zaznam prist od slave alebo od mastera. Dalsim slavom budem posuvat originalne id, aby si povodny autor zaznamu uz tuto zmenu nemusel stahovat
			idnazapis_slavom:=NEW.id_sync;
			IF mojmaster>0 THEN
				IF idnazapis_slavom IN (SELECT idriadok FROM food600.sync_set WHERE id_master=mojeid) THEN
					idnazapis_mastrovi:=mojeid;
				ELSE
					idnazapis_mastrovi:=idnazapis_slavom;
				END IF;
			END IF;
		END IF;
		--- Mastrovi sa posuvaju moje zaznamy a zaznamy mojich slavov a posuvam mu moje id (nevracaju sa nazad zaznamy, ktore prisli zhora)
		IF mojmaster>0 THEN
			IF mojeid=idnazapis_slavom THEN
				posunhore:=1;
			ELSE
				IF idnazapis_slavom IN (SELECT idriadok FROM food600.sync_set WHERE id_master=mojeid) THEN
					posunhore:=1;
				ELSE
					posunhore:=0;
				END IF;
			END IF;
		ELSE
			posunhore:=0;
		END IF;
		--- id_sync na riadok aj tak nezapisem
		NEW.id_sync:=0;
		ret:='UPDATE food600.skupiny SET ';
		ret_master:=ret;
		IF (NEW.c_druh != OLD.c_druh) THEN
			IF pocetzmien>0 THEN
				ret:=ret||',';
				ret_master:=ret_master||',';
			END IF;
			IF NEW.c_druh>0 THEN
				ret:=ret||'c_druh=%P3%';
				mp3:='getcdruhmaster('||btrim(new.c_druh::CHARACTER(20))||')';
				ret_master:=ret_master||'c_druh=%P3%';
				mp3_master:='getcdruhslave('||btrim(new.c_druh::CHARACTER(20))||')';
			ELSE
				ret:=ret||'c_druh=0';
				ret_master:=ret_master||'c_druh=0';
			END IF;
			pocetzmien:=pocetzmien+1;
		END IF;		
		IF (NEW.c_druh_1 != OLD.c_druh_1) THEN
			IF pocetzmien>0 THEN
				ret:=ret||',';
				ret_master:=ret_master||',';
			END IF;
			IF NEW.c_druh_1>0 THEN
				ret:=ret||'c_druh_1=%P2%';
				mp2:='getcdruhmaster('||btrim(new.c_druh_1::CHARACTER(20))||')';
				ret_master:=ret_master||'c_druh_1=%P2%';
				mp2_master:='getcdruhslave('||btrim(new.c_druh_1::CHARACTER(20))||')';
			ELSE
				ret:=ret||'c_druh_1=0';
				ret_master:=ret_master||'c_druh_1=0';
			END IF;
			pocetzmien:=pocetzmien+1;
		END IF;		
		IF (NEW.c_druh_2 != OLD.c_druh_2) THEN
			IF pocetzmien>0 THEN
				ret:=ret||',';
				ret_master:=ret_master||',';
			END IF;
			IF NEW.c_druh_2>0 THEN
				ret:=ret||'c_druh_2=%P4%';
				mp4:='getcdruhmaster('||btrim(new.c_druh_2::CHARACTER(20))||')';
				ret_master:=ret_master||'c_druh_2=%P4%';
				mp4_master:='getcdruhslave('||btrim(new.c_druh_2::CHARACTER(20))||')';
			ELSE
				ret:=ret||'c_druh_2=0';
				ret_master:=ret_master||'c_druh_2=0';
			END IF;
			pocetzmien:=pocetzmien+1;
		END IF;		
		SELECT * FROM food600.updatepolastring(OLD.druh, NEW.druh, pocetzmien, ret, ret_master, 'druh') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.spart, NEW.spart, pocetzmien, ret, ret_master, 'spart') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.spart_kas, NEW.spart_kas, pocetzmien, ret, ret_master, 'spart_kas') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.typ_skup, NEW.typ_skup, pocetzmien, ret, ret_master, 'typ_skup') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.typ_skl, NEW.typ_skl, pocetzmien, ret, ret_master, 'typ_skl') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.typ_kalk, NEW.typ_kalk, pocetzmien, ret, ret_master, 'typ_kalk') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.druh1, NEW.druh1, pocetzmien, ret, ret_master, 'druh1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.druh2, NEW.druh2, pocetzmien, ret, ret_master, 'druh2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.druh3, NEW.druh3, pocetzmien, ret, ret_master, 'druh3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.druh4, NEW.druh4, pocetzmien, ret, ret_master, 'druh4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolastring(OLD.druh5, NEW.druh5, pocetzmien, ret, ret_master, 'druh5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.c_data::CHARACTER(20)), btrim(NEW.c_data::CHARACTER(20)), pocetzmien, ret, ret_master, 'c_data') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.poradie::CHARACTER(20)), btrim(NEW.poradie::CHARACTER(20)), pocetzmien, ret, ret_master, 'poradie') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan01::CHARACTER(20)), btrim(NEW.dan01::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan01') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan02::CHARACTER(20)), btrim(NEW.dan02::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan02') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan03::CHARACTER(20)), btrim(NEW.dan03::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan03') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan04::CHARACTER(20)), btrim(NEW.dan04::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan04') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan05::CHARACTER(20)), btrim(NEW.dan05::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan05') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan06::CHARACTER(20)), btrim(NEW.dan06::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan06') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan07::CHARACTER(20)), btrim(NEW.dan07::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan07') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan08::CHARACTER(20)), btrim(NEW.dan08::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan08') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan09::CHARACTER(20)), btrim(NEW.dan09::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan09') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan10::CHARACTER(20)), btrim(NEW.dan10::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan10') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan11::CHARACTER(20)), btrim(NEW.dan11::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan11') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan12::CHARACTER(20)), btrim(NEW.dan12::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan12') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan13::CHARACTER(20)), btrim(NEW.dan13::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan13') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan14::CHARACTER(20)), btrim(NEW.dan14::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan14') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan15::CHARACTER(20)), btrim(NEW.dan15::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan15') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan16::CHARACTER(20)), btrim(NEW.dan16::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan16') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan17::CHARACTER(20)), btrim(NEW.dan17::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan17') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan18::CHARACTER(20)), btrim(NEW.dan18::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan18') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan19::CHARACTER(20)), btrim(NEW.dan19::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan19') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan20::CHARACTER(20)), btrim(NEW.dan20::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan20') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan21::CHARACTER(20)), btrim(NEW.dan21::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan21') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan22::CHARACTER(20)), btrim(NEW.dan22::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan22') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan23::CHARACTER(20)), btrim(NEW.dan23::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan23') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan24::CHARACTER(20)), btrim(NEW.dan24::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan24') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan25::CHARACTER(20)), btrim(NEW.dan25::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan25') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan26::CHARACTER(20)), btrim(NEW.dan26::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan26') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan27::CHARACTER(20)), btrim(NEW.dan27::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan27') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan28::CHARACTER(20)), btrim(NEW.dan28::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan28') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan29::CHARACTER(20)), btrim(NEW.dan29::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan29') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan30::CHARACTER(20)), btrim(NEW.dan30::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan30') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan31::CHARACTER(20)), btrim(NEW.dan31::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan31') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan32::CHARACTER(20)), btrim(NEW.dan32::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan32') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan33::CHARACTER(20)), btrim(NEW.dan33::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan33') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan34::CHARACTER(20)), btrim(NEW.dan34::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan34') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan35::CHARACTER(20)), btrim(NEW.dan35::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan35') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan36::CHARACTER(20)), btrim(NEW.dan36::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan36') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan37::CHARACTER(20)), btrim(NEW.dan37::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan37') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan38::CHARACTER(20)), btrim(NEW.dan38::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan38') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan39::CHARACTER(20)), btrim(NEW.dan39::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan39') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan40::CHARACTER(20)), btrim(NEW.dan40::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan40') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dan_samo::CHARACTER(20)), btrim(NEW.dan_samo::CHARACTER(20)), pocetzmien, ret, ret_master, 'dan_samo') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana0::CHARACTER(20)), btrim(NEW.dana0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana1::CHARACTER(20)), btrim(NEW.dana1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana2::CHARACTER(20)), btrim(NEW.dana2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana3::CHARACTER(20)), btrim(NEW.dana3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana4::CHARACTER(20)), btrim(NEW.dana4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana5::CHARACTER(20)), btrim(NEW.dana5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana6::CHARACTER(20)), btrim(NEW.dana6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana7::CHARACTER(20)), btrim(NEW.dana7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana8::CHARACTER(20)), btrim(NEW.dana8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dana9::CHARACTER(20)), btrim(NEW.dana9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dana9') INTO pocetzmien, ret, ret_master;		
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb0::CHARACTER(20)), btrim(NEW.danb0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb1::CHARACTER(20)), btrim(NEW.danb1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb2::CHARACTER(20)), btrim(NEW.danb2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb3::CHARACTER(20)), btrim(NEW.danb3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb4::CHARACTER(20)), btrim(NEW.danb4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb5::CHARACTER(20)), btrim(NEW.danb5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb6::CHARACTER(20)), btrim(NEW.danb6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb7::CHARACTER(20)), btrim(NEW.danb7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb8::CHARACTER(20)), btrim(NEW.danb8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danb9::CHARACTER(20)), btrim(NEW.danb9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danb9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc0::CHARACTER(20)), btrim(NEW.danc0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc1::CHARACTER(20)), btrim(NEW.danc1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc2::CHARACTER(20)), btrim(NEW.danc2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc3::CHARACTER(20)), btrim(NEW.danc3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc4::CHARACTER(20)), btrim(NEW.danc4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc5::CHARACTER(20)), btrim(NEW.danc5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc6::CHARACTER(20)), btrim(NEW.danc6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc7::CHARACTER(20)), btrim(NEW.danc7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc8::CHARACTER(20)), btrim(NEW.danc8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danc9::CHARACTER(20)), btrim(NEW.danc9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danc9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand0::CHARACTER(20)), btrim(NEW.dand0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand1::CHARACTER(20)), btrim(NEW.dand1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand2::CHARACTER(20)), btrim(NEW.dand2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand3::CHARACTER(20)), btrim(NEW.dand3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand4::CHARACTER(20)), btrim(NEW.dand4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand5::CHARACTER(20)), btrim(NEW.dand5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand6::CHARACTER(20)), btrim(NEW.dand6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand7::CHARACTER(20)), btrim(NEW.dand7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand8::CHARACTER(20)), btrim(NEW.dand8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dand9::CHARACTER(20)), btrim(NEW.dand9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dand9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane0::CHARACTER(20)), btrim(NEW.dane0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane1::CHARACTER(20)), btrim(NEW.dane1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane2::CHARACTER(20)), btrim(NEW.dane2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane3::CHARACTER(20)), btrim(NEW.dane3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane4::CHARACTER(20)), btrim(NEW.dane4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane5::CHARACTER(20)), btrim(NEW.dane5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane6::CHARACTER(20)), btrim(NEW.dane6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane7::CHARACTER(20)), btrim(NEW.dane7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane8::CHARACTER(20)), btrim(NEW.dane8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dane9::CHARACTER(20)), btrim(NEW.dane9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dane9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf0::CHARACTER(20)), btrim(NEW.danf0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf1::CHARACTER(20)), btrim(NEW.danf1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf2::CHARACTER(20)), btrim(NEW.danf2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf3::CHARACTER(20)), btrim(NEW.danf3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf4::CHARACTER(20)), btrim(NEW.danf4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf5::CHARACTER(20)), btrim(NEW.danf5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf6::CHARACTER(20)), btrim(NEW.danf6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf7::CHARACTER(20)), btrim(NEW.danf7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf8::CHARACTER(20)), btrim(NEW.danf8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danf9::CHARACTER(20)), btrim(NEW.danf9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danf9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang0::CHARACTER(20)), btrim(NEW.dang0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang1::CHARACTER(20)), btrim(NEW.dang1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang2::CHARACTER(20)), btrim(NEW.dang2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang3::CHARACTER(20)), btrim(NEW.dang3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang4::CHARACTER(20)), btrim(NEW.dang4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang5::CHARACTER(20)), btrim(NEW.dang5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang6::CHARACTER(20)), btrim(NEW.dang6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang7::CHARACTER(20)), btrim(NEW.dang7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang8::CHARACTER(20)), btrim(NEW.dang8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dang9::CHARACTER(20)), btrim(NEW.dang9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dang9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh0::CHARACTER(20)), btrim(NEW.danh0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh1::CHARACTER(20)), btrim(NEW.danh1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh2::CHARACTER(20)), btrim(NEW.danh2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh3::CHARACTER(20)), btrim(NEW.danh3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh4::CHARACTER(20)), btrim(NEW.danh4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh5::CHARACTER(20)), btrim(NEW.danh5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh6::CHARACTER(20)), btrim(NEW.danh6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh7::CHARACTER(20)), btrim(NEW.danh7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh8::CHARACTER(20)), btrim(NEW.danh8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danh9::CHARACTER(20)), btrim(NEW.danh9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danh9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani0::CHARACTER(20)), btrim(NEW.dani0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani1::CHARACTER(20)), btrim(NEW.dani1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani2::CHARACTER(20)), btrim(NEW.dani2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani3::CHARACTER(20)), btrim(NEW.dani3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani4::CHARACTER(20)), btrim(NEW.dani4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani5::CHARACTER(20)), btrim(NEW.dani5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani6::CHARACTER(20)), btrim(NEW.dani6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani7::CHARACTER(20)), btrim(NEW.dani7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani8::CHARACTER(20)), btrim(NEW.dani8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dani9::CHARACTER(20)), btrim(NEW.dani9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dani9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj0::CHARACTER(20)), btrim(NEW.danj0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj1::CHARACTER(20)), btrim(NEW.danj1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj2::CHARACTER(20)), btrim(NEW.danj2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj3::CHARACTER(20)), btrim(NEW.danj3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj4::CHARACTER(20)), btrim(NEW.danj4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj5::CHARACTER(20)), btrim(NEW.danj5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj6::CHARACTER(20)), btrim(NEW.danj6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj7::CHARACTER(20)), btrim(NEW.danj7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj8::CHARACTER(20)), btrim(NEW.danj8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danj9::CHARACTER(20)), btrim(NEW.danj9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danj9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank0::CHARACTER(20)), btrim(NEW.dank0::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank1::CHARACTER(20)), btrim(NEW.dank1::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank2::CHARACTER(20)), btrim(NEW.dank2::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank3::CHARACTER(20)), btrim(NEW.dank3::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank4::CHARACTER(20)), btrim(NEW.dank4::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank5::CHARACTER(20)), btrim(NEW.dank5::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank6::CHARACTER(20)), btrim(NEW.dank6::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank7::CHARACTER(20)), btrim(NEW.dank7::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank8::CHARACTER(20)), btrim(NEW.dank8::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dank9::CHARACTER(20)), btrim(NEW.dank9::CHARACTER(20)), pocetzmien, ret, ret_master, 'dank9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl0::CHARACTER(20)), btrim(NEW.danl0::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl0') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl1::CHARACTER(20)), btrim(NEW.danl1::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl1') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl2::CHARACTER(20)), btrim(NEW.danl2::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl3::CHARACTER(20)), btrim(NEW.danl3::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl4::CHARACTER(20)), btrim(NEW.danl4::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl5::CHARACTER(20)), btrim(NEW.danl5::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl5') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl6::CHARACTER(20)), btrim(NEW.danl6::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl6') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl7::CHARACTER(20)), btrim(NEW.danl7::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl7') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl8::CHARACTER(20)), btrim(NEW.danl8::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl8') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.danl9::CHARACTER(20)), btrim(NEW.danl9::CHARACTER(20)), pocetzmien, ret, ret_master, 'danl9') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.dotacia::CHARACTER(20)), btrim(NEW.dotacia::CHARACTER(20)), pocetzmien, ret, ret_master, 'dotacia') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.sumar::CHARACTER(20)), btrim(NEW.sumar::CHARACTER(20)), pocetzmien, ret, ret_master, 'sumar') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.samozdan::CHARACTER(20)), btrim(NEW.samozdan::CHARACTER(20)), pocetzmien, ret, ret_master, 'samozdan') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.koef_c_2::CHARACTER(20)), btrim(NEW.koef_c_2::CHARACTER(20)), pocetzmien, ret, ret_master, 'koef_c_2') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.koef_c_3::CHARACTER(20)), btrim(NEW.koef_c_3::CHARACTER(20)), pocetzmien, ret, ret_master, 'koef_c_3') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepolanumeric(btrim(OLD.koef_c_4::CHARACTER(20)), btrim(NEW.koef_c_4::CHARACTER(20)), pocetzmien, ret, ret_master, 'koef_c_4') INTO pocetzmien, ret, ret_master;
		SELECT * FROM food600.updatepoladatetime(to_char(OLD.zmena,'YYYYMMDD HH24:MI:SS'), to_char(NEW.zmena,'YYYYMMDD HH24:MI:SS'), pocetzmien, ret, ret_master, 'zmena') INTO pocetzmien, ret, ret_master;
		IF pocetzmien>0 THEN
			IF mojmaster>0  AND posunhore>0 THEN 
				ret:=ret||', id_sync='||btrim(idnazapis_mastrovi::CHARACTER(10));
				IF OLD.c_d_m IS NOT NULL AND OLD.c_d_m<>0 THEN
					ret:=ret||' WHERE c_druh='||btrim(OLD.c_d_m::CHARACTER(20))||';';
				ELSE
					ret:=ret||' WHERE c_druh=%P1%';
					mp1:='getcdruhmaster('||(OLD.c_druh::CHARACTER(20))||')';
				END IF;
				INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret, 'skupiny', OLD.c_druh, 'U', OLD.druh, mp1, mp2, mp3, mp4, mp5, mp6, idnazapis_mastrovi, 0);
			END IF;
			IF sommaster>0 THEN 
				ret_master:=ret_master||', id_sync='||btrim(idnazapis_slavom::CHARACTER(10));
				ret_master:=ret_master||' WHERE c_d_m='||btrim(OLD.c_druh::CHARACTER(20))||';';
			INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret_master, 'skupiny', OLD.c_druh, 'U', OLD.druh, mp1, mp2, mp3, mp4, mp5, mp6, idnazapis_slavom, 1);
			END IF;
		END IF;
	END IF;
	RETURN NEW;
  ELSIF (TG_OP = 'INSERT') THEN
	NEW.zmena := current_timestamp;
	PERFORM food600.f_zmeny_tab('skupiny',NEW.zmena,NEW.c_data);
	IF robsync>0  THEN
		IF NEW.id_sync IS NULL OR NEW.id_sync=0 THEN
			--- Ak nebol vyplneny id_sync, islo o zaznam, ktory vznikol na tomto PC (z FoodManu)
			idnazapis_slavom:=mojeid;
			idnazapis_mastrovi:=mojeid;
		ELSE
			--- Ak bol id_sync vyplneny, musel zaznam prist od slave alebo od mastera. Dalsim slavom budem posuvat originalne id, aby si povodny autor zaznamu uz tuto zmenu nemusel stahovat
			idnazapis_slavom:=NEW.id_sync;
			IF mojmaster>0 THEN
				IF idnazapis_slavom IN (SELECT idriadok FROM food600.sync_set WHERE id_master=mojeid) THEN
					idnazapis_mastrovi:=mojeid;
				ELSE
					idnazapis_mastrovi:=idnazapis_slavom;
				END IF;
			END IF;
		END IF;
		--- Mastrovi sa posuvaju moje zaznamy a zaznamy mojich slavov a posuvam mu moje id (nevracaju sa nazad zaznamy, ktore prisli zhora)
		IF mojmaster>0 THEN
			IF mojeid=idnazapis_slavom THEN
				posunhore:=1;
			ELSE
				IF idnazapis_slavom IN (SELECT idriadok FROM food600.sync_set WHERE id_master=mojeid) THEN
					posunhore:=1;
				ELSE
					posunhore:=0;
				END IF;
			END IF;
		ELSE
			posunhore:=0;
		END IF;
		--- id_sync na riadok aj tak nezapisem
		NEW.id_sync:=0;
		ret:='INSERT INTO food600.skupiny (';
		ret_master:=ret;
		IF NEW.c_druh_1 IS NOT NULL THEN
			IF pocetzmien>0 THEN
				polia:=polia||',';
				hodnoty:=hodnoty||',';
				polia_master:=polia_master||',';
				hodnoty_master:=hodnoty_master||',';
			END IF;
			polia:=polia||'c_druh_1';
			polia_master:=polia_master||'c_druh_1';
			IF NEW.c_druh_1>0 THEN
				hodnoty:=hodnoty||'%P3%';
				mp3:='getcdruhmaster('||btrim(NEW.c_druh_1::CHARACTER(20))||')';
				hodnoty_master:=hodnoty_master||'%P3%';
				mp3_master:='getcdruhslave('||btrim(NEW.c_druh_1::CHARACTER(20))||')';
			ELSE
				hodnoty:=hodnoty||'0';
				hodnoty_master:=hodnoty_master||'0';
			END IF;
			pocetzmien:=pocetzmien+1;
		END IF;		
		IF NEW.c_druh_2 IS NOT NULL THEN
			IF pocetzmien>0 THEN
				polia:=polia||',';
				hodnoty:=hodnoty||',';
				polia_master:=polia_master||',';
				hodnoty_master:=hodnoty_master||',';
			END IF;
			polia:=polia||'c_druh_2';
			polia_master:=polia_master||'c_druh_2';
			IF NEW.c_druh_2>0 THEN
				hodnoty:=hodnoty||'%P4%';
				mp4:='getcdruhmaster('||btrim(NEW.c_druh_2::CHARACTER(20))||')';
				hodnoty_master:=hodnoty_master||'%P4%';
				mp4_master:='getcdruhslave('||btrim(NEW.c_druh_2::CHARACTER(20))||')';
			ELSE
				hodnoty:=hodnoty||'0';
				hodnoty_master:=hodnoty_master||'0';
			END IF;
			pocetzmien:=pocetzmien+1;
		END IF;		
		SELECT * FROM food600.insertpolastring(NEW.druh, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.spart, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'spart') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.spart_kas, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'spart_kas') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.typ_skup, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'typ_skup') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.typ_skl, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'typ_skl') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.typ_kalk, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'typ_kalk') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.druh1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.druh2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.druh3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.druh4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolastring(NEW.druh5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'druh5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.c_data, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'c_data') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.poradie, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'poradie') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan01, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan01') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan02, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan02') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan03, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan03') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan04, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan04') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan05, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan05') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan06, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan06') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan07, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan07') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan08, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan08') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan09, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan09') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan10, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan10') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan11, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan11') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan12, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan12') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan13, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan13') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan14, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan14') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan15, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan15') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan16, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan16') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan17, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan17') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan18, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan18') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan19, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan19') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan20, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan20') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan21, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan21') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan22, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan22') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan23, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan23') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan24, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan24') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan25, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan25') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan26, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan26') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan27, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan27') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan28, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan28') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan29, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan29') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan30, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan30') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan31, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan31') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan32, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan32') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan33, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan33') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan34, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan34') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan35, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan35') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan36, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan36') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan37, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan37') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan38, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan38') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan39, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan39') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan40, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan40') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dan_samo, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dan_samo') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dana9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dana9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danb9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danb9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danc9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danc9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dand9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dand9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dane9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dane9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danf9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danf9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dang9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dang9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danh9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danh9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dani9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dani9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danj9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danj9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dank9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dank9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl0, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl0') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl1, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl1') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl5, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl5') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl6, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl6') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl7, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl7') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl8, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl8') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.danl9, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'danl9') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.dotacia, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'dotacia') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.sumar, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'sumar') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.samozdan, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'samozdan') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.koef_c_2, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'koef_c_2') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.koef_c_3, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'koef_c_3') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpolanumeric(NEW.koef_c_4, pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'koef_c_4') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		SELECT * FROM food600.insertpoladatetime(to_char(NEW.zmena,'YYYYMMDD HH24:MI:SS'), pocetzmien, hodnoty, polia, hodnoty_master, polia_master, 'zmena') INTO pocetzmien, hodnoty, polia, hodnoty_master, polia_master;
		IF pocetzmien>0 THEN
			polia:=polia||',';
			hodnoty:=hodnoty||',';
			polia_master:=polia_master||',';
			hodnoty_master:=hodnoty_master||',';
			IF mojmaster>0 AND posunhore>0 THEN 
				polia:=polia||'id_sync';
				hodnoty:=hodnoty||btrim(idnazapis_mastrovi::CHARACTER(10));
				pocetzmien:=pocetzmien+1;
				ret:=ret||polia||') VALUES ('||hodnoty||') RETURNING c_druh;';
				INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret, 'skupiny', NEW.c_druh, 'I', NEW.druh, mp1, mp2, mp3, mp4, mp5, mp6, idnazapis_mastrovi, 0);
			END IF;
			IF sommaster>0 THEN 
				polia_master:=polia_master||'id_sync';
				hodnoty_master:=hodnoty_master||btrim(idnazapis_slavom::CHARACTER(20));
				pocetzmien:=pocetzmien+1;
				ret_master:=ret_master||polia_master||') VALUES ('||hodnoty_master||') RETURNING c_druh;';
				INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret_master, 'skupiny', NEW.c_druh, 'I', NEW.druh, mp1, mp2, mp3, mp4, mp5, mp6, idnazapis_slavom, 1);
			END IF;
		END IF;
	END IF;
	RETURN NEW;
ELSIF (TG_OP = 'DELETE') THEN
	IF robsync>0 THEN
		ret:='DELETE FROM food600.skupiny WHERE c_druh=';
		ret_master:='DELETE FROM food600.skupiny WHERE c_d_m=';
		IF mojmaster>0 THEN 
			IF (OLD.c_d_m>0) THEN
				ret:=ret||OLD.c_d_m::CHARACTER(20);
			ELSE
				ret:=ret||'%P1%';
				mp1:='getcdruhmaster('||btrim(OLD.c_druh::CHARACTER(20))||')';
			END IF;	
			INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret, 'skupiny', OLD.c_druh, 'D', OLD.druh, mp1, mp2, mp3, mp4, mp5, mp6, mojeid, 0);
		END IF;
		IF sommaster>0 THEN 
			ret_master:=ret_master||OLD.c_druh::CHARACTER(20);
			INSERT INTO food600.sync_skupiny (prikaz, tabulka, c_druh, operacia, druh, p1, p2, p3, p4, p5, p6, id_sync, is_master) VALUES (ret_master, 'skupiny', OLD.c_druh, 'D', OLD.druh, mp1, mp2, mp3, mp4, mp5, mp6, mojeid, 1);
		END IF;
	END IF;		
	RETURN OLD;
END IF;
END;
$BODY$;
