SQL$HELP72.HLB  —  CREATE  OUTLINE  Examples
    Example 1: Creating an outline named AVAILABLE_EMPLOYEES

    SQL> CREATE OUTLINE available_employees
    cont> ID '09ADFE9073AB383CAABC4567BDEF3832'  MODE 0
    cont> AS (
    cont>     QUERY (
    cont> --
    cont> -- Cross the employees table with departments table first.
    cont> --
    cont>           employees 0 ACCESS PATH SEQUENTIAL JOIN BY MATCH TO
    cont>           departments 3 ACCESS PATH INDEX dept_index JOIN BY MATCH TO
    cont>           SUBQUERY (
    cont>               job_fitness 2 ACCESS PATH INDEX job_fit_emp, job_fit_dept
    cont>            JOIN BY CROSS TO
    cont>               SKILLS 4 ACCESS PATH ANY
    cont>                        ) JOIN BY MATCH TO
    cont>          SUBQUERY (
    cont>               major_proj 1 ACCESS PATH ANY JOIN BY CROSS TO
    cont>               education 6 ACCESS PATH ANY
    cont>                         ) JOIN BY CROSS TO
    cont>          research_projects 5 ACCESS PATH ANY UNION WITH
    cont> --
    cont> -- Always do the union with employees table last
    cont> --
    cont>          employees 7 ACCESS PATH ANY
    cont>           )
    cont>   )
    cont> COMPLIANCE OPTIONAL
    cont> COMMENT IS 'Available employees';

    Example 2: Creating an outline using the FROM clause

    SQL> CREATE OUTLINE degrees_for_emps_over_65
    cont> FROM
    cont>    (SELECT e.last_name, e.first_name, e.employee_id,
    cont>              d.degree, d.year_given
    cont>          FROM employees e, degrees d
    cont>          WHERE e.birthday < '31-Dec-1930'
    cont>          AND e.employee_id = d.employee_id
    cont>          ORDER BY e.last_name)
    cont> USING
    cont>    (QUERY
    cont>       (SUBQUERY
    cont>          (degrees 1 ACCESS PATH SEQUENTIAL
    cont>           JOIN BY CROSS TO
    cont>           employees 0 ACCESS PATH ANY
    cont>          )
    cont>       )
    cont>    )
    cont> COMPLIANCE OPTIONAL
    cont> COMMENT IS 'Outline to find employees over age 65 with college degrees';
    SQL> --
    SQL> SHOW OUTLINE degrees_for_emps_over_65
         DEGREES_FOR_EMPS_OVER_65
     Comment:       Outline to find employees over age 65 with college degrees
     Source:

    -- Rdb Generated Outline : 13-NOV-1995 15:28
    create outline DEGREES_FOR_EMPS_OVER_65
    id 'B6923A6572B28E734D6F9E8E01598CD8'
    mode 0
    as (
      query (
        subquery (
          DEGREES 1       access path sequential
            join by cross to
          EMPLOYEES 0     access path index       EMPLOYEES_HASH
          )
        )
      )
    compliance optional     ;

    Example 3: Creating an outline using the ON FUNCTION clause

    SQL> CREATE OUTLINE out1
    cont> ON FUNCTION NAME function1;
    SQL> COMMIT;
    SQL> SHOW OUTLINE out1
         OUT1
     Source:

    -- Rdb Generated Outline :  2-FEB-1996 15:46
    create outline OUT1
    id '264A6DDADCB483AE5B2CDF629C9C8C0F'
    mode 0
    as (
      query (
        subquery (
          EMPLOYEES 0     access path index       EMPLOYEES_HASH
          )
        )
      )
    compliance optional     ;

    Example 4: Creating an outline on a procedure that accesses a
    declared local temporary table (see the CREATE MODULE statement
    for the stored procedure and temporary table definition)

    SQL> CREATE OUTLINE outline1
    cont> ON PROCEDURE NAME paycheck_ins_decl
    cont> MODE 0
    cont> AS (
    cont>     QUERY (
    cont>            module.paycheck_decl_tab MODULE paycheck_decl_mod
    cont>            0
    cont>            ACCESS PATH SEQUENTIAL
    cont>           )
    cont>    )
    cont> COMPLIANCE OPTIONAL;
    SQL> SHOW OUTLINE outline1
         OUTLINE1
     Source:

    create outline OUTLINE1
    mode 0
    as (
      query (
        PAYCHECK_DECL_TAB       MODULE PAYCHECK_DECL_MOD 0
        access path sequential
        )
      )
    compliance optional     ;

    Example 5: New Output from Query Outlines

    SQL> BEGIN
    cont> DECLARE :x INTEGER;
    cont> -- Assignment
    cont> SET :x = (SELECT COUNT(*) FROM TOUT_1);
    cont> -- Delete statement
    cont> DELETE FROM TOUT_1;
    cont> -- Update statement
    cont> UPDATE TOUT_1
    cont>     SET a = (SELECT AVG(a) FROM TOUT_2)
    cont>     WHERE a IS NULL;
    cont> -- Singleton Select
    cont> SELECT a INTO :x
    cont>     FROM TOUT_1
    cont>     WHERE a = 1;
    cont> -- Trace (nothing if TRACE is disabled)
    cont> TRACE 'The first value: ', (SELECT a FROM TOUT_1 LIMIT TO 1 ROW);
    cont> END;

    The query outline generated by Oracle Rdb appears with comments
    after the QUERY keyword in the outline.

    -- Rdb Generated Outline : 29-MAY-1997 23:17
    create outline QO_C11395E6020C6FFA_00000000
    id 'C11395E6020C6FFA5A183A6CCE7C1F33'
    mode 0
    as (
      query (
    -- Set
        subquery (
          TOUT_1 0        access path sequential
          )
        )
      query (
    -- Delete
        subquery (
          TOUT_1 0        access path sequential
          )
        )
      query (
    -- Update
        subquery (
          subquery (
            TOUT_2 1        access path sequential
            )
            join by cross to
          subquery (
            TOUT_1 0        access path sequential
            )
          )
        )
      query (
    -- Select
        subquery (
          TOUT_1 0        access path sequential
          )
        )
      query (
    -- Trace
        subquery (
          TOUT_1 0        access path sequential
          )
        )
      )
    compliance optional     ;
Close Help