SalesProfitDB7.gms : SQL2GMS Example 7 - Multi-Query Batch Example (Output: A single GDX File)

Description

Several queries are executed in a single SQL2GMS call. The results are written
to a single GDX file.

Alternatively, following connection strings might also be used
C=DSN=MS Access Database;dbq=Sample.mdb
C=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sample.mdb
C=DSN=Sample
Note that for the last connection string to work, Sample.mdb must be entered as
'User DSN' in 'Control Panel | Administrative Tools | Data Sources (ODBC)'.

This model is referenced in "Example 7 - Multi-Query Batch Example" section
"Output: A single GDX File" from the SQL2GMS Documentation.

Keywords: SQL2GMS, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : SalesProfitDB7.gms   includes :  Sample.mdb  SalesProfitDB7.gms

$title SQL2GMS Example 7 - Multi-Query Batch Example (Output: A single GDX File) (SalesProfitDB7,SEQ=050)

$onText
Several queries are executed in a single SQL2GMS call. The results are written
to a single GDX file.

Alternatively, following connection strings might also be used
C=DSN=MS Access Database;dbq=Sample.mdb
C=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sample.mdb
C=DSN=Sample
Note that for the last connection string to work, Sample.mdb must be entered as
'User DSN' in 'Control Panel | Administrative Tools | Data Sources (ODBC)'.

This model is referenced in "Example 7 - Multi-Query Batch Example" section
"Output: A single GDX File" from the SQL2GMS Documentation.

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

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

$onEcho > howToRead.txt
C=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sample.mdb
X=Sample.gdx

Q1=SELECT distinct(year) FROM data
S1=year

Q2=SELECT distinct(loc) FROM data
S2=loc

Q3=SELECT distinct(prod) FROM data
S3=prd

Q4=SELECT prod, loc, year, sales FROM data
A4=sales

Q5=SELECT prod, loc, year, profit FROM data
A5=profit
$offEcho

$call sql2gms @howToRead.txt > %system.nullfile%
$ifE errorLevel<>0 $abort Error using SQL2GMS!

$call =shellExecute gdxviewer Sample.gdx
$ifE errorLevel<>0 $abort Error calling GDXVIEWER!

Set
   y   'years'
   loc 'locations'
   prd 'products';

Parameter
   sales(prd,loc,y)
   profit(prd,loc,y);

$gdxIn sample.gdx
$load y=year prd loc sales profit
$gdxIn

display sales, profit;