DBA Data[Home] [Help]

APPS.AD_FILE_SYS_SNAPSHOTS_PKG SQL Statements

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

Line: 55

            p_update_global_view  boolean,
            p_snapshot_id         number,
            p_global_snapshot_id  number,
            p_delete_junk_created boolean)
 is
  L_BUGSTAT_EXPL_ACT_CD constant number := 15;  -- bug fix row: EXPLICIT status
Line: 63

  l_snapshot_bugs_inserted number := 0;
Line: 77

    put_line('Inserting candidate bugs into temp table');
Line: 84

  insert into ad_patch_hist_snaps_temp (action_code, bug_id)
  select distinct L_BUGSTAT_EXPL_ACT_CD, prb.bug_id
  from ad_patch_run_bugs prb, ad_patch_hist_snaps_temp t
  where prb.patch_run_id = t.patch_run_id
  and t.action_code = p_action_code
  and (prb.applied_flag = 'Y' or prb.reason_not_applied = L_ADPBNAAS);
Line: 92

    put_line('Inserted '||to_char(sql%rowcount)||
             ' candidate bugs into temp table');
Line: 107

    put_line('Inserting new bugfixes in the curr-vw snapshot');
Line: 111

  insert into ad_snapshot_bugfixes
  (
    snapshot_bug_id,
    snapshot_id,
    bugfix_id,
    bug_status,
    success_flag,
    creation_date, last_update_date, last_updated_by, created_by
  )
  select
    ad_snapshot_bugfixes_s.nextval,
    p_snapshot_id,
    t.bug_id,
    'EXPLICIT',
    'Y',
    sysdate, sysdate, 5, 5
  from ad_patch_hist_snaps_temp t
  where t.action_code = L_BUGSTAT_EXPL_ACT_CD
  and not exists (select 'Bug not yet recorded in the curr-vw'
                  from ad_snapshot_bugfixes sb2
                  where sb2.snapshot_id = p_snapshot_id
                  and sb2.bugfix_id = t.bug_id);
Line: 134

  l_snapshot_bugs_inserted := sql%rowcount;
Line: 137

    put_line('Inserted '||to_char(l_snapshot_bugs_inserted)||
             ' new bugfixes in the CV');
Line: 149

  update ad_snapshot_bugfixes sb
  set sb.bug_status = 'EXPLICIT',
      sb.success_flag = 'Y',
      sb.last_update_date = sysdate,
      sb.last_updated_by = 5
  where sb.snapshot_id = p_snapshot_id
  and sb.bugfix_id in (select t.bug_id
                       from ad_patch_hist_snaps_temp t
                       where t.action_code = L_BUGSTAT_EXPL_ACT_CD)
  and (sb.bug_status <> 'EXPLICIT' or
       sb.success_flag <> 'Y');
Line: 162

    put_line('Updated '||to_char(sql%rowcount)|| ' bugfix rows in the CV');
Line: 170

  if p_update_global_view then

    if G_DEBUG then
      put_line('Inserting new bugfixes in the GV');
Line: 177

    insert into ad_snapshot_bugfixes
    (
      snapshot_bug_id,
      snapshot_id, bugfix_id,
      bug_status, success_flag,
      creation_date, last_update_date, last_updated_by, created_by
    )
    select
      ad_snapshot_bugfixes_s.nextval,
      p_global_snapshot_id, t.bug_id,
      'EXPLICIT', 'Y',
      sysdate, sysdate, 5, 5
    from ad_patch_hist_snaps_temp t
    where t.action_code = L_BUGSTAT_EXPL_ACT_CD
    and not exists (select 'Bug not yet recorded in the curr-vw'
                    from ad_snapshot_bugfixes sb2
                    where sb2.snapshot_id = p_global_snapshot_id
                    and sb2.bugfix_id = t.bug_id);
Line: 196

    l_snapshot_bugs_inserted := l_snapshot_bugs_inserted + sql%rowcount;
Line: 199

      put_line('Inserted '||to_char(sql%rowcount)|| ' new bugfixes in the GV');
Line: 210

    update ad_snapshot_bugfixes sb
    set sb.bug_status = 'EXPLICIT',
        sb.success_flag = 'Y',
        sb.last_update_date = sysdate,
        sb.last_updated_by = 5,
        sb.inconsistent_flag = null
    where sb.snapshot_id = p_global_snapshot_id
    and sb.bugfix_id in (select t.bug_id
                         from ad_patch_hist_snaps_temp t
                         where t.action_code = L_BUGSTAT_EXPL_ACT_CD)
    and (sb.bug_status <> 'EXPLICIT' or
         sb.success_flag <> 'Y');
Line: 224

      put_line('Updated '||to_char(sql%rowcount)|| ' bugfix rows in the GV');
Line: 229

  end if;  -- End If p_update_global_view
Line: 235

                                              l_snapshot_bugs_inserted,
                                              TRUE,
                                              TRUE,
                                              l_gathered_stats_flag);
Line: 241

  if p_delete_junk_created then

    delete from ad_patch_hist_snaps_temp
    where action_code = L_BUGSTAT_EXPL_ACT_CD;
Line: 249

    update ad_snapshots set snapshot_update_date = sysdate
    where  snapshot_id in (p_snapshot_id, p_global_snapshot_id);
Line: 269

  select s.appl_top_id, aat.applications_system_name, aat.name
  into l_appl_top_id, l_apps_sys_nm, l_at_name
  from ad_snapshots s, ad_appl_tops aat
  where s.appl_top_id = aat.appl_top_id
  and s.snapshot_id = p_snapshot_id;
Line: 276

    select 'x'
    into l_dummy
    from ad_timestamps
    where type = 'BACKFILLED_BUGS_IN_CURRENT_VIEW_SNAPSHOT'
    and attribute = l_apps_sys_nm||'*'||l_at_name;
Line: 291

      put_line('About to insert PR-IDs into temp table - 2');
Line: 294

    insert into ad_patch_hist_snaps_temp
    (
      patch_run_id, action_code
    )
    select
      patch_run_id, G_PR_ID_ACT_CD2
    from ad_patch_runs
    where appl_top_id = l_appl_top_id
    and patch_run_id not in (select patch_run_id
                             from ad_patch_hist_snaps_temp
                             where action_code in (G_PR_ID_ACT_CD,
                                                   G_PR_ID_ACT_CD2));
Line: 308

      put_line('Inserted '||to_char(sql%rowcount)||' PR-ID rows - 2');
Line: 329

                  p_update_global_view => FALSE,
                  p_global_snapshot_id => -1,
                  p_delete_junk_created => TRUE);
Line: 335

      delete from ad_patch_hist_snaps_temp
      where action_code = G_PR_ID_ACT_CD2;
Line: 342

    ad_file_util.update_timestamp('BACKFILLED_BUGS_IN_CURRENT_VIEW_SNAPSHOT',
                                  l_apps_sys_nm||'*'||l_at_name);
Line: 362

  select nvl(count(*), 0)
  into p_count_appltops
  from ad_appl_tops
  where applications_system_name = p_apps_system_name
  and active_flag = 'Y';
Line: 370

  insert into ad_appl_tops
  (
    appl_top_id, name, applications_system_name, appl_top_type,
    description,
    server_type_admin_flag, server_type_forms_flag,
    server_type_node_flag, server_type_web_flag,
    creation_date, created_by, last_update_date, last_updated_by,
    active_flag
  )
  select
    ad_appl_tops_s.nextval, 'GLOBAL', p_apps_system_name, 'G',
    'Created for Global View Snapshot',
    null, null,
    null, null,
    sysdate, 5, sysdate, 5,
    'N'
  from dual
  where not exists (select 'Already exists'
                    from ad_appl_tops t
                    where t.name = 'GLOBAL'
                    and t.appl_top_type = 'G'
                    and t.applications_system_name = p_apps_system_name);
Line: 395

  select appl_top_id
  into p_global_appl_top_id
  from ad_appl_tops
  where appl_top_type = 'G'
  and name = 'GLOBAL'
  and applications_system_name = p_apps_system_name;
Line: 403

  select release_id into l_release_id from ad_releases
  where  to_char(major_version) || '.' ||
         to_char(minor_version) || '.' ||
         to_char(tape_version) = (select release_name
                                  from   fnd_product_groups
                                  where  applications_system_name =
                                         p_apps_system_name);
Line: 410

  insert into ad_snapshots
  (
    snapshot_id, release_id,
    appl_top_id, snapshot_name,
    snapshot_creation_date, snapshot_update_date,
    snapshot_type, comments,
    ran_snapshot_flag,
    creation_date, last_updated_by, created_by, last_update_date
  )
  select
    ad_snapshots_s.nextval, l_release_id,
    p_global_appl_top_id, 'GLOBAL_VIEW',
    sysdate, sysdate,
    'G', 'Created from Current View Snapshots',
    'N',
    sysdate, 5, 5, sysdate
  from dual
  where not exists (select 'Already exists'
                    from ad_snapshots
                    where appl_top_id = p_global_appl_top_id
                    and snapshot_type = 'G'
                    and snapshot_name = 'GLOBAL_VIEW');
Line: 435

  select snapshot_id
  into p_global_snapshot_id
  from ad_snapshots
  where snapshot_type = 'G'
  and snapshot_name = 'GLOBAL_VIEW'
  and appl_top_id   = p_global_appl_top_id;
Line: 475

  select snapshot_id
  bulk collect into l_cv_ids
  from ad_snapshots s, ad_appl_tops at1
  where s.appl_top_id = at1.appl_top_id
  and at1.applications_system_name = p_apps_system_name
  and at1.appl_top_type = 'R'
  and at1.active_flag = 'Y'
  and s.snapshot_type = 'C'
  and s.snapshot_name = 'CURRENT_VIEW';
Line: 521

    'insert into ad_snapshot_files_temp '||
    '( '||
      'snapshot_file_id, file_id, update_source_id, update_type, '||
      'inconsistent_flag, containing_file_id, file_version_id, '||
      'dest_file_id, file_type_flag '||
    ') '||
    'select '||
    'snapshot_file_id, file_id, -1, ''P'', ''Y'', containing_file_id, '||
    'file_version_id, '||
    'dest_file_id, file_type_flag '||
    'from (select '||
     'sf.snapshot_file_id snapshot_file_id, sf.file_id file_id, '||
          'sf.containing_file_id containing_file_id, '||
          'sf.file_version_id file_version_id, '||
          'sf.dest_file_id dest_file_id, sf.file_type_flag file_type_flag, '||
          'row_number() over '||
            '(partition by afv.file_id, sf.containing_file_id '||
             'order by afv.version_segment1 desc, afv.version_segment2 desc, '||
                      'afv.version_segment3 desc, afv.version_segment4 desc, '||
                      'afv.version_segment5 desc, afv.version_segment6 desc, '||
                      'afv.version_segment7 desc, afv.version_segment8 desc, '||
                      'afv.version_segment9 desc, afv.version_segment10 desc, '||
                      'afv.translation_level desc nulls last) as r '||
        'from ad_snapshot_files sf, ad_file_versions afv ';
Line: 619

  select release_id into l_release_id
	from ad_releases
 	where major_version||'.'||minor_version||'.'||tape_version = p_release_name;
Line: 624

    select snapshot_id into l_global_snapshot_id
    from ad_snapshots
    where snapshot_name ='GLOBAL_VIEW'
    and snapshot_type= 'G'
    and appl_top_id = (
      select appl_top_id
      from ad_appl_tops
      where appl_top_type = 'G'
      and name = 'GLOBAL'
      and applications_system_name = p_apps_system_name
    );
Line: 643

        select 'x' into l_dummy
        from ad_snapshots ads
        where ads.release_id = l_release_id
        and ads.snapshot_id = l_global_snapshot_id;
Line: 652

        update ad_snapshots
        set snapshot_type = 'O',
        snapshot_name = snapshot_name||'-'||snapshot_id,
        last_update_date = sysdate
        where snapshot_id = l_global_snapshot_id;
Line: 679

      select ss.snapshot_id
      into l_preseeded_snapshot_id
      from ad_snapshots ss,             -- seeded
           ad_appl_tops ats             -- seeded
      where ss.appl_top_id = ats.appl_top_id
      and ss.snapshot_type = 'B'
      and ss.snapshot_name like '*PRESEEDED*'||p_release_name||'%'
      and ats.name = '*PRESEEDED*'
      and ats.applications_system_name = '*PRESEEDED*'
      and ats.appl_top_type = 'S';
Line: 696

      insert into ad_snapshot_bugfixes
      (
        snapshot_bug_id, snapshot_id, bugfix_id, bug_status, success_flag,
        creation_date, last_update_date, last_updated_by, created_by,
        inconsistent_flag
      )
      select
        ad_snapshot_bugfixes_s.nextval,
        l_global_snapshot_id,
        sbs.bugfix_id,
        sbs.bug_status,
        sbs.success_flag,
        sysdate, sysdate, 5, 5,
        'N'  /* inconsistent_flag: set to 'N' */
      from ad_snapshot_bugfixes sbs     -- seeded
      where sbs.snapshot_id = l_preseeded_snapshot_id
      and not exists (select /*+ INDEX(SB2 AD_SNAPSHOT_BUGFIXES_U2) */
                        'Already exists'
                      from ad_snapshot_bugfixes sb2
                      where sb2.snapshot_id = l_global_snapshot_id
                      and sb2.bugfix_id = sbs.bugfix_id);
Line: 721

      insert into ad_snapshot_files
      (
        snapshot_file_id,
        snapshot_id, file_id, containing_file_id,
        file_version_id,
        update_source_id, update_type,
        creation_date, last_update_date, last_updated_by, created_by,
        appl_top_id, inconsistent_flag,
        server_type_admin_flag, server_type_forms_flag,
        server_type_node_flag, server_type_web_flag,
        dest_file_id, file_type_flag
      )
      select
        ad_snapshot_files_s.nextval,
        l_global_snapshot_id, file_id, containing_file_id,
        file_version_id,
        update_source_id, update_type,
        sysdate, sysdate, 5, 5,
        p_cur_appl_top_id, 'N',
        server_type_admin_flag, server_type_forms_flag,
        server_type_node_flag, server_type_web_flag,
        dest_file_id, file_type_flag
      from  ad_snapshot_files sf
      where snapshot_id = l_preseeded_snapshot_id
      and not exists (select  /*+ INDEX(SF2 AD_SNAPSHOT_FILES_U2) */
                          'Already exists'
                      from ad_snapshot_files sf2
                      where sf2.snapshot_id = l_global_snapshot_id
                      and sf2.file_id = sf.file_id
                      and nvl(sf2.containing_file_id, -1) =
                                                nvl(sf.containing_file_id, -1));
Line: 761

      select 'x' into l_dummy
      from ad_snapshots ads, ad_releases adr
      where ads.release_id = adr.release_id
      and ads.snapshot_id = l_global_snapshot_id
      and adr.major_version = ( select distinct major_version from ad_releases
                                where release_id = l_release_id );
Line: 773

        update ad_snapshots
        set snapshot_type = 'O',
        snapshot_name = snapshot_name||'-'||snapshot_id,
        last_update_date = sysdate
        where snapshot_id = l_global_snapshot_id;
Line: 781

        update ad_snapshots
        set release_id = l_release_id,
        last_update_date = sysdate
        where snapshot_id = l_global_snapshot_id
        and release_id <> l_release_id;
Line: 806

      insert into ad_snapshot_bugfixes_temp
      (
        bugfix_id,
        bug_status,
        success_flag
      )
      select
        bugfix_id,
        decode(min(decode(bug_status, 'EXPLICIT', 1, 2)), 1,
               'EXPLICIT', 'IMPLICIT'),
        decode(min(decode(success_flag, 'N', 1, 2)), 1, 'N', 'Y')
      from ad_snapshot_bugfixes
      where snapshot_id in (select snapshot_id
                            from ad_snapshots s, ad_appl_tops at1
                            where s.appl_top_id = at1.appl_top_id
                            and at1.applications_system_name = p_apps_system_name
                            and at1.appl_top_type = 'R'
                            and s.snapshot_type = 'C'
                            and s.snapshot_name = 'CURRENT_VIEW')
      group by bugfix_id;
Line: 846

      insert into ad_snapshot_bugfixes
      (
        snapshot_bug_id, snapshot_id,
        bugfix_id, bug_status, success_flag,
        inconsistent_flag,
        creation_date, last_update_date, last_updated_by, created_by
      )
      select
        ad_snapshot_bugfixes_s.nextval, l_global_snapshot_id,
        t.bugfix_id, t.bug_status, t.success_flag,
        decode(l_count_appltops, 1, 'N', null),
        sysdate, sysdate, 5, 5
      from ad_snapshot_bugfixes_temp t
      where not exists (select 'Already exists'
                        from ad_snapshot_bugfixes sb2
                        where sb2.snapshot_id = l_global_snapshot_id
                        and sb2.bugfix_id = t.bugfix_id);
Line: 867

      insert into ad_snapshot_files
      (
        snapshot_file_id, snapshot_id,
        file_id, containing_file_id, file_version_id,
        dest_file_id, file_type_flag,
        appl_top_id,
        inconsistent_flag,
        update_source_id, update_type,
        creation_date, last_update_date, created_by, last_updated_by
      )
      select
        ad_snapshot_files_s.nextval, l_global_snapshot_id,
        t.file_id, t.containing_file_id, t.file_version_id,
        t.dest_file_id, t.file_type_flag,
        decode(l_count_appltops, 1, p_cur_appl_top_id, null),
        decode(l_count_appltops, 1, 'N', null),
        -1, 'P',
        sysdate, sysdate, 5, 5
      from
        (
          select
            file_id,
            max(containing_file_id) containing_file_id,
            max(file_version_id) file_version_id,
            max(dest_file_id) dest_file_id,
            decode(max(decode(file_type_flag,'M',1,'N',0,2)),
                                 1,'M',0,'N',null) file_type_flag
          from
            ad_snapshot_files_temp
          group by file_id) t
       where not exists (select 'Already exists'
                        from ad_snapshot_files sf2
                        where sf2.snapshot_id = l_global_snapshot_id
                        and sf2.file_id = t.file_id
                        and nvl(sf2.containing_file_id, -1) =
                                                   nvl(t.containing_file_id, -1)
                       );
Line: 926

procedure update_current_view
           (p_patch_run_id number,
            p_appl_top_id  number)
is
  l_at_id number;
Line: 940

    select pr.appl_top_id
    into l_at_id
    from ad_patch_runs pr
    where pr.patch_run_id = p_patch_run_id;
Line: 946

    select pr.appl_top_id
    into l_at_id
    from ad_patch_runs pr
    where pr.patch_run_id = p_patch_run_id
    and pr.appl_top_id = p_appl_top_id;
Line: 953

  delete from ad_patch_hist_snaps_temp;
Line: 956

    put_line('About to insert PR-ID into temp table');
Line: 959

  insert into ad_patch_hist_snaps_temp
  (
    action_code, patch_run_id
  )
  select G_PR_ID_ACT_CD, pr.patch_run_id
  from ad_patch_runs pr
  where pr.patch_run_id = p_patch_run_id;
Line: 968

    put_line('Inserted '||to_char(sql%rowcount)||' PR-ID rows');
Line: 969

    put_line('About to call update_current_view() (the one '||
             'that works on many)');
Line: 973

  update_current_view('IN_TEMP_TAB', l_at_id, TRUE);
Line: 988

end update_current_view;
Line: 990

procedure update_current_view
           (p_patch_runs_spec          varchar2,
            p_appl_top_id              number,
            p_caller_is_managing_locks boolean)
is
  l_snapshot_id number;
Line: 1020

  l_snapshot_files_inserted number := 0;
Line: 1029

  l_deleted_ru_file_ids NUM_TAB;
Line: 1042

    put_line('In update_current_view(). (the one that '||
             'works on many ptch-runs)');
Line: 1059

      put_line('About to insert PR-IDs into temp table');
Line: 1062

    insert into ad_patch_hist_snaps_temp
    (
      patch_run_id, action_code
    )
    select
      patch_run_id, G_PR_ID_ACT_CD
    from ad_patch_runs
    where appl_top_id = p_appl_top_id
    and patch_run_id not in (select patch_run_id
                             from ad_patch_hist_snaps_temp
                             where action_code = G_PR_ID_ACT_CD);
Line: 1075

      put_line('Inserted '||to_char(sql%rowcount)||' PR-ID rows');
Line: 1092

  select nvl(count(*), 0)
  into l_count
  from ad_patch_hist_snaps_temp;
Line: 1107

    select 1
    into l_count
    from ad_patch_hist_snaps_temp t,
         ad_patch_runs pr,
         ad_patch_drivers pd
    where t.patch_run_id = pr.patch_run_id
    and pr.patch_driver_id = pd.patch_driver_id
    and pd.driver_type_c_flag = 'Y'
    and rownum < 2;
Line: 1127

  select release_name
  into l_curr_rlse_nm
  from fnd_product_groups;
Line: 1179

  select snapshot_id
  into l_snapshot_id
  from ad_snapshots
  where appl_top_id = p_appl_top_id
  and snapshot_name = 'CURRENT_VIEW'
  and snapshot_type = 'C';
Line: 1190

  select applications_system_name into l_apps_system_name
  from   ad_appl_tops where appl_top_id = p_appl_top_id;
Line: 1196

  select snapshot_id into l_global_snapshot_id
  from   ad_snapshots s, ad_appl_tops t
  where  s.snapshot_type            = 'G' and
         s.snapshot_name            = 'GLOBAL_VIEW' and
         s.appl_top_id              = t.appl_top_id and
         t.applications_system_name = l_apps_system_name;
Line: 1214

    select f.file_id
    into l_apps_zip_f_id
    from ad_files f
    where f.filename = 'apps.zip'
    and f.app_short_name = 'AU'
    and f.subdir = 'java';
Line: 1221

    insert into ad_files
    (
      file_id,
      app_short_name, subdir, filename,
      creation_date, last_update_date, last_updated_by, created_by
    )
    values
    (
      ad_files_s.nextval,
      'AU', 'java', 'apps.zip',
      sysdate, sysdate, 5, 5
    ) returning file_id into l_apps_zip_f_id;
Line: 1244

  insert into ad_files
  (
    file_id,
    app_short_name,
    subdir,
    filename,
    creation_date, last_update_date, last_updated_by, created_by
  )
  select    -- for all the various Unix's
    ad_files_s.nextval,
    a.application_short_name,
    'lib',
    'lib'||decode(a.application_short_name, 'SQLGL', 'gl',
                                            'SQLAP', 'ap',
                                            'OFA', 'fa',
                                            'SQLSO', 'so',
                                            lower(a.application_short_name))||
           '.a',
    sysdate, sysdate, 5, 5
  from fnd_application a
  where not exists (select
                      'lib.a already exists'
                    from ad_files f2
                    where f2.filename =  'lib'||
                                           decode(a.application_short_name,
                                             'SQLGL', 'gl',
                                             'SQLAP', 'ap',
                                             'OFA', 'fa',
                                             'SQLSO', 'so',
                                             lower(a.application_short_name))||
                                           '.a'
                    and f2.subdir = 'lib'
                    and f2.app_short_name = a.application_short_name);
Line: 1280

    put_line('>>(had to insert '||to_char(sql%rowcount)||' rows)');
Line: 1285

  insert into ad_files
  (
    file_id,
    app_short_name,
    subdir,
    filename,
    creation_date, last_update_date, last_updated_by, created_by
  )
  select
    ad_files_s.nextval,
    a.application_short_name,
    'lib',
    decode(a.application_short_name, 'SQLGL', 'gl',
                                     'SQLAP', 'ap',
                                     'OFA', 'fa',
                                     'SQLSO', 'so',
                                     lower(a.application_short_name))||
           'st.lib',
    sysdate, sysdate, 5, 5
  from fnd_application a
  where not exists (select
                      'st.lib already exists'
                    from ad_files f2
                    where f2.filename =  decode(a.application_short_name,
                                           'SQLGL', 'gl',
                                           'SQLAP', 'ap',
                                           'OFA', 'fa',
                                           'SQLSO', 'so',
                                           lower(a.application_short_name))||
                                         'st.lib'
                    and f2.subdir = 'lib'
                    and f2.app_short_name = a.application_short_name);
Line: 1320

    put_line('>>(had to insert '||to_char(sql%rowcount)||' rows)');
Line: 1329

      put_line('About to insert candidate FILES info into temp table');
Line: 1344

    This is done in a 2-step process, viz. an INSERT SQL followed by an UPDATE
    SQL. The first SQL inserts candidate rows into the temp table, and the
    second one flags (updates) C object files that are not archived (main()'s),
    that got mistaken as non-main() files in the first SQL.

    Moreover, when there is only 1 row in the temp table, then the analytic
    function can be done away with and replaced with a grp by instead (since
    each FILE_ID partition will have only 1 row, or worst case, multiple
    rows with same version). Note that in the vast majority of the cases,
    we will have only 1 starter row in the temp table (multiple rows
    occur only in the applptch.txt upload case)

    The 2nd SQL (the UPDATE) is however the same regardless of whether its
    a big/small patch, or whether there are 1/many rows in the temp tables
    to start with.

    The first SQL (INSERT stmt) is explained below:

    Case 1: 1 patch-run
    ------
      The SQL to use is:

      insert into ad_patch_hist_snaps_temp
        (patch_run_id, action_code, file_id, file_version_id,
         app_short_name, filename,
         version_segment1, version_segment2,
         version_segment3, version_segment4,
         version_segment5, version_segment6,
         version_segment7, version_segment8,
         version_segment9, version_segment10,
         translation_level, dest_file_id, file_type_flag)
      select
        max(pr.patch_run_id),
        decode(max(pca.action_code),
               'copy',
                 decode(max(f.subdir),
                        'lib',
                          case when (max(f.filename) like '%.o' or
                                     max(f.filename) like '%.obj') then
                            :clib_cd else
                            :none_cd end,
                          :none_cd),
               'RU_Insert', :azip_cd,
               'RU_Update', :azip_cd,
               'RU_Delete', :azip_cd,
                 :none_cd) act_cd,
        f.file_id, max(afv.file_version_id),
        max(f.app_short_name), max(f.filename),
        max(afv.version_segment1), max(afv.version_segment2),
        max(afv.version_segment3), max(afv.version_segment4),
        max(afv.version_segment5), max(afv.version_segment6),
        max(afv.version_segment7), max(afv.version_segment8),
        max(afv.version_segment9), max(afv.version_segment10),
        max(afv.translation_level), max(prba.dest_file_id),
        max(prba.file_type_flag)
      from ad_patch_hist_snaps_temp t, ad_patch_runs pr,
           ad_patch_run_bugs prb, ad_patch_run_bug_actions prba,
           ad_patch_common_actions pca, ad_file_versions afv, ad_files f
      where pr.patch_run_id = t.patch_run_id
      and pr.appl_top_id = :at_id
      and t.action_code = :pr_id_act_cd
      and pr.patch_run_id = prb.patch_run_id
      and prb.patch_run_bug_id = prba.patch_run_bug_id
      and prba.common_action_id = pca.common_action_id
      and prba.file_id = f.file_id
      and prba.patch_file_version_id = afv.file_version_id (+)
      and prba.executed_flag = 'Y'
      and pca.action_code in ('copy', 'forcecopy', 'RU_Update',
          'RU_Insert', 'RU_Delete')
      group by f.file_id;
Line: 1426

      insert into ad_patch_hist_snaps_temp
        (patch_run_id, action_code, file_id, file_version_id,
         app_short_name, filename,
         version_segment1, version_segment2,
         version_segment3, version_segment4,
         version_segment5, version_segment6,
         version_segment7, version_segment8,
         version_segment9, version_segment10,
         translation_level, dest_file_id, file_type_flag)
      select
        m.patch_run_id, m.act_cd, m.file_id, m.file_version_id,
        m.app_short_name, m.filename,
        m.version_segment1, m.version_segment2,
        m.version_segment3, m.version_segment4,
        m.version_segment5, m.version_segment6,
        m.version_segment7, m.version_segment8,
        m.version_segment9, m.version_segment10,
        m.translation_level, prba.dest_file_id, prba.file_type_flag
      from
        (
        select
          pr.patch_run_id, afv.file_version_id,
          f.file_id, f.app_short_name, f.filename,
          afv.version_segment1, afv.version_segment2,
          afv.version_segment3, afv.version_segment4,
          afv.version_segment5, afv.version_segment6,
          afv.version_segment7, afv.version_segment8,
          afv.version_segment9, afv.version_segment10,
          afv.translation_level,
          decode(pca.action_code, 'copy',
            decode(f.subdir, 'lib',
              case when (f.filename like '%.o' or f.filename like '%.obj')
                     then :clib_cd
                   else :none_cd
              end,
              :none_cd),
            'RU_Insert', :azip_cd,
            'RU_Update', :azip_cd,
            'RU_Delete', :azip_cd,
            :none_cd) act_cd,
          row_number() over  (partition by f.file_id
                  order by afv.version_segment1 desc, afv.version_segment2 desc,
                           afv.version_segment3 desc, afv.version_segment4 desc,
                           afv.version_segment5 desc, afv.version_segment6 desc,
                           afv.version_segment7 desc, afv.version_segment8 desc,
                           afv.version_segment9 desc, afv.version_segment10 desc,
                           afv.translation_level desc nulls last) as r1
        from ad_patch_hist_snaps_temp t, ad_patch_runs pr,
             ad_patch_run_bugs prb, ad_patch_run_bug_actions prba,
             ad_patch_common_actions pca, ad_file_versions afv, ad_files f
        where pr.patch_run_id = t.patch_run_id
        and pr.appl_top_id = :at_id
        and t.action_code = :pr_id_act_cd
        and pr.patch_run_id = prb.patch_run_id
        and prb.patch_run_bug_id = prba.patch_run_bug_id
        and prba.common_action_id = pca.common_action_id
        and prba.file_id = f.file_id
        and prba.patch_file_version_id = afv.file_version_id (+)
        and prba.executed_flag = 'Y'
        and pca.action_code in ('copy', 'forcecopy', 'RU_Update',
            'RU_Insert', 'RU_Delete')
        ) m
      where m.r1 = 1


    Next, the second SQL (UPDATE stmt) is explained below:

    update
      ad_patch_hist_snaps_temp t
    set t.action_code = :none_cd
    where t.action_code = :clib_cd
    and not exists (select
                        'libin action exists for this .o (ie. its archived)'
                    from ad_patch_run_bug_actions prba,
                         ad_patch_run_bugs prb,
                         ad_patch_common_actions pca
                    where prba.file_id = t.file_id
                    and prba.patch_run_bug_id = prb.patch_run_bug_id
                    and prb.patch_run_id = t.patch_run_id
                    and pca.common_action_id = prba.common_action_id
                    and pca.action_code = 'libin')

    */

    l_ins_stmt1 :=
      'insert into ad_patch_hist_snaps_temp '||
        '(patch_run_id, action_code, file_id, file_version_id, '||
        'app_short_name, filename, '||
        'version_segment1, version_segment2, '||
        'version_segment3, version_segment4, '||
        'version_segment5, version_segment6, '||
        'version_segment7, version_segment8, '||
        'version_segment9, version_segment10, '||
        'translation_level,  dest_file_id, file_type_flag) '||
      'select ';
Line: 1537

        'and pca.action_code in (''copy'', ''forcecopy'', ''RU_Update'', '||
        '''RU_Insert'', ''RU_Delete'') ';
Line: 1555

               '''RU_Insert'', '||
                 ':azip_cd, '||
               '''RU_Update'', '||
                 ':azip_cd, '||
               '''RU_Delete'', '||
                 ':azip_cd, '||
                 ':none_cd) act_cd, '||
        'f.file_id, max(afv.file_version_id), '||
        'max(f.app_short_name), max(f.filename), '||
        'max(afv.version_segment1), max(afv.version_segment2), '||
        'max(afv.version_segment3), max(afv.version_segment4), '||
        'max(afv.version_segment5), max(afv.version_segment6), '||
        'max(afv.version_segment7), max(afv.version_segment8), '||
        'max(afv.version_segment9), max(afv.version_segment10), '||
        'max(afv.translation_level), max(prba.dest_file_id), '||
        'max(prba.file_type_flag) ';
Line: 1588

          'select ';
Line: 1607

          '''RU_Insert'', :azip_cd, '||
          '''RU_Update'', :azip_cd, '||
          '''RU_Delete'', :azip_cd, '||
          ':none_cd) act_cd, '||
        'row_number() over  (partition by f.file_id '||
              'order by afv.version_segment1 desc, afv.version_segment2 desc, '||
                       'afv.version_segment3 desc, afv.version_segment4 desc, '||
                       'afv.version_segment5 desc, afv.version_segment6 desc, '||
                       'afv.version_segment7 desc, afv.version_segment8 desc, '||
                       'afv.version_segment9 desc, afv.version_segment10 desc, '||
                       'afv.translation_level desc nulls last) as r1, '||
                       'prba.dest_file_id, prba.file_type_flag ';
Line: 1642

      put_line('@@FULL INSERT STMT:@@');
Line: 1656

      put_line('Inserted '||to_char(sql%rowcount)||
               ' candidate FILES rows into temp table');
Line: 1670

    update
      ad_patch_hist_snaps_temp t
    set t.action_code = L_ARCH_NONE_ACT_CD
    where t.action_code = L_ARCH_CLIB_ACT_CD
    and not exists (select
                        'libin action exists for this .o (ie. its archived)'
                    from ad_patch_run_bug_actions prba,
                         ad_patch_run_bugs prb,
                         ad_patch_common_actions pca
                    where prba.file_id = t.file_id
                    and prba.patch_run_bug_id = prb.patch_run_bug_id
                    and prb.patch_run_id = t.patch_run_id
                    and pca.common_action_id = prba.common_action_id
                    and pca.action_code = 'libin');
Line: 1688

    update
      ad_patch_hist_snaps_temp t
    set t.clib_arch_file_id =
      (
        select f.file_id
        from ad_files f
        where f.app_short_name = translate(t.app_short_name, 'A#', 'A')
        and f.subdir = 'lib'
        and f.filename = decode(
                           lower(substr(t.filename, instr(t.filename,'.',-1),
                                        length(t.filename) -
                                          instr(t.filename,'.',-1) + 1)),
                           '.o', 'lib', null) ||
                         decode(translate(t.app_short_name, 'A#', 'A'),
                                'SQLGL', 'gl',
                                'SQLAP', 'ap',
                                'OFA', 'fa',
                                'SQLSO', 'so',
                              lower(translate(t.app_short_name, 'A#', 'A'))) ||
                         decode(
                           lower(substr(t.filename, instr(t.filename,'.',-1),
                                        length(t.filename) -
                                          instr(t.filename,'.',-1) + 1)),
                           '.o', '.a', 'st.lib')
      )
    where t.action_code = L_ARCH_CLIB_ACT_CD;
Line: 1733

    update ad_patch_hist_snaps_temp t
    set t.irep_gathered_flag = 'N';
Line: 1744

      put_line('Inserting new files in the curr-vw snapshot');
Line: 1748

    insert into ad_snapshot_files
    (
      snapshot_file_id,
      snapshot_id,
      file_id,
      containing_file_id,
      file_version_id,
      dest_file_id,
      file_type_flag,
      update_source_id,
      update_type,
      creation_date, last_update_date,
      last_updated_by, created_by,
      appl_top_id,
      irep_gathered_flag,
      last_patched_date
    )
    select
      ad_snapshot_files_s.nextval,
      l_snapshot_id,
      t.file_id,
      decode(t.action_code, L_ARCH_CLIB_ACT_CD, t.clib_arch_file_id,
                            L_ARCH_AZIP_ACT_CD, l_apps_zip_f_id,
                            null),
      t.file_version_id,
      t.dest_file_id,
      t.file_type_flag,
      t.patch_run_id,
      'P',
      sysdate, sysdate,
      5, 5, p_appl_top_id,
      t.irep_gathered_flag,
      sysdate
    from ad_patch_hist_snaps_temp t
    where t.action_code in (L_ARCH_NONE_ACT_CD, L_ARCH_CLIB_ACT_CD,
                            L_ARCH_AZIP_ACT_CD)
    and not exists (select 'Already exists'
                    from ad_snapshot_files sf
                    where sf.snapshot_id = l_snapshot_id
                    and sf.file_id = t.file_id
                    and ((sf.containing_file_id is null and
                          t.action_code = L_ARCH_NONE_ACT_CD)
                             or
                         (sf.containing_file_id = decode(t.action_code,
                                    L_ARCH_CLIB_ACT_CD, t.clib_arch_file_id,
                                    L_ARCH_AZIP_ACT_CD, l_apps_zip_f_id))
                        )
                    );
Line: 1797

    l_snapshot_files_inserted := sql%rowcount;
Line: 1800

      put_line('Inserted '||to_char(l_snapshot_files_inserted)||
               ' new files in the curr-vw snapshot');
Line: 1804

    select count(*) into l_snapshot_count
    from   ad_snapshots s, ad_appl_tops t
    where  s.snapshot_type = 'C' and
           s.appl_top_id = t.appl_top_id and
           t.applications_system_name = l_apps_system_name;
Line: 1815

      raise_application_error(-20000, 'Error: update_current_view: ' ||
                              'Currrent view snapshot doesn''t exist.');
Line: 1819

    /* insert new files into Global current view snapshot */

    insert into ad_snapshot_files
    (
      snapshot_file_id, snapshot_id, file_id, containing_file_id,
      file_version_id, dest_file_id, file_type_flag,
      update_source_id, update_type,
      creation_date, last_update_date, last_updated_by,
      created_by, appl_top_id, inconsistent_flag
    )
    select
      ad_snapshot_files_s.nextval,
      l_global_snapshot_id,          -- Global Snapshot ID here
      t.file_id,
      decode(t.action_code, L_ARCH_CLIB_ACT_CD, t.clib_arch_file_id,
                            L_ARCH_AZIP_ACT_CD, l_apps_zip_f_id,
                            null),
      t.file_version_id,
      t.dest_file_id,
      t.file_type_flag,
      t.patch_run_id,
      'P',
      sysdate, sysdate,
      5, 5, p_appl_top_id,
      l_inconsistent_flag
    from ad_patch_hist_snaps_temp t
    where
    t.action_code in (L_ARCH_NONE_ACT_CD, L_ARCH_CLIB_ACT_CD,
                                          L_ARCH_AZIP_ACT_CD)
    and not exists (select 'Already exists'
                    from ad_snapshot_files sf
                    where sf.snapshot_id = l_global_snapshot_id
                    and sf.file_id = t.file_id
                    and ((sf.containing_file_id is null and
                          t.action_code = L_ARCH_NONE_ACT_CD)
                             or
                         (sf.containing_file_id = decode(t.action_code,
                                    L_ARCH_CLIB_ACT_CD, t.clib_arch_file_id,
                                    L_ARCH_AZIP_ACT_CD, l_apps_zip_f_id))
                        )
                    );
Line: 1861

    l_snapshot_files_inserted := l_snapshot_files_inserted + sql%rowcount;
Line: 1864

      put_line('Inserted '||to_char(sql%rowcount)||
               ' new files in the Global View snapshot');
Line: 1873

                                                l_snapshot_files_inserted,
                                                TRUE,
                                                TRUE,
                                                l_gathered_stats_flag);
Line: 1885

    update ad_snapshot_files sf
    set
      (sf.file_version_id, sf.update_source_id,
       sf.dest_file_id, sf.file_type_flag, sf.irep_gathered_flag) =
         (select t.file_version_id, t.patch_run_id,
                 t.dest_file_id, t.file_type_flag, t.irep_gathered_flag
          from ad_patch_hist_snaps_temp t
          where t.file_id = sf.file_id),
      sf.update_type = 'P',
      sf.last_update_date = sysdate,
      sf.last_updated_by = 5,
      sf.last_patched_date = sysdate
    where sf.snapshot_id = l_snapshot_id
    and sf.file_id in (select t2.file_id
                       from ad_patch_hist_snaps_temp t2
                       where t2.action_code in (L_ARCH_NONE_ACT_CD,
                                       L_ARCH_CLIB_ACT_CD, L_ARCH_AZIP_ACT_CD))
    and exists
     (
      select 'File exists in curr-vw with lower version'
      from ad_patch_hist_snaps_temp t, ad_file_versions fv_old
      where sf.file_id = t.file_id
      and    t.file_version_id = fv_old.file_version_id (+)
      and sf.file_version_id = fv_old.file_version_id (+)
           -- Update only if patch version is higher (code copied from adfilutb.pls)
      and (((fv_old.file_version_id is null)
                or
               ('Y' = decode(
                sign(nvl(t.version_segment1,0) - nvl(fv_old.version_segment1,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment2,0) - nvl(fv_old.version_segment2,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment3,0) - nvl(fv_old.version_segment3,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment4,0) - nvl(fv_old.version_segment4,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment5,0) - nvl(fv_old.version_segment5,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment6,0) - nvl(fv_old.version_segment6,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment7,0) - nvl(fv_old.version_segment7,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment8,0) - nvl(fv_old.version_segment8,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment9,0) - nvl(fv_old.version_segment9,0)),
                -1, null, 1, 'Y', decode(
                sign(nvl(t.version_segment10,0) - nvl(fv_old.version_segment10,0)),
                -1, null, 1, 'Y',  decode(
                sign(t.translation_level - fv_old.translation_level),
                -1, null, 1, 'Y', null)))))))))))
              )
             )
          or (nvl(sf.dest_file_id, -1) <> nvl(t.dest_file_id, -1))
          or (nvl(sf.file_type_flag, 'X') <> nvl(t.file_type_flag, 'X'))
          )
      and ((sf.containing_file_id is null and
            t.action_code = L_ARCH_NONE_ACT_CD)
               or
           (sf.containing_file_id = decode(t.action_code,
                      L_ARCH_CLIB_ACT_CD, t.clib_arch_file_id,
                      L_ARCH_AZIP_ACT_CD, l_apps_zip_f_id))
          )
      );
Line: 1950

      put_line('Updated '||to_char(sql%rowcount)||
               ' files in the curr-vw snapshot');
Line: 1959

       action_code is RU_Delete */

    /* Bug#3483080/3419891:
         We KNOW that RU_Delete actions will be very, very few.
         Therefore our approach is:
           - Hold these temporarily in a collection type
             - While fetching the data, give the hints exactly as given
               below (no more, no less) worked great in volume testing
               db (gsiappkm).
           - Issue a bulk-bind DELETE using the collection type
    */

    select /*+ ordered use_nl(prba, prb, pr, t)
               index(pca ad_patch_common_actions_n1) */
      distinct prba.file_id
    bulk collect into l_deleted_ru_file_ids
    from ad_patch_common_actions pca,
         ad_patch_run_bug_actions prba,
         ad_patch_run_bugs prb,
         ad_patch_runs pr,
         ad_patch_hist_snaps_temp t
    where pr.patch_run_id       = t.patch_run_id and
          pr.appl_top_id        = p_appl_top_id and
          t.action_code         = G_PR_ID_ACT_CD and
          pr.patch_run_id       = prb.patch_run_id and
          prba.patch_run_bug_id = prb.patch_run_bug_id and
          prba.common_action_id = pca.common_action_id and
          pca.action_code       = 'RU_Delete';
Line: 1988

    if nvl(l_deleted_ru_file_ids.last, 0) > 0 then

      forall i in l_deleted_ru_file_ids.first..l_deleted_ru_file_ids.last
        delete from ad_snapshot_files
        where snapshot_id = l_snapshot_id and
              file_id = l_deleted_ru_file_ids(i);
Line: 1996

        put_line('Deleted '||to_char(sql%rowcount)||
                 ' class files which are removed from apps.zip');
Line: 2029

         select file_id, dest_file_id, file_type_flag,
                file_version_id, containing_file_id,
                inconsistent_flag
         from ad_snapshot_files_temp;
Line: 2049

            update /*+ INDEX(SF AD_SNAPSHOT_FILES_U2) */
              ad_snapshot_files sf
            set sf.last_update_date  = sysdate,
              sf.last_updated_by   = 5,
              sf.file_version_id   = file_version_id_list(j),
              sf.update_source_id  = -1,
              sf.update_type       = 'P',
              sf.appl_top_id       = null,
              sf.inconsistent_flag = null,
              sf.dest_file_id      = dest_file_id_list(j),
              sf.file_type_flag    = file_type_flag_list(j)
            where
              sf.snapshot_id                  =  l_global_snapshot_id and
              sf.file_id                      =  file_id_list(j) and
              nvl(sf.containing_file_id, -1)  =
              nvl(containing_file_id_list(j), -1) and
              -- rkagrawa: deliberately putting -2 here since for versionless
              -- files, we want the update_type, update_source_id, etc to be
              -- updated each time the file is patched
              (nvl(sf.file_version_id, -1)    <> nvl(file_version_id_list(j), -2) or
              sf.inconsistent_flag            <> inconsistent_flag_list(j) or
              nvl(sf.dest_file_id, -1)        <> nvl(dest_file_id_list(j), -1) or
              nvl(sf.file_type_flag, -1)      <> nvl(file_type_flag_list(j), -1))
          ;
Line: 2082

        put_line('Updated ' || to_char(sql%rowcount) ||
                 ' in Global view snapshot');
Line: 2089

    /* Delete files from Global view snapshot */

    if nvl(l_deleted_ru_file_ids.last, 0) > 0 then

      forall i in l_deleted_ru_file_ids.first..l_deleted_ru_file_ids.last
        delete from ad_snapshot_files sf
        where sf.snapshot_id = l_global_snapshot_id and
              sf.file_id = l_deleted_ru_file_ids(i)
        and not exists
        (
         select 'Exists in the curr vw of some appltop'
         from ad_snapshot_files sf1
         where sf1.file_id                   = l_deleted_ru_file_ids(i)
         and nvl(sf1.containing_file_id, -1) = nvl(sf.containing_file_id, -1)
         and sf1.snapshot_id in (
                          select s.snapshot_id
                          from ad_snapshots s, ad_appl_tops a
                          where s.snapshot_type          = 'C'
                          and s.appl_top_id              = a.appl_top_id
                          and a.applications_system_name = l_apps_system_name
                          and nvl(a.active_flag,'Y')     = 'Y'
                                )
        );
Line: 2114

        put_line('Deleted '||to_char(sql%rowcount)||
                 ' files from Global View snapshot');
Line: 2121

    update ad_snapshots set last_update_date = sysdate,
    snapshot_update_date = sysdate
    where  snapshot_id in (l_snapshot_id, l_global_snapshot_id);
Line: 2137

  delete from ad_patch_hist_snaps_temp
  where action_code <> G_PR_ID_ACT_CD;
Line: 2144

              p_update_global_view => TRUE,
              p_global_snapshot_id => l_global_snapshot_id,
              p_delete_junk_created => FALSE);  -- let it be, can help debug.
Line: 2167

end update_current_view;
Line: 2186

  l_snapshot_bugs_inserted number := 0;
Line: 2187

  l_snapshot_files_inserted number := 0;
Line: 2214

  select nvl(applications_system_name, '1 UNKNOWN 1')
  into l_prim_apps_sys_nm
  from fnd_product_groups;
Line: 2223

  select to_char(major_version)||'.'||
         to_char(minor_version)||'.'||
         to_char(tape_version)
  into l_rlse_nm
  from ad_releases
  where release_id = p_release_id;
Line: 2233

    select nvl(applications_system_name, '1 UNKNOWN 1'), name
    into l_apps_sys_nm, l_at_name
    from ad_appl_tops
    where appl_top_id = p_appl_top_id
    and appl_top_type = 'R';
Line: 2261

    select snapshot_id
    into l_curr_vw_snapshot_id
    from ad_snapshots
    where appl_top_id = p_appl_top_id
    and snapshot_name = 'CURRENT_VIEW'
    and snapshot_type = 'C';
Line: 2273

    select ss.snapshot_id, ss.release_id
    into l_preseeded_snapshot_id, l_preseeded_rlse_id
    from ad_snapshots ss,             -- seeded
         ad_appl_tops ats             -- seeded
    where ss.appl_top_id = ats.appl_top_id
    and ss.snapshot_type = 'B'
    and ss.snapshot_name like '*PRESEEDED*'||l_rlse_nm||'%'
    and ats.name = '*PRESEEDED*'
    and ats.applications_system_name = '*PRESEEDED*'
    and ats.appl_top_type = 'S'
    and ss.release_id = p_release_id;
Line: 2292

        select 'x' into l_dummy
        from ad_snapshots ads
        where nvl(ran_snapshot_flag, 'N') = 'Y'
        and ads.release_id = p_release_id
        and ads.snapshot_id = l_curr_vw_snapshot_id;
Line: 2302

        update ad_snapshots
        set snapshot_type = 'O',
        snapshot_name = snapshot_name||'-'||snapshot_id,
        last_update_date = sysdate
        where snapshot_id = l_curr_vw_snapshot_id;
Line: 2317

      select ad_snapshots_s.nextval into l_curr_vw_snapshot_id from dual;
Line: 2319

      insert into ad_snapshots
      (
        snapshot_id,
        release_id, appl_top_id,
        snapshot_name, comments,
        snapshot_creation_date, snapshot_update_date,
        snapshot_type, ran_snapshot_flag,
        creation_date, last_update_date, last_updated_by, created_by
      )
      select
        l_curr_vw_snapshot_id,
        p_release_id, p_appl_top_id,
        'CURRENT_VIEW', 'Current View',
        sysdate, sysdate,
        'C', 'N',
        sysdate, sysdate, 5, 5
      from dual;
Line: 2349

      insert into ad_snapshot_bugfixes
      (
        snapshot_bug_id,
        snapshot_id, bugfix_id,
        bug_status, success_flag,
        creation_date, last_update_date, last_updated_by, created_by
      )
      select
        ad_snapshot_bugfixes_s.nextval,
        l_curr_vw_snapshot_id, sbs.bugfix_id,
        sbs.bug_status, sbs.success_flag,
      sysdate, sysdate, 5, 5
      from ad_snapshot_bugfixes sbs     -- seeded
      where sbs.snapshot_id = l_preseeded_snapshot_id
      and not exists (select /*+ INDEX(SB2 AD_SNAPSHOT_BUGFIXES_U2) */
                        'Already exists'
                      from ad_snapshot_bugfixes sb2
                      where sb2.snapshot_id = l_curr_vw_snapshot_id
                      and sb2.bugfix_id = sbs.bugfix_id);
Line: 2369

      l_snapshot_bugs_inserted := sql%rowcount;
Line: 2371

      insert into ad_snapshot_files
      (
        snapshot_file_id,
        snapshot_id, file_id, containing_file_id,
        file_version_id,
        update_source_id, update_type,
        creation_date, last_update_date, last_updated_by, created_by,
        dest_file_id, file_type_flag
      )
      select
        ad_snapshot_files_s.nextval,
        l_curr_vw_snapshot_id, file_id, containing_file_id,
        file_version_id,
        update_source_id, update_type,
        sysdate, sysdate, 5, 5,
        dest_file_id, file_type_flag
      from ad_snapshot_files sf
      where sf.snapshot_id = l_preseeded_snapshot_id

       -- Added for bug 3947949
--   and ((sf.server_type_admin_flag  = l_server_type_admin_flag
--         and l_server_type_admin_flag = 'Y') or
--           (sf.server_type_forms_flag  = l_server_type_forms_flag
--            and l_server_type_forms_flag = 'Y') or
--           (sf.server_type_node_flag   = l_server_type_node_flag
--            and l_server_type_node_flag = 'Y') or
--           (sf.server_type_web_flag    = l_server_type_web_flag
--            and l_server_type_web_flag = 'Y')
--         )

      and not exists (select  /*+ INDEX(SF2 AD_SNAPSHOT_FILES_U2) */
                        'Already exists' from ad_snapshot_files sf2
                      where sf2.snapshot_id = l_curr_vw_snapshot_id
                      and sf2.file_id       = sf.file_id
                      and nvl(sf2.containing_file_id, -1) =
                                                nvl(sf.containing_file_id, -1));
Line: 2407

      l_snapshot_files_inserted := sql%rowcount;
Line: 2409

      if l_snapshot_files_inserted > 0 then

        /* set ran_snapshot_flag only incase the *PRESEEDED* snapshot
         * has files information.
         */

        update ad_snapshots
        set ran_snapshot_flag = 'Y',
        last_update_date = sysdate
        where snapshot_id = l_curr_vw_snapshot_id;
Line: 2435

        select 'x' into l_dummy
        from ad_snapshots ads, ad_releases adr
        where ads.release_id = adr.release_id
        and ads.snapshot_id = l_curr_vw_snapshot_id
        and adr.major_version = ( select distinct major_version from ad_releases
                                  where release_id = p_release_id );
Line: 2448

        update ad_snapshots
        set snapshot_type = 'O',
        last_update_date = sysdate,
        snapshot_name = snapshot_name||'-'||snapshot_id
        where snapshot_id = l_curr_vw_snapshot_id;
Line: 2471

      select ad_snapshots_s.nextval into l_curr_vw_snapshot_id from dual;
Line: 2473

      insert into ad_snapshots
      (
        snapshot_id,
        release_id, appl_top_id,
        snapshot_name, comments,
        snapshot_creation_date, snapshot_update_date,
        snapshot_type, ran_snapshot_flag,
        creation_date, last_update_date, last_updated_by, created_by
      )
      select
        l_curr_vw_snapshot_id,
        p_release_id, p_appl_top_id,
        'CURRENT_VIEW', 'Current View',
        sysdate, sysdate,
        'C', 'N',
        sysdate, sysdate, 5, 5
      from dual;
Line: 2493

      update ad_snapshots
      set release_id = p_release_id,
      last_update_date = sysdate
      where snapshot_id = l_curr_vw_snapshot_id
      and release_id <> p_release_id;
Line: 2512

    l_snapshot_bugs_inserted + l_snapshot_files_inserted,
    TRUE,
    TRUE,
    l_gathered_stats_flag
  );
Line: 2549

procedure update_rel_name(rel_name varchar2) is

G_CURRENT_RELEASE varchar2(50);
Line: 2554

   select release_name
     into G_CURRENT_RELEASE
    from fnd_product_groups;
Line: 2561

            update fnd_product_groups
               set    release_name = rel_name,
                      last_update_date = sysdate,
                      last_updated_by = 1
               where  product_group_id = 1;
Line: 2571

end update_rel_name;