Distances2.gms : SQL2GMS Example 1 - Reading a single valued Table

Description

The programs selects distances from database "Sample.accdb"
and writes them to "distances.inc" or "distances.gdx" or both.
Note that at least one output file name has to be provided.
If no output file name is provided, the program starts to run
in interactive mode.

This model is referenced in "Example 1 - Reading a single valued Table" from
the SQL2GMS Documentation.

Keywords: SQL2GMS, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : Distances2.gms   includes :  Sample.accdb  Distances2.gms

$title SQL2GMS Example 1 - Reading a single valued Table (Distances2,SEQ=047)

$onText
The programs selects distances from database "Sample.accdb"
and writes them to "distances.inc" or "distances.gdx" or both.
Note that at least one output file name has to be provided.
If no output file name is provided, the program starts to run
in interactive mode.

This model is referenced in "Example 1 - Reading a single valued Table" from
the SQL2GMS Documentation.

Keywords: SQL2GMS, data exchange, GAMS language features
$offText

$callTool win32.msappavail Access
$if errorlevel 1 $abort.noError "No Access available"

$call sql2gms C="DRIVER=Microsoft Access Driver (*.mdb, *.accdb);dbq=.\Sample.accdb" Q="SELECT city1, city2, distance FROM distances" O=distances.inc X=distances.gdx A=distances > %system.nullfile%
$ifE errorLevel<>0 $abort Error using SQL2GMS!

* the following options can be used
* B: Quote blanks
* M: Mute
* L: No listing
*$call =sql2gms C="DRIVER=Microsoft Access Driver (*.mdb, *.accdb);dbq=.\Sample.accdb" Q="SELECT city1, city2, distance FROM distances" O=distances.inc X=distances.gdx A=distances B M L
*$ifE errorLevel<>0 $abort Error using SQL2GMS with options B, M, L activated!

* output could be produced separately as follows:
*$call =sql2gms C="DRIVER=Microsoft Access Driver (*.mdb, *.accdb);dbq=.\Sample.accdb" Q="SELECT city1, city2, distance FROM distances" O=distances.inc
*$ifE errorLevel<>0 $abort Error using SQL2GMS writing to include file only!
*$call =sql2gms C="DRIVER=Microsoft Access Driver (*.mdb, *.accdb);dbq=.\Sample.accdb" Q="SELECT city1, city2, distance FROM distances" X=distances.gdx A=distances
*$ifE errorLevel<>0 $abort Error using SQL2GMS writing to gdx file only!

Set
   i 'canning plants' / seattle,  san-diego /
   j 'markets'        / new-york, chicago, topeka /;

Parameter dist1(i,j) 'distances in thousands of miles' /
$include distances.inc
/;

Parameter dist2(i,j) 'distances in thousands of miles';
$gdxIn 'distances.gdx'
$load dist2 = distances
$gdxIn

display dist1, dist2;