Batch Query and Report execution
|Abstract:||Schedule LANSA Client queries or call a query from an application|
|Submitted By:||LANSA Technical Support|
LANSA Client allows the automation of the actions required to run a query and a report. This means that a LANSA Client query (with or without a related report) can be called from any application, including from a scheduling facility.
Any variable values required by the query can be included on the command line or in a file called from the command line. Below follow a few syntax examples of how to run an automated query. Refer to the LANSA Client documentation for more details.
The basic syntax (without any parameters) is:
To run a query in batch mode (there will be no prompting for selection criteria) add a B, /b or /B.
LCRUN32EXE <queryname>.lcq /B
To specify a host, which is needed if more than one host can be accessed, add either HSTN=<n> with the sequence number of the host in the host definitions, or add HSTD=<description> with a description that matches a host in the host definitions. (Host definitions are registered with LANSA Client's administration utilty)
For example, to execute myquery in batch against a host that defined as "Sales-History"
LCRUN32EXE myquery.lcq /B HSTD="Sales-History"
PROMPTED SELECTION CRITERIA PARAMETERS
The value of a prompted parameter can be manipulated by referring to its sequence number and giving it a value: QPnn=<parameter value>
For example, to execute myquery in batch against a host that is listed as the second host in the host definitions, with a first (date) parameter value of 981101 and a second (city) parameter North Sydney:
LCRUN32EXE myquery.lcq /B HSTN=2 QP01=981101 QP02="North Sydney"
To control whether the report output will go to a Printer or will be displayed in a Window, use RPTO=W or RPTO=P. In other words, if in the query definition "Output to Report" has been specified, then variables can be used to send that report to a printer (P) or to display it on the screen (W). If the query definition has a specification "Output to" File, Printer or Windows, then the RPTO variable in the automated query will be ignored. RPTO only work for reports.
When queries and reports are run in batch, the most likely choices would be to have the output to a file or to a Printed report. It would make little sense to display information on a screen when a query is run in batch mode. The scheduler could be running several queries with Output to File and then run the Crystal reports interactively or to a printer.
Example: To execute myquery in batch against a host that is listed as the second host in my host definitions, with a first (date) parameter value of 981101 and a second (city) parameter North Sydney and send the report to a printer:
LCRUN32EXE myquery.lcq /B HSTN=2 QP01=981101 QP02="North Sydney" RPTO=P
SPECIFYING QUERY VARIABLES IN AN INPUT FILE
Alternatively specify the query variables in an input file and add it to the query
QFIL=<file path and filename>
For example, to execute myquery with variables as defined in file c:\temp\novsales
LCRUN32EXE myquery.lcq QFIL=c:\temp\novsales
Note: All variables (HSTN, HSTD, QPnn, RPTO and QFIL must be specified in upper case)