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.

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.accdb  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.

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

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

$onEcho > howToRead.txt
C=DRIVER=Microsoft Access Driver (*.mdb, *.accdb);dbq=.\Sample.accdb
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!

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;