File-Driven SQL Sessions

Suppose you have an input file called QUERY1 that contained the following:

SELECT REGION_CODE, CUSTOMER.NAME, PAYMENT_VALUE
FROM REGION, CUSTOMER, ORDER_HEADER
WHERE PAYMENT_VALUE > 1000
AND ORDER_HEADER.CUSTOMER_NUMBER = CUSTOMER.CUSTOMER_NUMBER
AND CUSTOMER.REGION_CODE = REGION.REGION_CODE
ORDER BY REGION_CODE ASC, PAYMENT_VALUE DESC;

You could use this command line:

    SQLEXE <query1 >result1 -DB salesord

to run the SQL statement held in QUERY1 against the SALESORD database and to send any data which resulted to RESULT1. (The database must be specified with the '-db' command tail). In some situations you may not be able to rely on a command line to redirect SQLEXE's input and output like this. In this case you could use this command line instead:

    SQLEXE -read query1 -write result1

The numerous SQLEXE command tails are described here.

The results should appear in the file RESULT1 as shown below:

Region_Code     Name                              Payment_Value
----------- ---- -------------
ANG Barkataki Z Y 1119.48
LON Golf Oil Ltd 2378.40
NEE Mercer Q 2531.00
NEE Mercer Q 1034.26
SCT Mackintosh D.C.Electrical Ltd 5506.52
SCT Mackintosh D.C.Electrical Ltd 5506.52
SCT Mackintosh D.C.Electrical Ltd 4531.00
SCT Mackintosh D.C.Electrical Ltd 2253.26
SEE Richmond P 2054.34
SEE Kennedy R P 1094.75