Execute each line in the job, and execute the job

Source: Internet
Author: User

Execute each line in the job, and execute the job
Zookeeper

Execute each line in the job

Sometimes, we need to execute a job or a conversion multiple times, and each input parameter is different. If you are migrating data and need to import old data every day, a job needs to import data based on the specified date, which is specified as a parameter, if we need to import all the old data from a start date to yesterday, it is painful and wrong to manually run the job, kettle can first calculate the correct date and then run the import job according to each date.
In the main job, run the return date conversion (each date is used as a row), the job that actually imports data is executed after the conversion, and each row is executed according to the conversion result, A job can be set to obtain parameters from a result field.
 

Generation date
This conversion is used to generate data rows with only one date field. The "set start date" Step generates 10000 rows of data streams (estimate the number of rows based on actual conditions, and set a small point during testing ), contains a constant field of the date type. The "calc days" Step inserts a sequence into the data stream, so that continuous dates can be calculated in the "calc date" step; the subsequent steps remove other auxiliary fields, then, add the date of yesterday to the data stream. Then, a comparison function is used to determine whether the date in each row is earlier than today. If you go to the "discard" step, otherwise, go to the "copy rows to result" step.

 
Master job
After the generation date conversion is executed in the main job, it is a sub-job responsible for executing each input date. This job must be explicitly set to execute each input line, select the "execute for every input row" check box. At the same time, you need to input a calculation date through the "date" parameter, so "copy previous results to parameters ?" You also need to select. Finally, the parameters must be mapped from the input line. Both the parameter names and input fields are named "date ".
 
 

Sub-job
The subjob receives and runs the "date" parameter of each row. In this example, the log is recorded and completed by using the "date" parameter.
 

Download
In this example, the main job runs a sub-job for all rows from to yesterday. It should be pointed out that the technology in this example is not suitable for all occasions, especially "loop until the condition is true" (uncertain number of times), this article may be used to implement the loop.


In oracle, you want to set a job to be executed every morning at, which is executed every hour and ended?

Declare
Job1 number (4 );
Begin
Sys. dbms_job.submit (job => job1,
What => 'Clare s1 varchar2 (200); s2 varchar2 (200); begin
If to_number (to_char (sysdate, ''hh24'') between 8 and 22) then p_test.usp_test_jobincs (s1, s2); end if; end ;',
Next_date => sysdate,
Interval => 'sysdate + 1/24 ');
Commit;
End;
/

How does one define a job in oracle and execute it at every night?

Interval = & gt; TRUNC (sysdate) + 1 + 20/24

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.