NAME
source - execute commands or SQL statements from a file
SYNOPSIS
source [OPTION...] FILE [ARGUMENT...]
source [OPTION...]
DESCRIPTION
Read and execute commands or SQL statements from FILE in the current shell environment.
If FILE is not supplied, source reads input from standard input.
A script can be either SQL script or an AquaScript, depending on the supplied file extension: an XJS extension would tell the shell to interpret an AquaScript.
In case of SQL scripts, the contents of the specified file are imported into the SQL buffer. When the source command encounters statement separators [ GO, go, /, @] it sends
the contents of the buffer to the database and executes the accumulated commands.
The source command executes an aquascript file (.xjs) within the project. For example, to execute a script named foo.xjs under the project demo which is in /home/tariq/demo,
you need to change directory to /home/tariq/demo/AquaScripts and then use the command source foo.xjs
It is possible to pass command line arguments to an AquaScript (but not to a SQL script). In AquaScript, the command line arguments are passed via javascript array in an
"argument" variable in the global context.
OPTIONS
-c --charset CHARSET
The character set to be used for encoding; supported values are: 'UTF-8' and 'platform-default', default to 'UTF-8'.
-e BOOLEAN
Echo FluidShell commands, default to 'true'.
-sc BOOLEAN
Stop on any exception occurred in a FluidShell command, default to 'false'.
-ss BOOLEAN
Stop on any exception occurred in an SQL statement, default to 'true'.
-tx {COMMIT | ROLLBACK | NONE}
Determine whether to commit or rollback all data changes, or do nothing, on an SQL exception when -ss is set to true and autocommit is turned off; default to 'NONE'.
See BOOLEAN VALUES section below for supported BOOLEAN values.
BOOLEAN VALUES:The followings are supported BOOLEAN values: 'true', 'false', 'yes', 'no', 'y', 'n', 'on', 'off', '1', '0'.
EXAMPLE
To execute a SQL script:
No Format |
---|
source sample.sql |
To execute an AquaScript
No Format |
---|
source aquascript.xjs |
You can also specify arguments in the source command
No Format |
---|
source aquascript.xjs ARG1 ARG2 |
To retrieve passed command line arguments in an AquaScript
No Format |
---|
if(argument != null)
{
print(argument[0]);
print(argument[1]);
print(argument[2]);
} |
SEE ALSO
go