Previous Topic

Next Topic

Book Contents

Book Index

Scripting - Include

This option allows you to run an SQL script that is in another file. This statement cannot be used when running AQT control statements in the interactive mode of AQT.

Warning: AQT does not have any controls to prevent a recursive specification of Include statements.

Example 1:

--aqt include,file=create_table1.sql

--aqt include,file=create_table2.sql

--aqt include,file=create_table3.sql,notfounderror=n

Example 2:

This feature can be used to copy data from one database to another. The following example copies data from Table1 in Database1 to Table2 in Database2.

--aqt connect,dbs=database1

--aqt options,stoponerror=y

--aqt output,file=C:\AQT\batch_insert.sql,type=insert,filemode=replace,insert_tab=table2

select * from table1;

--aqt connect,dbs=database2

delete from table2;

--aqt include,file=C:\AQT\batch_insert.sql

Note on Filemode=New

When this is specified in an Export, AQT will can write to a file different to the one specified in File. AQT will add a sequence number to the end of file name so that it is a unique file.

One must be aware of this if you use the file in a subsequent include step. For instance, the following would be very dangerous:

--aqt export,file="C:\AQT\customer_details.sql",type=insert,filemode=new

Select * from Customer_Details;

--aqt include,file="C:\AQT\customer_details.sql"

The export may write to a file other than "C:\AQT\customer_details.sql". This means that the include statement may not pick up the file that was created during the export.


This specifies whether or not AQT is to return an error condition if the file is not found.

By default, an error condition will be returned. If you have specified:

--aqt options,stoponerror=y

then the script will cease processing.

Advanced Query Tool
© 2023 Cardett Associates Ltd. All rights reserved.