SalesProfitDB6.gms : SQL2GMS Example 7 - Multi-Query Batch Example (Output: Several include Files)

Description

Several queries are executed in a single SQL2GMS call. The results are written
to several include files.

This model is referenced in "Example 7 - Multi-Query Batch Example" section
"Output: Several include Files" from the SQL2GMS Documentation.

Keywords: SQL2GMS, data exchange, GAMS language features


Category : GAMS Data Utilities library


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

$title SQL2GMS Example 7 - Multi-Query Batch Example (Output: Several include Files) (SalesProfitDB6,SEQ=049)

$onText
Several queries are executed in a single SQL2GMS call. The results are written
to several include files.

This model is referenced in "Example 7 - Multi-Query Batch Example" section
"Output: Several include Files" 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

Q1=SELECT distinct(year) FROM data
O1=year.inc

Q2=SELECT distinct(loc) FROM data
O2=loc.inc

Q3=SELECT distinct(prod) FROM data
O3=prod.inc

Q4=SELECT prod, loc, year, sales FROM data
O4=sales.inc

Q5=SELECT prod, loc, year, profit FROM data
O5=profit.inc
$offEcho

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

Set y 'years' /
$include year.inc
/;
Set loc 'locations' /
$include loc.inc
/;
Set prd 'products' /
$include prod.inc
/;

Parameter sales(prd,loc,y) /
$include sales.inc
/;
display sales;

Parameter profit(prd,loc,y) /
$include profit.inc
/;
display profit;