Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Managed Jobs PHP web interface provides a text for this area, while in the Job Scheduler Object Editor (JOE), only one input field is available.
PHP converts the textarea hexadecimal because a newline can not be written in an XML attribute.
If you want to use the job with multiple statements without the MANAGED JOBS, then the statements must be changed hexadecimal.
The following is an example of a job chain in which the statements are converted before launching.

launchDB.job_chain.xml:

Code Block
 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/job_chain.xml job ] title="Launch Database Statement" order="yes">      
    <description>_chain] orders_recoverable="yes" visible="yes">
     <job_chain_node state="prepare" job="prepareStatements" next_state="launch"  error_state="error"/>
     <job_chain_node state="launch"  job="launchDB"          next_state="success" error_state="error"/>
     <job_chain_node  <include file=state="success"/>
     <job_chain_node state="error"/>
 </job_chain>

prepareStatements.job.xml:
It reads order parameter statements and statement_newline, replaces statement_newline to a real newline, converts statements hexadecimal and writes the result in the command parameter.

Code Block

 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/job.xml job] order="yes" stop_on_error="no" title="set command param hexadecimal">
"jobs/JobSchedulerManagedManagedDatabaseJob.xml" />     <script language="javascript">
         </description>           
    <params>        
        <param name="command"                 value="" />        
        <param name="database_connection"     value="" />        
        <param name="db_class"        ![CDATA[
 function spooler_process()\{
   spooler_log.info(spooler_job.name + " tries to set command parameter.")
   var orderParams = spooler_task.order.params;  
   var stmts = orderParams.value("statements");
   var sep = orderParams.value("statement_newline");
   spooler_log.info("param statements = " + stmts);
   spooler_log.info("param statement_newline = " + sep);
   stmts = stmts.split(sep).join("\n").bin2hex();
   orderParams.set_var("command", stmts);
   spooler_log.info("param command = " + orderParams.value("command"));  
   return true;
 \}
 
 String.prototype.bin2hex = function() \{
   var hex = "";
   var str = this;  
   var sLength = this.length;
   for( var i = 0; i < sLength; i++ ) \{ 
     hex += str.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
   \}
   return hex;
 \}
        value="" /> ]]>
     </script>
   
  <run_time/>
 </job>

launchDB.job.xml:
It executes the statements.

Code Block

 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/job.xml job] title="Launch Database <paramStatement" nameorder="db_driver"yes" stop_on_error="no">
     <description>
         <include valuefile="jobs/JobSchedulerManagedDatabaseJob.xml" />
     </description>
     <params>
         <param name="db_urlclass"                value="SOSMySQLConnection"/>
         <param valuename="db_driver" />               value="com.mysql.jdbc.Driver"/>
         <param name="db_userurl"                  value="" />jdbc:mysql://localhost:3306/scheduler"/>
         <param name="db_user"                 value="scheduler"/>
         <param name="db_password"             value="scheduler" />
         <param name="command"    
        <param name="resultset_as_warning"    value="false" />
        </params>
     <script   <param namelanguage="exec_returns_resultsetjava"  valuejava_class="false" />   sos.scheduler.managed.JobSchedulerManagedDatabaseJob"/>
     <run_time/>
 </job>

launchDB,updateMyTable.order.xml:

Code Block

 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/order.xml order] title="update MY_TABLE">
     <params>
         <param name="resultsetstatement_as_parametersnewline" value="false__xA0__" />
      
   <param  </params>      
     <script language="java" java_class="sos.scheduler.managed.JobSchedulerManagedDatabaseJob"name="statements" value="update MY_TABLE set a='foo' where b='bar';__xA0__commit;"/>
     </params>
     <run_time/>
 </job>order>