...
Following is simple example of the JITL JobSchedulerPLSQLJob. Following job is simple example of executing an PL/SQL unanimous code bloc. Following example is selecting current system date and displaying is as a order_date.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?> <job title="Execute PL/SQL procedure" order="yes"> <description > <include file="jobs/JobSchedulerPLSQLJob.xml"/> </description> <params > <param name="db_url" value="jdbc:oracle:thin:@:1521:DORCL01"/> <param name="db_user" value="sos_scheduler"/> <param name="db_password" value="sos"/> <param name="command" value=" DECLARE v_order_date DATE := SYSDATE; BEGIN SELECT SYSDATE INTO v_order_date FROM DUAL; DBMS_OUTPUT.PUT_LINE(' +++ +++'); DBMS_OUTPUT.PUT_LINE('SET order_date IS '|| v_order_date); DBMS_OUTPUT.PUT_LINE(' +++ +++'); END; "/> <param name="variable_parser_reg_expr" value="^SET\s+([^\s]+)\s*IS\s+(.*)$"/> </params> <script language="java" java_class="sos.scheduler.db.JobSchedulerPLSQLJobJSAdapterClass"/> <run_time /> </job> |
...
Following is the example of a database connection parameter file
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<params > <param name="db_url" value="jdbc:oracle:thin:@:1521:DORCL01"/> <param name="db_user" value="sos_scheduler"/> <param name="db_password" value="sos"/> <params > |
Following is the example of a JITL job with database connection parameter stored in the external file. In following example an directory is being created in side the live folder as "common_settings/database".
...
Jobscheduler order parameters can be passed to the PL/SQL. . PL/SQL code can be parameterized by defining variables as ${SCHEDULER_PARAM_VARIABLE_NAME}. Variables can be set from environment variables, JobScheduler task parameter ( as described in the following example) or from JobScheduler order parameter.
Code Block |
---|
...
|
...
|
...
|
...
| |||
<?xml version="1.0" encoding="ISO-8859-1"?>
<job title="Execute PL/SQL procedure" order="no">
<settings >
<log_level ><![CDATA[debug9]]></log_level>
</settings>
<description >
<include file="jobs/JobSchedulerPLSQLJob.xml"/>
</description>
<params >
<!-- Database connection parameters i.e. db_url, db_user, db_password -->
<include live_file="../common_settings/database/database_connection.params.xml" node=""/>
<!-- Parameter can be passed by task or as order param -->
<param name="date_mask" value="YYYYMMDD_HH24MI"/>
<param name="command" value="
DECLARE
v_order_date VARCHAR2(16) := SYSDATE;
BEGIN
/* recommended to set variables in the PL/SQL is with ${SCHEDULER_PARAM_VARIABLE_NAME} */
SELECT to_char(SYSDATE, '\${SCHEDULER_PARAM_DATE_MASK}' )
INTO v_order_date
FROM DUAL;
DBMS_OUTPUT.PUT_LINE(' +++ +++');
DBMS_OUTPUT.PUT_LINE('SET order_date IS '|| v_order_date);
DBMS_OUTPUT.PUT_LINE(' +++ +++');
END; "/>
</params>
<script language="java" java_class="sos.scheduler.db.JobSchedulerPLSQLJobJSAdapterClass"/>
<run_time />
</job>
|
parameters can be defined with following syntex
- %parameter_name%
- ${SCHEDULER_PARAM_parameter_name}
- parameters are not case sensitive
PL/SQL script as external file
PL/SQL code can be defined directly inside the Job xml as value of command parameter or better PL/SQL scripts are stored at filesystem. JITL job can be configured to read PL/SQL script from filesystem by defining path of the script as value of command parameter i.e.
In Following example the PL/SQL code is save at filesystem in C:\app\executables\plsql\get_order_date.sql and subsequently refereed by the command parameter.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
<job title="Execute PL/SQL procedure" order="no">
<settings >
<log_level ><![CDATA[debug9]]></log_level>
</settings>
<description >
<include file="jobs/JobSchedulerPLSQLJob.xml"/>
</description>
<params >
<!-- Database connection parameters i.e. db_url, db_user, db_password -->
<include live_file="../common_settings/database/database_connection.params.xml" node=""/>
<!-- Parameter can be passed by task or as order param -->
<param name="date_mask" value="YYYYMMDD_HH24MI"/>
<!-- PL/SQL script from filesystem -->
<param name="command" value="C:/app/executables/plsql/get_order_date.sql"/>
</params>
<script language="java" java_class="sos.scheduler.db.JobSchedulerPLSQLJobJSAdapterClass"/>
<run_time />
</job>
|
...
How can results be used in subsequent jobs?
...