DBA Data[Home] [Help]

APPS.HRI_BPL_AGE SQL Statements

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

Line: 11

g_age_ff_update     DATE;  -- Last update date of age_band Fast Formula
Line: 24

/* This procedure inserts an age band into the hri_age_bands table. The PK is */
/* the minimum age for the age band. There will always be a row with minimum  */
/* age zero (since this cannot be removed by the delete_age_band API) and     */
/* there will always be (possibly the same row) a row with a null maximum age */
/* since inserting a row always works by picking the age band that the new    */
/* minimum age falls into, and splitting it out on the new minimum age.       */
/*                                                                            */
/* If a minimum age is given that already exists, then nothing will happen.   */
/*                                                                            */
/* E.g. if the following bands exist:                                         */
/*                   0 - 12                                                   */
/*                  12 - 24                                                   */
/*                  24 - 36                                                   */
/*                  36 -                                                */
/*                                                                            */
/*  Then insert_age_band(0,12) would do nothing since 12 does not strictly    */
/*  fall into any of the above bands.                                         */
/*                                                                            */
/*  However, insert_age_band(0,18) [NB - equivalent to insert_age_band(1,6) ] */
/*  would give the new set of bands as:                                       */
/*                   0 - 12                                                   */
/*                  12 - 18  [UPDATEd band]                                   */
/*                  18 - 24  [INSERTed band]                                  */
/*                  24 - 36                                                   */
/*                  36 -                                                */
/*                                                                            */
/* The band_min_total_months is the primary key for the table, and each age   */
/* band is defined as the ages (X) satisfying:                                */
/*       band_min_total_months <= X < band_max_total_months                   */
/*                                                                            */
/******************************************************************************/
PROCEDURE insert_age_band( p_age_min_years    NUMBER,
                           p_age_min_months   NUMBER)
IS

  l_total_min_age_months    NUMBER;  --Holds converted age min in months
Line: 64

/* Selects the age band that the new age minimum falls into */
/* Since this is strict it will return no rows if an age minimum is passed in */
/* which corresponds exactly to an age minimum on an existing age band */
  CURSOR split_cur
  (v_total_min_age_months  NUMBER) IS
  SELECT band_min_total_months, band_max_total_months
  FROM hri_age_bands
  WHERE v_total_min_age_months < NVL(band_max_total_months, l_total_min_age_months + 1)
  AND   v_total_min_age_months > NVL(band_min_total_months, l_total_min_age_months - 1)
;
Line: 87

    INSERT INTO hri_age_bands
      (band_min_total_months
      ,band_max_total_months)
      VALUES
        (l_total_min_age_months, l_age_band_to_split_max);
Line: 93

    /* Update the age max of the above band to the new age min above */
    UPDATE hri_age_bands
    SET band_max_total_months = l_total_min_age_months
    WHERE band_min_total_months = l_age_band_to_split_min;
Line: 99

END insert_age_band;
Line: 107

/* inserting a row always works by picking the age band that the new minimum  */
/* age falls into, and splitting it out on the new minimum age.               */
/*                                                                            */
/* If a minimum age is given that does not exists, then nothing will happen.  */
/*                                                                            */
/* E.g. if the following bands exist:                                         */
/*                   0 - 12                                                   */
/*                  12 - 24                                                   */
/*                  24 - 36                                                   */
/*                  36 -                                                */
/*                                                                            */
/*  Then remove_age_band(0,18) would do nothing since 18 does not match the   */
/*  minimum age of any of the above bands.                                    */
/*                                                                            */
/*  However, remove_age_band(0,12) would give the new set of bands as:        */
/*                   0 - 24  [UPDATEd band with maximum age of DELETEd band]  */
/*                  24 - 36                                                   */
/*                  36 -                                                */
/* If the top band is removed, the previous band maximum age will be updated  */
/* with the null value.                                                       */
/******************************************************************************/
PROCEDURE remove_age_band( p_age_min_years   NUMBER,
                           p_age_min_months  NUMBER)
IS

  l_total_min_age_months    NUMBER;  -- Minimum age in months of band to remove
Line: 138

  SELECT band_max_total_months
  FROM hri_age_bands
  WHERE band_min_total_months = v_remove_band_min;
Line: 153

      DELETE FROM hri_age_bands
      WHERE band_min_total_months = l_total_min_age_months;
Line: 156

      UPDATE hri_age_bands
      SET band_max_total_months = l_total_max_age_months
      WHERE band_max_total_months = l_total_min_age_months;
Line: 165

/* Inserts a row into the table. If the row already exists then the row is    */
/* updated. Called from UPLOAD part of FNDLOAD.                               */
/******************************************************************************/
PROCEDURE load_row( p_band_min     IN NUMBER,
                    p_band_max     IN NUMBER,
                    p_owner        IN VARCHAR2 )
IS

  l_row_exists          NUMBER;  -- Whether a row already exists in table
Line: 176

  l_last_update_date    DATE := SYSDATE;
Line: 177

  l_last_updated_by     NUMBER := 0;
Line: 178

  l_last_update_login   NUMBER := 0;
Line: 183

  SELECT 1
  FROM hri_age_bands
  WHERE band_min_total_months = p_band_min;
Line: 191

    l_last_updated_by := 1;
Line: 198

    INSERT INTO hri_age_bands
      ( band_min_total_months
      , band_max_total_months
      , last_update_date
      , last_update_login
      , last_updated_by
      , created_by
      , creation_date )
      VALUES
        ( p_band_min
        , p_band_max
        , l_last_update_date
        , l_last_update_login
        , l_last_updated_by
        , l_created_by
        , l_creation_date );
Line: 216

    UPDATE hri_age_bands
    SET
     band_max_total_months = p_band_max
    ,last_update_date  = l_last_update_date
    ,last_update_login = l_last_update_login
    ,last_updated_by   = l_last_updated_by
    WHERE band_min_total_months = p_band_min;