#[ ZACATEK SOUBORU ]#

#DEF <SCHEMA>    food600
#DEF <PRIMARYKEY> idriadok
#DEF <TABLENAME> nlimit_hladiny

#[ CREATE TABLE ZACATEK ]#
    idriadok serial NOT NULL,
    id_limit integer NOT NULL DEFAULT 0,
    hladina character(30) NOT NULL DEFAULT '',
    c_hlad smallint NOT NULL DEFAULT 0,
    hores_kody text NOT NULL DEFAULT '',
    is_deleted smallint NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

#[ IF EXIST ZACATEK ]#
#[ PRIMARYKEY ]#



	IF EXISTS (SELECT table_name FROM information_schema.tables WHERE table_schema='food600' and table_name='nlimit_hladiny') THEN 
		IF EXISTS (SELECT table_name FROM information_schema.tables WHERE table_schema='food600' and table_name='nlimit_hl') THEN 
			insert into food600.nlimit_hladiny (id_limit, c_hlad, hladina, c_data) select id_limit, 1 as c_hlad, hladina1, c_data from food600.nlimit_hl where btrim(hladina1)<>'';
			insert into food600.nlimit_hladiny (id_limit, c_hlad, hladina, c_data) select id_limit, 2 as c_hlad, hladina2, c_data from food600.nlimit_hl where btrim(hladina2)<>'';
			update food600.nlimit_hl set hladina1='' where btrim(hladina1)<>'';
			update food600.nlimit_hl set hladina2='' where btrim(hladina2)<>'';
		END IF;
	END IF;



END IF;

#[ KONEC SOUBORU ]#