Create a Job

The Jobs feature automates the steps that were performed in the prerequisites section.

Here is step-by-step example of creating a job using the Jobs feature.

  1. On the Jobs feature of the Data Studio tool, select Create Job.



    On the Create Job wizard, in the general settings specify the following field values:
    • Job Name: Enter the name of the Job. For example, MY NEW JOB.
    • Job Description: Enter the description. This field is optional.

      Click Next to proceed to the Steps tab.

  2. Add Steps

    On the Steps tab, you will add the steps to automate your process.

    You will add the data load step, add the Table AI Assist Recipe you created, run a PL/SQL procedure and run a REST call as steps to your job.

    Note:

    You have already defined the tasks in the Prerequisites section.



    Add Data Load Step:
    • On the +Add Step drop-down, select Add Data Load.
    • Specify the following field values on the Add Data Load dialog:

      Select Data Load: Select the Data Load from the drop-down. In this example, it is DATA_LOAD.

      Load Name: Enter the Load name. This field will be automatically populated. This is the name by which you tag your load.

      Select Stop Job On Errors.

      Click Add Data Load.



      You will see your new step appear in the list of steps for your Job. Click the pencil icon besides the step to edit the step. Click the remove icon besides the step to remove the selected step.

    Add Table AI Assist Recipe:
    • On the +Add Step drop-down, select Add Table AI Assist Recipe.
    • Specify the following field values on the Table AI Assist Recipe dialog:

      Select Table AI Assist Recipe: Select the recipe you create from the drop-down.

      Select Stop Job On Errors.

      Click Add Table AI Assist Recipe.



      You will see this new step get added to your list of Steps, below your existing Data Load step. Click the pencil Icon besides the step to edit the step. Click the remove icon besides the step to remove the selected step.

    Add Procedure
    • On the + Add Step drop-down of the Steps tab, select Add Procedure.
    • Specify the following field values on the Add Procedure dialog:

      PL/SQL Procedure: Select any one of the PL/SQL Procedures you create from the drop-down. In this example, you select PRINT IT.

      PL/SQL Procedure Arguments: Specify a comma delimited list of arguments in this field. The values you specify in this field will be passed to the actual parameters to the procedure accepting the default values for any parameters you omit. These arguments will be passed to your PL/SQL procedure. Your arguments can be numbers, string, booleans or one of the special values starting with $. In this case, $job_name will be changed to My New Job when calling the procedure.

      For example, to replace $job_name with PLSQL_JOB in the output, you must pass PLSQL_JOB parameter in this field.

      Select Stop Job On Errors.

      Click Add Procedure.



    Add REST Call:
    • On the +Add Step drop-down, select Add REST Call.

      Note:

      You can use REST calls to perform a variety of operations. These may be against your own custom applications, your cloud provider, or other third party vendors. For instance, Oracle Cloud Infrastructure (OCI) provides a variety of endpoints, comprehensively documented at: https://docs.oracle.com/en-us/iaas/api/. It should be noted that this scope is not confined solely to OCI.

      In this example, you will call OCI's object store REST calls to access their endpoint that reads a file from the object store.

    • Specify the following field values on the Add REST dialog to must set up a Job step:

      Method: GET.

      This method retrieves data from the Oracle database. The GET method is used to fetch data, such as rows from a table or the result of a query. It does not modify any data.

      You can select any of the following methods depending on the operation you want to perform:
      • POST:

        This method inserts new data or invokes a process that changes data. It submits data to the Oracle database, typically to create new records or run procedures that modify data.

      • DELETE:

        Removes data from the Oracle database. This method deletes specified resources, such as rows in a table, identified by parameters or path variables.

      • PATCH: Partially updates existing data. This method applies partial modifications to a resource, such as updating specific columns of a row without replacing the entire record.

      Url: Specifies the object storage location of the REST service you want to access, directing your request to the correct resource on the server. In this example, enter https://objectstorage.us-ashburn-1.oraclecloud.com/n/*********/*/***/*/**/****.csv.

      Credential: Select any one of the credentials to authenticate your request, ensuring that you are authorized to access the REST API resources securely.

      Note:

      There is no credential selected in this example, since the Url is a public bucket.

      Body: This field specifies the data sent to the server, typically in POST or PUT requests. GET and DELETE requests do not have a body according to HTTP standards.

      Headers: The headers should be supplied as a JSON object where each key/value pair of the JSON object is used as a header and value in the request. For example, {"X-My-Header": "My header value"}.This field specifies additional information about the request or the client to the server. These headers can specify metadata such as content type, authorization credentials, custom parameters, and other control information necessary for processing the request. Headers are typically used in PUT, PATCH, POST, and DELETE methods to convey such details.

      Select Stop Job On Errors.

      Click Add Step.



      Note:

      You can view the output of this step in the Report menu. It displays the content of the table you retrieved from the cloud storage.



    You will see your new step in the list of Job Steps, below the procedure you previously added. Click the pencil Icon besides the step to edit the step. Click the remove icon besides the step to remove the selected step.



    Once you have added all the steps to the Job feature with the Create Job dialog, you will report the status of the jobs next.

    Click Next to progress to the Reporting tab.

  3. Send Email Reports:
    On the Reporting tab, select any of the available options to send email updates on the reporting feature via email:
    • On Completed Job: You will receive an email update when the job is completed.
    • On Failed Job: You will receive an email update when the job has failed.
    • On Error in Job: You will receive an email update when the job has an error.

    Note:

    • For the Jobs feature to send notifications, you need to configure the Simple Mail Transfer Protocol (SMTP) Settings in the Data Studio Settings.

    • Refer to the Send Email on Autonomous Database chapter for more details.

    • See Data Studio Settings for more information on configuration.

    Click Next to progress to the Schedule tab.

  4. Create a Job Schedule:
    • On the Schedule tab, you will define when to run the job and at what frequency.

      Enable for Scheduling: Select this option to set up a schedule for running the job feature; that is, to poll the data source on a regular basis:
      • In the time interval fields, enter a number, and select a time type and the days on which to poll the bucket for new or changed files. For example, to poll every two hours on Monday, Wednesday, and Friday, enter 2, select Hours. You can select All Days, Monday to Friday, Sunday to Thursday, or Custom from Week Days drop-down. The Custom field enables you to select Monday, Tuesday, Wednesday, Thursday and Friday in the appropriate fields.
      • Select a start and end date with start and end time. If you don't select a start date, the current time and date are used as the start date. The end date is optional. However, without an end date, the live feed will continue to poll.



      Click Next to progress to the API Details tab.

  5. Run Jobs Manually:

    You can run the Jobs feature after its created with the DBMS_SCHEDULER or API’s.

    On the API Details tab of the Create Job dialog, you can view the following panes on the left navigation:
    • Run Job: Run the specific job by copying the statements under REST API and submitting a GET request to the REST resource using cURL.
      curl -u admin:<password>
            'https://*******.******.*******.oraclecloud.com:****/ords/admin/_/db-api/latest/data-tools/jobs/run'
            -X POST -H 'Content-Type: application/json;charset=UTF-8' -d '{"job_name":"My New
            Job","owner":"admin"}'

      This is a sample code.

      You can also run the job on the SQL worksheet by copying and pasting the following sample code you view under the SQL section:
      begin c#***$service.dbms_data_tools.run_job('My New Job'); end;

      The above sample SQL code runs the specific job feature. You can run this code on SQL worksheet to run the Jobs feature.

    • Job Activity Detail: This option displays the REST APIs and SQL query to check the status of any ongoing job run. For example, if your job takes 10 hours, you can view if the job is in progress or not, it failed or not.

      Note:

      Every time the job is run the entire flow of every step is started from scratch.



    Click Create.

    You will receive a confirmation message saying that My New Job was created.

    The newly created job will be listed on the Jobs page.