VERS='5.69.46'

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

isql - - <<EOT

DATABASE gc;

UPDATE 
  gc_parsys 
SET 
  version='$VERS'
WHERE
  version<'$VERS';

drop table gc_loc;
drop table gc_lres;
drop table gc_noloc;
drop table gc_ldisp;
drop table gc_nodisp;

create table gc_loc 
  (
    code char(12),
    serie1 char(20),
    serie2 char(20),
    serie3 char(20),
    numdep smallint,
    dttrsf date,
    actif smallint
  );
create index ixloc01 on gc_loc (code);

create table gc_lres 
  (
    code integer,
    typelocation smallint,
    cli char(6),
    vnd char(2),
    rsoc char(30),
    respon char(30),
    ad1 char(25),
    ad2 char(25),
    cpv char(25),
    codpost char(5),
    tel char(15),
    fax char(15),
    dteinit date,
    dtdeb date,
    dtfin date,
    comment1 char(40),
    comment2 char(40),
    comment3 char(40),
    caution float,
    mdreg smallint,
    codeart char(12),
    serie char(20),
    numdep smallint,
    numchq char(20),
    nofac char(20),
    dtclose date,
    tarif float
  );
create index ixlres01 on gc_lres (code);

create table gc_noloc 
  (
    num integer
  );

create table gc_ldisp 
  (
    compteur integer,
    codeart char(12),
    serie char(20),
    dtdeb date,
    dtfin date,
    comment char(40)
  );
create index ixldisp01 on gc_ldisp (codeart);

create table gc_nodisp 
  (
    num integer
  );

CLOSE DATABASE;

EOT

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

echo "Mise a jour terminee"
