#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_uzaverka integer NOT NULL DEFAULT 0,
    ucet integer NOT NULL DEFAULT 0,
    c_stredisk integer NOT NULL DEFAULT 0,
    c_karty integer NOT NULL DEFAULT 0,
    prachy numeric(10,2) NOT NULL DEFAULT 0,
    prachy_puv numeric(10,2) NOT NULL DEFAULT 0,
    dan numeric(9,2) NOT NULL DEFAULT 0,
    dan_sazba numeric(4,1) NOT NULL DEFAULT 1,
    mnozstvi numeric(10,3) NOT NULL DEFAULT 0,
    cen_hlad character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    k_odpoctu character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    poradi integer NOT NULL DEFAULT 0,
    dotacia character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    dil_porce numeric(1,0) NOT NULL DEFAULT 1,
    id_fmenu character(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    kompez smallint NOT NULL DEFAULT 0,
    stor_mno numeric(10,3) NOT NULL DEFAULT 0,
    id_karty integer NOT NULL DEFAULT 0,
    sleva_pol numeric(10,2) NOT NULL DEFAULT 0,
    sleva_txt character varying(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    order_id integer NOT NULL DEFAULT 0,
    idriadok_orig integer NOT NULL DEFAULT 0,
    jc numeric(12,2) DEFAULT 0,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

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


	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='food600' AND table_name='<TABLENAME>' AND column_name='jc') THEN
		ALTER TABLE <SCHEMA>.<TABLENAME> ADD COLUMN jc NUMERIC(12,2) DEFAULT 0;
		UPDATE <SCHEMA>.<TABLENAME> SET jc=ROUND(CAST(prachy_puv/mnozstvi as NUMERIC),2) WHERE mnozstvi<>0;
	END IF;

END IF;
#[ KONEC SOUBORU ]#