VERS='5.4.65'

echo "Mise a jour de la base de donnees pour Version $VERS"

isql - - <<EOT

database gc;

UPDATE 
  gc_parsys 
SET 
  version='$VERS';

create table gc_fcc 
  (
    nofac char(10),
    cli char(6),
    ind smallint,
    edite smallint,
    traite smallint,
    ouverte smallint,
    encompte smallint,
    export smallint,
    devise smallint,
    vnd char(2),
    numbl char(10),
    rsoc char(30),
    ad1 char(25),
    ad2 char(25),
    cpv char(25),
    numdep smallint,
    remise float,
    dteinit date,
    dteche date,
    total float,
    totht float,
    totva float,
    margbr float,
    comment1 char(40),
    refcom char(7),
    mdreg smallint,
    delreg smallint,
    jreg smallint,
    typreg smallint,
    dtcom date,
    numop char(10),
    comment2 char(40),
    comment3 char(40),
    hrinit integer,
    totom float,
    totda float,
    numcais smallint,
    codpost char(5),
    numchant smallint,
    solde float
  );

create unique index ix_fcc01 on gc_fcc (nofac);
create index ix_fcc02 on gc_fcc (dteinit,nofac);

create table gc_lfc 
  (
    numfac char(10),
    numlig smallint,
    code char(12),
    desig char(60),
    tva smallint,
    qt float,
    uv float,
    px float,
    rev float,
    remis float,
    promo smallint,
    codtar smallint,
    numdep smallint,
    pxbase float,
    grat float,
    rempromo float,
    om smallint,
    da smallint,
    tl char(2),
    unite char(7),
    compo smallint,
    nodos char(6),
    qtav float,
    qtliv float,
    rvlu float,
    typtail char(3),
    nlt smallint,
    codecoul char(2),
    vnd char(2)
  );

create unique index ux_lfc01 on gc_lfc (numfac,numlig);

CLOSE DATABASE;

EOT

chmod 666 $DBPATH/gc.dbs/*.idx
chmod 666 $DBPATH/gc.dbs/*.dat

echo "Mise a jour terminee"
