Skip to end of metadata
Go to start of metadata


The SOSSQLPlusJob JITL job provides a standardized and parameterized interface for executing Oracle SQL*Plus scripts.  The JobScheduler offers out of the box capability to execute SQL scripts, passing parameters to the SQL*Plus script  or collecting and passing on the results of a script execution to next job step as a JobScheduler Order parameter.  The SOSSQLPlusJob can be used to execute existing SQL*Plus scripts  by referring them in the command parameter. 

A Simple JITL SQL*Plus Job Example

The following example shows a basic example of the SOSSQLPlusJob . It executes a simple SQL Statment  - selecting the current system date and displaying it on stdout as order_date.

Simple JobSchedulerSQLPlusJob  Expand source


The SOSSQLPlusJob requires the following parameters:








SQL script to be executed






Database service or Instance name






User name for database access



db username


Password for database access



db password
5shell_commandSQL plus client nametrue sqlplus


Regular expression to parse output and

set order parameters for next job steps



7command_Line_optionsSQL*Plus command line optionsfalse -S -L
8ignore_ora_messagesIgnore ora error messagesfalse  
9ignore_sp2_messagesignore sp2 error messagesfalse  
10include_filesCode blocks should be executed before SQLfalse  


  • The SQL script  can be:
    • saved to a separate file such as get_order.sql . This file can subsequently be referred to as the value of the "command_script_file" job parameter. This is a recommended approach for achieving "separation of concern" in application architecture. 

    • SQL code can also be specified as the value of the CDATA tag as part of the Job.XML. This approach is preferred only if the SQL  code is very small and only used by a single job.


For SQLPlus job db_url is only the Oracle DB service name or instance name


DB Username which has necessary database permission to execute SQL script.


The password for the DB user defined in the db_user parameter.


The value of this parameter specifies the name of SQL*Plus client. The SQL sctipt will be processed by the client. This parameter is useful when executing legacy SQL code i.e. Oracle 9i, 10g


By default the SOSSQLPlusJob job defines a regular expression to parse console output from the execution of SQL Script and sets order parameters for subsequent job steps. For example, the SQL*Plus client stdout  prompt SET period_prev IS ${PN_YEAR_PREV_PERIOD}  displays the output on console; if  period_prev is 20140915, it will be parsed by regular expression ^SETs+(\\s)\\s*ISs(.*)$ and return the period_prev="20140915" order parameter.  All stdout statements matching the ^SETs+(\\s)\\s*ISs(.*)$ regular expression will be set as order_parameters.


 The value of this parameter specifies all the command line parameters required by the SQL*Plus client i.e.  -V SQL*Plus version , -S silent  no banner , -M automatic HTML output etc.


Its not always the case when you want to ignore error messages but if need be arise, value of the parameter ignore_ora_message will specify which ORA messages Jobscheduler can ignore.


If there are some expected Oracle SP2 errors which you want to ignore, use a comma separated list of all the SP2 errors as value for the ignore_sp2_messages parameter.


If you have some common code need to be executed before SQL*Plus code, you can define with include_files parameter. Multiple files can be specified, seperated by semicolons. 

Saving Database Connection Settings in a Parameter File

It strongly recommend that a db_connection parameter file such as database_connection_sqlplus.parameter.xml is used to store all the database connection settings in a common location. This approach enables the user to manage settings at central location which can then be reused by multiple jobs.

This approach also makes it easy to maintain different settings for  development, integration and production environments.

The following shows an example database connection parameter file:

database_connection_sqlplus.parameter.xml  Expand source


The next example shows a JITL job where the database connection parameters are stored in an external file. In this example a "common_settings/database" directory has been created inside the JobScheduler's live folder. 

SOSSQLPlusJob with database_connection_settings file  Expand source

Passing parameters to the SQL Script

JobScheduler order parameters can be passed to the SQL Script. SQL Script code can be parameterized by defining variables such as ${SCHEDULER_PARAM_VARIABLE_NAME}. Variables can be set using environment variables, JobScheduler task parameters ( as described in the following example) or from JobScheduler order parameters.


Passing variables to the SQL script  Expand source
Parameters can also be defined with following syntax:
  • %parameter_name%
  • ${SCHEDULER_PARAM_parameter_name}

Parameters are not case sensitive.

SQL Script as an External File 

SQL script can be defined directly inside the Job xml as a command  parameter value but is generally better stored on the file system. JITL jobs can be configured to read PL/SQL scripts from the file system by defining the script path as a value for the command  parameter i.e. 

In the following example the PL/SQL code is saved to the filesystem in C:\app\executables\sqls\get_booking_cycle.sql and subsequently referenced using the command_script_file  parameter.


Passing variables to the SQL Script  Expand source

Passing SQL script results to subsequent job steps as parameters

JobScheduler jobs can create and update JobScheduler Order parameters. The SOSSQLPlusJob can also pass on the result of SQL script execution i.e. calculated dates, parameters calculated from tables, etc. By default the JobSchedulerSQLPlus job defines a regular expression to parse console output from the execution of SQL Script and sets order parameters for subsequent job steps. For example, the SQL*Plus client stdout  prompt SET period_prev IS ${PN_YEAR_PREV_PERIOD}  displays the output on console; if  period_prev is 20140915, it will be parsed by regular expression ^SETs+(\\s)\\s*ISs(.*)$ and return the period_prev="20140915" order parameter All stdout statements matching the ^SETs+(\\s)\\s*ISs(.*)$ regular expression will be set as order_parameters.

Advanced Configuration

Generic job for executing multiple SQL scripts

The SOSSQLPlusJob can be configured as a generic node inside a job chain and executable SQL script can be defined as an order parameter. The following example shows such a generic job. The job chain has a job node - execute_sql - two orders - get_booking_cycle and count_trx_records . Each order is scheduled to be executed at a different time. Both orders are configured to use a different SQL script file i.e. get_booking_cycle.sql and count_trx_records.sql. 

  • JobChain

    JITL-SQLPlus.job_chain.xml  Expand source
  • Job

    JITL-SQLPlus.job.xml  Expand source
  • Order : get_booking_cycle

    JITL-SQLPlus,get_booking_cycle.order  Expand source
  • Order : get_trx_count

    JITL-SQLPlus,get_trx_count.order.xml  Expand source

Return parameters created by the SOSSQLPlusJob

The JobScheduler automatically creates the following order parameters, which will then be available to subsequent job steps. 


  • The sql_error parameter contains all the error messages generated during the SQL script execution. This parameter will be empty if errors do not occur.


  • The std_out_output parameter contains all the messages spooled to stdout by SQL Script.


  • The std_out_output parameter contains all the messages spooled to stdout by SQL Script.


  • The exit_code will be 0 If script ended without any error 
  • If std_error_output is not empty the exit code will be set to 99
  • If either SP2 or an ORA- error occurs the exit code will be set to 98

See also: