This feature of AQT allows you to run a set of SQL statements (and other AQT functions) in unattended batch mode.
An AQT batch script consists of:
a batch file which runs AQT, and specifies the name of the script file
a script file containing the AQT scripting control statements
a log file to which AQT reports on the running of the script
other files to which AQT has exported data
A number of example batch files are supplied with AQT. We recommend that you use these as models for building your own scripts.
The sample files are held in the Application Data directory - this is directory %appdata%\Advanced Query Tool\batch, where %appdata% is your APPDATA environment variable. This is:
(for Windows XP and earlier) x:\Documents and Settings\<username>\Application Data\Advanced Query Tool\batch
(for Windows Vista, Windows 7, Windows 8) x:\Users\<username>\AppData\Roaming\Advanced Query Tool\batch
The batch file consists of the following statement
aqtv10.exe infile logfile options
infile is a script file containing SQL statements and AQT script statements.
logfile (optional) is a file where AQT will write messages about the processing of the script. If logfile is not specified, AQT will write log output to file aqt_output.log in the same directory as infile. If the log file already exists, AQT will append the output to it.
options. This specifies some miscellaneous options. If these are specified, you should also code logfile.
At this stage, only one option is implement: NOAPPEND. When this is specified, the log output over-writes the existing log file (eg. the output is not appended to it).
if the batch file is not in the same directory as your AQT executable or script files, you will need to use a fully-qualified name for these files.
You run the batch script by running the batch file. This can be done by double clicking the file in the Windows explorer.
Scheduling AQT batch scripts
AQT does not supply a scheduler for running your batch scripts. This is because Windows has a scheduler which can be used for this purpose. The Window scheduler can be run with the AT command (from a command prompt). In later versions of Windows there is a graphical interface into this - see Start > Programs > Accessories > System Tools > Scheduled Tasks.
Note that when running a scheduled task, you should run this under your own userid. If running it under a different userid you can hit several problems:
AQT may not be registered. Registration is at the user level, so if the script runs under a different userid it will not see the registration information that was loaded under your userid.
another userid will not see the files in your %appdata% directory structure, as these are isolated between users.
The script file consists of a series of AQT scripting statements and SQL statements. batch_sample.sql is an example of this, and demonstrates many of the script statements.
Your script should have at least one Connect function to sign onto the database you wish to run your SQL against.
You can sign onto multiple databases; the Use function specifies which database a particular SQL statement runs against.
You can run both Action SQL statements and Select statements. Select statements can only send output to a file.
Most AQT script statements can be run from the Run SQL window. You can test a statement in this window before putting it in your script file.
Many AQT functions have an option for generating a script control statement. For instance, in the export data window you can do this through File > View Export Options or Ctrl+G. This shows how more complicated scripting statements are set up.