----    slovenskaverzia=.F.       ----
---    Oprava C_DATA v UCTOBD a TEXTY.MODUL

DO
$$
BEGIN
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='food600' and table_name='texty' and column_name='modul') THEN
		UPDATE food600.texty SET modul='FOOD' WHERE btrim(modul)='';
	END IF;
UPDATE food600.sk__fin SET u_cas=SUBSTRING(aaa.u_cas FROM 7 FOR 2)||' '||SUBSTRING(aaa.u_cas FROM 9 FOR 2)||':'||SUBSTRING(aaa.u_cas FROM 11 FOR 2) FROM (SELECT sk_fin.u_cis, sk_fin.u_cas, sk_fin.uzaverka, sk__uza.idriadok FROM food600.sk_fin INNER JOIN food600.sk__uza ON sk_fin.uzaverka=sk__uza.uzaverka AND sk_fin.id_kas=sk__uza.id_kas WHERE length(btrim(sk_fin.u_cis))>2 AND food600.tvor_cislo(SUBSTRING(sk_fin.u_cis FROM 3))>0 AND POSITION('*' IN  sk_fin.uzaverka)=0) aaa  WHERE (LENGTH(sk__fin.u_cas) - LENGTH(REPLACE(sk__fin.u_cas, ':','')))=2 AND  sk__fin.ucet=(SUBSTRING(aaa.u_cis FROM 3)::INTEGER) AND sk__fin.c_uzaverka=aaa.idriadok ;
IF EXISTS (SELECT trigger_name FROM information_schema.triggers WHERE trigger_schema='food600' and trigger_name='tkarty_zmena') THEN
	DROP TRIGGER tkarty_zmena ON food600.karty;
END IF;
END
$$