DBTimestamp1.gms : Retrieve data from database once each day

Description

Retrieve data from database once each day. Day of month in 'dbtimestamp.inc'
is compared with current day and if they are different, data are selected
and 'dbtimestamp.inc' is updated with current date. Note that if 'dbtimestamp.inc'
does not exist, it is created with day of month equaling to '0' to ensure data
selection.


Category : GAMS Data Utilities library


Main file : DBTimestamp1.gms   includes :  DBTimestamp1.gms  MDBSr0.gms  Transportation.mdb

$ontext
Retrieve data from database once each day. Day of month in 'dbtimestamp.inc'
is compared with current day and if they are different, data are selected
and 'dbtimestamp.inc' is updated with current date. Note that if 'dbtimestamp.inc'
does not exist, it is created with day of month equaling to '0' to ensure data
selection.
$offtext

$if %system.filesys% == UNIX $abort.noerror 'This model cannot run on a non-Windows platform';

$onecho > getdate.txt
I=Transportation.mdb
Q=select day(now())
O=dbtimestamp.inc
$offecho

$if not exist dbtimestamp.inc $call "echo 0 > dbtimestamp.inc"

scalar dbtimestamp 'day of month when data was retrieved' /
$include dbtimestamp.inc
/;

scalar currentday 'day of this run';
currentday = gday(jnow);

display "compare", dbtimestamp,currentday;

if (dbtimestamp<>currentday,
   execute '=gams.exe MDBsr0 lo=%GAMS.lo% gdx=Transportation.gdx';
   abort$errorlevel "step 0 (database access) failed";
   execute 'mdb2gms.exe @getdate.txt > %system.nullfile%'
);