Run External Script
Main menu - Query - Run External Script
The external script can contain all the usual SQL commands
(create, insert, update, drop, alter, ...)
All commands must end with semicolon ;
The script also can contain connect and disconnect commands, our special 'stop' command,
and comments. The correct syntax is shown below.
All the 'select' commands are ignored in the non-interactive mode.
The script execution runs in a separate thread - you can cancel it at any time.
connect datasource;
connect datasource/username;
connect datasource/username/password;
- all these are correct. If username and password are omitted the empty string
is used. If the script has been already connected to a data source, the connect
command reconnects it (i.e. it makes disconnect and connect).
disconnect;
- disconnects from the current data source
STOP;
- stop behaves the same as in the interactive mode (i.e. it stops the execution
of the script at this point).
comments:
/* this is a comment - it can span multiple lines */
// this is also a comment (single line)
# this is also a comment (single line - unix style)
-- this is also a comment (single line - oracle style)
Use [Qn] connection
- External script uses the database connection from the current interactive window [Qn] (if it is connected).
- This behavior gives you the possibility to connect to any data source before
executing the external script and check the results and run commit/rollback by hand
when script has ended.
- This option is useful if your script doesn't contain any 'connect' and 'disconnect' commands.
- If there is any 'connect AnotherDatasource' command in the script, the current window [Qn] will be connected
to AnotherDatasource after script end.
- If there is a 'disconnect' command at the end of script, the current window [Qn] will be disconnected.
Use another connection
- External script uses its own connection handle.
- The script must contain a 'connect' command.
Stop on error
- The execution stops on the first error.
Do not stop on error
- The whole script is executed. The errors are logged into logfile.
Example of the script:
connect oprago7/SYSADM/SYSADM;
drop table TNUM;
create table TNUM(mynum integer);
create unique index IPK_TNUM on TNUM(mynum);
insert into TNUM values (1);
insert into TNUM values (2);
insert into TNUM values (3);
STOP;
insert into TNUM values (4);
insert into TNUM values (5);
insert into TNUM values (6);
insert into TNUM values (6);
commit;
disconnect;