4.3.2 Create Paragraph Dependencies

Paragraph Dependencies allow you to add dependencies between paragraphs. The dependent paragraphs automatically run after the original paragraph is run, according to the order of dependency.

To create paragraph dependencies:
  1. On the Notebooks page, click Create Notebooks.
  2. In the Create Notebooks dialog, enter the name Paragraph Dependencies Demo in the Name field and click OK.
    The notebook is created and it opens in the notebook editor.
  3. On the notebook, hover your cursor over the lower border of the paragraph and click the + icon to add a paragraph. Add two more paragraphs to this notebook, and paste the following PL/SQL script in the paragraphs:
    Add paragraph
    1. In the first paragraph, copy and paste the following PL/SQL script. This script creates the view ESM_SH_DATA from the SALES table present in the SH schema.
      %script
      
      CREATE OR REPLACE VIEW ESM_SH_DATA AS 
        SELECT TIME_ID, AMOUNT_SOLD FROM SH.SALES;
    2. In the second paragraph, copy and paste the following SQL script. This script gives a count of the record present in the view ESM_SH_DATA.
      %script
      SELECT COUNT(*) FROM ESM_SH_DATA;
    3. In the third paragraph, copy and paste the following SQL script to review the data in a tabular format.
      %sql
      SELECT * FROM ESM_SH_DATA
      FETCH FIRST 10 ROWS ONLY;
  4. Go to the first paragraph and click on the Enter Dependency Mode icon.
    Enter Dependency Mode
    The message appears: You are selecting dependents for this paragraph
  5. Click on the second and third paragraph to add them as dependents of paragraph one.

    Note:

    The order of paragraph dependency is based on the order of your click.
    Select Dependent Paragraph
  6. Click Save. Once the dependent paragraphs are defined and saved, it is indicated by the numbers as shown in the screenshot here:
    Dependent paragraphs
  7. Now, go to the first paragraph and click Run. After the first paragraph starts successfully, the subsequent dependent paragraphs start to run according to the order of dependency.
    Dependent paragraph run