DBA Data[Home] [Help]

APPS.AD_PARALLEL_UPDATES_PKG SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 13

   update_info       update_info_type,
   batch_size        NUMBER        := 0,
   debug_level       NUMBER        := 0,
   processed_mode    NUMBER        := NULL,
   lock_name         VARCHAR2(128),
   lock_handle       VARCHAR2(128) := NULL,
   worker_id         NUMBER        := NULL
   );
Line: 68

PROCEDURE init_g_cache_update_info
           (p_owner        IN VARCHAR2,
            p_table_name   IN VARCHAR2,
            p_script_name  IN VARCHAR2)
IS
  BEGIN
     g_cache.ui_initialized := FALSE;
Line: 75

     SELECT *
       INTO g_cache.update_info
       FROM ad_parallel_updates
       WHERE owner = p_owner
       AND table_name = p_table_name
       AND script_name = p_script_name;
Line: 82

  END init_g_cache_update_info;
Line: 84

PROCEDURE get_update_info
           (x_update_info OUT nocopy update_info_type)
IS
  BEGIN
     IF (g_cache.ui_initialized) THEN
   x_update_info := g_cache.update_info;
Line: 94

  END get_update_info;
Line: 168

procedure create_update_record
           (X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2,
            X_id_column    in varchar2 default null,
            X_num_workers  in number default null)
is
    l_initialized varchar2(1);
Line: 179

     IF (X_update_type in (ID_RANGE_BY_ROWID, ID_RANGE,
                           ID_RANGE_SUB_RANGE,
                           ID_RANGE_SUB_RANGE_SQL,
                           ID_RANGE_SCAN_EQUI_ROWSETS))
     THEN
        if (X_id_column is null) then
           raise_application_error(-20001,
               'Cannot get name for the unique id column');
Line: 191

               'Cannot get number of workers for ID range updates');
Line: 193

     ELSIF (x_update_type = ROWID_RANGE) THEN
        NULL;
Line: 197

               'Unknown update type : ' || x_update_type);
Line: 201

        select null
        into   l_initialized
        from   ad_parallel_updates
        where  owner = X_owner
        and    table_name = X_table
        and    script_name = X_script;
Line: 210

          insert into ad_parallel_updates (
                        update_id,
                        update_type,
                        owner, script_name, table_name,
                        object_id,
                        id_column, num_workers, creation_date,
                        db_block_size, avg_row_len,
                        initialized_flag)
          select ad_parallel_updates_s.nextval,
                 X_update_type,
                 X_owner, X_script, X_table,
                 nvl(o.dataobj#, o.obj#),
                 X_id_column, X_num_workers, sysdate,
                 8192, t.avgrln, 'N' -- only 8k block sizes for 11i and above
          from   sys.obj$ o,
                 sys.tab$ t,
                 sys.user$ u
          where  u.name = X_owner
          and    o.owner# = u.user#
          and    o.name   = X_table
          and    o.type# = 2 -- TABLE
          and    t.obj#   = o.obj#;
Line: 238

     init_g_cache_update_info(x_owner, x_table, x_script);
Line: 240

  END create_update_record;
Line: 254

      SELECT segment_name,
             partition_name,
             segment_type,
             data_object_id,
             relative_fno, block_id, blocks
      from   sys.ad_extents
      where  owner = X_owner
      and    segment_name = X_table
      and    segment_type in ('TABLE', 'TABLE PARTITION',
                                'TABLE SUBPARTITION')
      order by segment_name, partition_name, relative_fno, block_id;
Line: 284

    l_update_info    update_info_type;
Line: 299

       l_statement := 'select version from v$instance';
Line: 334

       select sid, serial#
       into l_my_sid, l_my_serialid
       from v$session where audsid = userenv('sessionid');
Line: 347

     create_update_record(ROWID_RANGE,
                          X_owner,
                          X_table,
                          X_script);
Line: 352

     get_update_info(l_update_info);
Line: 354

     if (nvl(l_update_info.avg_row_len, 0) = 0) then
        l_minblocks := DEFAULT_MIN_BLOCKS;
Line: 357

        l_minblocks := round((X_batch_size*l_update_info.avg_row_len)/
                                 l_update_info.db_block_size, -1);
Line: 365

     select nvl(max(unit_id), 0)
     into   l_unit_id
     from   ad_parallel_update_units
     where  update_id = l_update_info.update_id;
Line: 403

                 INSERT INTO ad_parallel_update_units(
                   unit_id, update_id,
                   data_object_id,
                   relative_fno, start_block, end_block,
                   status
                 )
                 values( unit_id_tab(k), l_update_info.update_id,
                         object_id_tab(k),
                         relative_fno_tab(k),
                         start_block_tab(k),
                         end_block_tab(k),
                         UNASSIGNED_STATUS);
Line: 448

        l_stmt := 'select min('||X_id_column||') min_val '||
                  'from '||X_owner||'.'||X_table;
Line: 453

        l_stmt := 'select max('||X_id_column||') max_val '||
                  'from '||X_owner||'.'||X_table;
Line: 473

            X_update_type in number,
            X_update_id   in number,
            X_num_workers in number,
            X_batch_size  in number,
            X_SQL_Stmt    in varchar2)
is
  l_status varchar2(1);
Line: 492

    ' INSERT INTO ad_parallel_update_units '||
    ' (update_id, unit_id, start_id, end_id, status) '||
    ' SELECT :update_id update_id, '||
    '        unit_id+1 unit_id, '||
    '        min(id_value) start_id_value, '||
    '        max(id_value) end_id_value, '||
    '        :status status '||
    ' from ('||
    '   select id_value, '||
    '          floor(rank() over (order by id_value)/:batchsize) unit_id '||
    '   from ( '||
             X_SQL_Stmt||
    '   ) '||
    ' ) '||
    ' group by unit_id '
  using X_Update_id, l_status, X_batch_size;
Line: 513

    'INSERT INTO ad_parallel_update_units '||
    ' (update_id, unit_id, start_id, end_id, status) '||
    ' select :update_id, unit_id, start_id_value, end_id_value, :status '||
    ' from ( '||
             X_SQL_Stmt||
    ' ) ');
Line: 522

           (X_update_type in number,
            X_owner       in varchar2,
            X_table       in varchar2,
            X_script      in varchar2,
            X_id_column   in varchar2,
            X_num_workers in number,
            X_batch_size  in number,
            X_SQL_Stmt    in varchar2,
            X_Begin_ID    in number,
            X_End_ID      in number)
is
    l_table_start_id  number;
Line: 548

    l_update_info     update_info_type;
Line: 554

      l_entire_range := (X_update_type = ID_RANGE_BY_ROWID);
Line: 556

      create_update_record(X_update_type,
                           X_owner, X_table, X_script,
                           X_id_column, X_num_workers);
Line: 560

      get_update_info(l_update_info);
Line: 562

      if (X_update_type = ID_RANGE_SCAN_EQUI_ROWSETS)
      then
         populate_id_ranges(
            X_update_type,
            l_update_info.update_id,
            X_num_workers, X_batch_size,
            X_SQL_Stmt);
Line: 570

         if (X_update_type = ID_RANGE_SUB_RANGE)
         then
            l_table_start_id := X_Begin_ID;
Line: 592

                insert into ad_parallel_update_units(
                    unit_id, update_id,
                    start_id, end_id,
                    status
                 )
                values (unit_id_tab(i), l_update_info.update_id,
                         start_id_tab(i), end_id_tab(i),
                         UNASSIGNED_STATUS);
Line: 626

                      insert into ad_parallel_update_units(
                        unit_id, update_id,
                        start_id, end_id,
                        status
                       )
                      values (unit_id_tab(i), l_update_info.update_id,
                              start_id_tab(i), end_id_tab(i),
                              UNASSIGNED_STATUS);
Line: 645

      end if; /* if not X_Update_type = ID_RANGE_SCAN_EQUI_ROWSETS */
Line: 652

           (X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2,
            X_ID_column    in varchar2,
            X_worker_id    in number,
            X_num_workers  in number,
            X_batch_size   in number,
            X_debug_level  in number,
            X_processed_mode in number,
            X_SQL_Stmt     in varchar2,
            X_Begin_ID     in number,
            X_End_ID       in number)
is
    l_initialized  varchar2(1);
Line: 668

    l_update_id    number;
Line: 675

                                   DELETE_PROCESSED_UNITS))
      then
         raise_application_error(-20001,
           'Incorrect mode specified for processed units. '||
           'Must be either PRESERVE_PROCESSED_UNITS or '||
           'DELETE_PROCESSED_UNITS. ');
Line: 689

      if (X_update_type = ID_RANGE_SCAN_EQUI_ROWSETS
          and
          X_SQL_Stmt is null)
      then
        raise_application_error(-20001,
          'You must specify a SQL statement to derive processing units.');
Line: 697

      if (X_update_type = ID_RANGE_SUB_RANGE
          and
          X_SQL_Stmt is not null)
      then
        raise_application_error(-20001,
          'You cannot specify a SQL statement for specific ID range.');
Line: 705

      if (X_update_type = ID_RANGE_SUB_RANGE_SQL
          and
          X_SQL_Stmt is null)
      then
          raise_application_error(-20001,
          'You must specify a SQL statement for this ID range method.');
Line: 721

        select update_id, initialized_flag, num_workers
        into   l_update_id, l_initialized, l_num_workers
        from   ad_parallel_updates
        where  owner = X_owner
          and  table_name = X_table
          and  script_name = X_script;
Line: 738

          l_update_id := null;
Line: 746

          if (l_update_id is not null) then
             delete from ad_parallel_update_units
             where update_id = l_update_id;
Line: 753

          if (X_update_type = ROWID_RANGE) then
             populate_extent_info(X_owner, X_table, X_script, X_batch_size);
Line: 756

             populate_id_info(X_update_type,
                              X_owner, X_table, X_script, X_ID_column,
                              X_num_workers, X_batch_size,
                              X_SQL_Stmt, X_Begin_ID, X_End_ID);
Line: 765

          update ad_parallel_updates
          set    initialized_flag = 'Y',
                 num_workers = X_num_workers
          where  owner = X_owner
            and  table_name = X_table
            and  script_name = X_script;
Line: 785

             select 1
             into   l_unproc_units_exist
             from   sys.dual
             where  exists (
                 select 1
                 from   ad_parallel_update_units
                 where  update_id = l_update_id
                 and status in (UNASSIGNED_STATUS, ASSIGNED_STATUS));
Line: 800

             if (X_update_type not in (ROWID_RANGE, ID_RANGE)) then
                --
                -- for ID over ROWID range methods, you cannot reduce the
                -- number of workers after initialization
                --
                if (X_num_workers <  l_num_workers) then

                   raise_application_error(-20001,
              'Cannot reduce the number of workers after initialization.');
Line: 816

               update ad_parallel_update_units
               set    status = UNASSIGNED_STATUS,
                      worker_id = null
               where  update_id = l_update_id
               and    status = ASSIGNED_STATUS
               and    worker_id > X_num_workers;
Line: 823

               update ad_parallel_workers
               set    start_unit_id = 0,
                      end_unit_id = 0,
                      start_rowid = null,
                      start_id    = null,
                      end_rowid   = null,
                      end_id      = null
               where update_id = l_update_id
               and    worker_id > X_num_workers;
Line: 833

               update ad_parallel_updates
               set    num_workers = X_num_workers
               where  update_id = l_update_id;
Line: 839

           end if; -- incomplete update
Line: 851

             g_cache.update_info.owner||'.'||
             g_cache.update_info.table_name||'.'||
             g_cache.update_info.script_name)) THEN
         init_g_cache_update_info(x_owner, x_table, x_script);
Line: 881

           (X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2,
            X_worker_id    in number,
            X_num_workers  in number,
            X_batch_size   in number,
            X_debug_level  in number)
is
begin
  initialize_rowid_range
             (X_update_type => X_update_type,
              X_owner       => X_owner,
              X_table       => X_table,
              X_script      => X_script,
              X_worker_id   => X_worker_id,
              X_num_workers => X_num_workers,
              X_batch_size  => X_batch_size,
              X_debug_level => X_debug_level,
              X_processed_mode => PRESERVE_PROCESSED_UNITS);
Line: 905

           (X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2,
            X_worker_id    in number,
            X_num_workers  in number,
            X_batch_size   in number,
            X_debug_level  in number,
            X_processed_mode in number)
is
  begin
     debug_info('initialize_rowid_range()+');
Line: 917

     initialize(X_update_type,
                X_owner, X_table, X_script, null,
                X_worker_id, X_num_workers,
                X_batch_size, X_debug_level,
                X_processed_mode,
                null, null, null);
Line: 927

           (X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2,
            X_ID_column    in varchar2,
            X_worker_id    in number,
            X_num_workers  in number,
            X_batch_size   in number,
            X_debug_level  in number,
            X_SQL_Stmt     in varchar2 default NULL,
            X_Begin_ID     in number   default NULL,
            X_End_ID       in number   default NULL)
is
  begin
     initialize(X_update_type,
                X_owner, X_table, X_script, X_ID_column,
                X_worker_id, X_num_workers,
                X_batch_size, X_debug_level,
                ad_parallel_updates_pkg.PRESERVE_PROCESSED_UNITS,
                X_SQL_Stmt, X_Begin_ID, X_End_ID);
Line: 952

            X_update_id        in         number,
            X_res_start_rowid  out nocopy rowid,
            X_res_end_rowid    out nocopy rowid,
            X_res_start_id     out nocopy number,
            X_res_end_id       out nocopy number,
            X_start_unit_id    out nocopy number,
            X_end_unit_id      out nocopy number)
  is
  begin

     select start_rowid, end_rowid,
            start_id, end_id,
            start_unit_id, end_unit_id
     into   X_res_start_rowid, X_res_end_rowid,
            X_res_start_id, X_res_end_id,
            X_start_unit_id, X_end_unit_id
     from   ad_parallel_workers
     where  worker_id = X_worker_id
     and    update_id = X_update_id;
Line: 998

    l_update_info       update_info_type;
Line: 1001

     get_update_info(l_update_info);
Line: 1007

     select start_unit_id, end_unit_id
     into   l_start_unit_id, l_end_unit_id
     from   ad_parallel_workers
     where  worker_id = l_worker_id
     and    update_id = l_update_info.update_id;
Line: 1017

     update ad_parallel_workers
     set    start_rowid = nvl(X_last_rowid, start_rowid),
	    start_id    = least(nvl(X_last_id, start_id)+1, end_id+1),
            rows_processed = nvl(rows_processed, 0) + nvl(X_rows_processed, 0)
     where  worker_id = l_worker_id
     and    update_id = l_update_info.update_id;
Line: 1024

     if (g_cache.processed_mode = DELETE_PROCESSED_UNITS) then
        delete from ad_parallel_update_units
        where  update_id = l_update_info.update_id
        and    unit_id  between l_start_unit_id and l_end_unit_id;
Line: 1029

        update ad_parallel_update_units
        set    status = decode(l_update_info.update_type,
                               ROWID_RANGE, PROCESSED_STATUS,
                               decode(X_last_id,
                                      end_id, PROCESSED_STATUS,
                                      status)),
               end_date = sysdate,
               rows_processed = nvl(rows_processed, 0) +
                                nvl(X_rows_processed, 0)
        where  update_id = l_update_info.update_id
        and    unit_id  between l_start_unit_id and l_end_unit_id;
Line: 1086

    l_update_info  update_info_type;
Line: 1091

    get_update_info(l_update_info);
Line: 1093

    update ad_parallel_workers
    set    start_unit_id = X_start_unit_id,
           end_unit_id   = X_end_unit_id,
           start_rowid   = X_start_rowid,
           end_rowid     = X_end_rowid,
           start_id      = X_start_id,
           end_id        = X_end_id
    where  worker_id   = X_worker_id
    and    update_id   = l_update_info.update_id;
Line: 1107

       insert into ad_parallel_workers (
                      worker_id, update_id,
                      start_unit_id, end_unit_id,
                      start_rowid, end_rowid,
                      start_id, end_id
                   )
       values (X_worker_id, l_update_info.update_id,
               X_start_unit_id, X_end_unit_id,
               X_start_rowid, X_end_rowid,
               X_start_id, X_end_id
              );
Line: 1124

    update ad_parallel_update_units
    set    status = ASSIGNED_STATUS,
           worker_id = X_worker_id,
           start_date = nvl(start_date, sysdate)
    where  update_id = l_update_info.update_id
    and    unit_id between X_start_unit_id and X_end_unit_id;
Line: 1219

    l_unit_rec             ad_parallel_update_units%rowtype;
Line: 1222

    l_update_info          update_info_type;
Line: 1224

    cursor c_range(p_update_id number) is
      select /*+ FIRST_ROWS +*/ *
      from   ad_parallel_update_units
      where  update_id = p_update_id
      and status = UNASSIGNED_STATUS
      for update of status
      skip locked;
Line: 1235

    get_update_info(l_update_info);
Line: 1238

    get_restart_range(l_worker_id, l_update_info.update_id,
                      l_res_start_rowid, l_res_end_rowid,
                      l_res_start_id, l_res_end_id,
                      l_start_unit_id, l_end_unit_id);
Line: 1268

    open c_range(l_update_info.update_id);
Line: 1278

                                     l_update_info.object_id),
                                 l_unit_rec.relative_fno,
                                 l_unit_rec.start_block,
                                 0);
Line: 1284

                                     l_update_info.object_id),
                                 l_unit_rec.relative_fno,
                                 l_unit_rec.end_block,
                                 G_MAX_ROWS_IN_BLOCK);
Line: 1326

    l_unit_rec           ad_parallel_update_units%rowtype;
Line: 1332

    l_update_info        update_info_type;
Line: 1334

    cursor c_range(p_update_id in number) is
      select /*+ FIRST_ROWS +*/ *
      from   ad_parallel_update_units
      where  update_id = p_update_id
      and status = UNASSIGNED_STATUS
      for update of status
      skip locked;
Line: 1345

    get_update_info(l_update_info);
Line: 1350

    get_restart_range(l_worker_id, l_update_info.update_id,
                      l_res_start_rowid, l_res_end_rowid,
                      l_res_start_id, l_res_end_id,
                      l_start_unit_id, l_end_unit_id);
Line: 1368

        if (l_update_info.update_type = ID_RANGE_SCAN_EQUI_ROWSETS) then
           X_end_id := l_res_end_id;
Line: 1391

          select status
          into   l_status
          from   ad_parallel_update_units
          where  update_id = l_update_info.update_id
          and    unit_id = l_start_unit_id;
Line: 1404

             if (l_update_info.update_type = ID_RANGE_SCAN_EQUI_ROWSETS) then
               X_end_id := l_res_end_id;
Line: 1431

    open c_range(l_update_info.update_id);
Line: 1455

        if (l_update_info.update_type = ID_RANGE_SCAN_EQUI_ROWSETS) then
          X_end_id := l_end_id;
Line: 1473

          update AD_PARALLEL_UPDATE_UNITS
          set STATUS = PROCESSED_STATUS
          where update_id = l_update_info.update_id
          and    unit_id = l_unit_rec.unit_id;
Line: 1495

       select update_id
       from   ad_parallel_updates p
       where  initialized_flag = 'Y'
       and    owner = nvl(upper(X_owner), owner)
       and    table_name = nvl(upper(X_table), table_name)
       and    script_name = nvl(X_script, script_name)
       and not exists (
           select update_id
           from   ad_parallel_update_units u
           where  u.update_id = p.update_id
           and    u.status in ('A', 'U'));
Line: 1511

      delete from ad_parallel_update_units
      where update_id = c_rec.update_id;
Line: 1517

      delete from ad_parallel_workers
      where update_id = c_rec.update_id;
Line: 1534

procedure delete_update_information(
            X_update_type  in number,
            X_owner        in varchar2,
            X_table        in varchar2,
            X_script       in varchar2)
is
  l_update_id  number;
Line: 1545

    select update_id
    into   l_update_id
    from   ad_parallel_updates
    where  owner = upper(X_owner)
    and    table_name = upper(X_table)
    and    script_name = X_script;
Line: 1565

  delete from ad_parallel_workers
  where  update_id = l_update_id;
Line: 1568

  delete from ad_parallel_update_units
  where  update_id = l_update_id;
Line: 1571

  delete from ad_parallel_updates
  where  update_id = l_update_id;
Line: 1600

    select update_id, table_name, owner
    from   ad_parallel_updates pu
    where  owner = nvl(upper(X_owner), owner)
    and    table_name = nvl(upper(X_table), table_name)
    and    script_name = nvl(X_script, script_name)
    and    update_type = ROWID_RANGE
    and    initialized_flag = 'Y'
    and exists (
        select 'Unprocessed units exist'
        from   ad_parallel_update_units pun
        where  pun.update_id = pu.update_id
        and    pun.status in (UNASSIGNED_STATUS, ASSIGNED_STATUS));
Line: 1624

     update ad_parallel_updates
     set initialized_flag = 'N'
     where update_id = crec.update_id;
Line: 1631

     delete from ad_parallel_update_units
     where update_id = crec.update_id;
Line: 1634

     delete from ad_parallel_workers
     where update_id = crec.update_id;