DBA Data[Home] [Help]

APPS.PA_RESOURCE_PVT SQL Statements

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

Line: 36

        SELECT (max(a1.end_date)+1) available_from
        FROM  pa_res_availability a1,
              pa_res_availability a2
        WHERE a1.resource_id = p_resource_id
          and a1.percent < l_avl_profile
          and a1.record_type = 'C'
          and a1.start_date < sysdate
          and a1.resource_id = a2.resource_id
          and a2.record_type ='C'
          and a2.percent >= l_avl_profile
          and sysdate between a2.start_date and a2.end_date
       UNION
        SELECT min(a1.start_date) available_from
        FROM  pa_res_availability a1,
              pa_res_availability a2
        WHERE a1.resource_id = p_resource_id
          and a1.percent >= l_avl_profile
          and a1.record_type = 'C'
          and a1.start_date >= sysdate
          and a1.resource_id = a2.resource_id
          and a2.record_type ='C'
          and a2.percent < l_avl_profile
          and sysdate between a2.start_date and a2.end_date
       UNION
        SELECT min(a1.start_date) available_from
        FROM   pa_res_availability a1
        WHERE  a1.record_type = 'C'
          and  a1.resource_id = p_resource_id
          and  a1.percent >= l_avl_profile
          and  sysdate < (select min(resource_effective_start_date)
                          from pa_resources_denorm res
                          where a1.resource_id = res.resource_id);
Line: 79

   SELECT min(item_date)
   INTO   l_available_date
   FROM   pa_forecast_items
   WHERE  resource_id          = p_resource_id
   AND    forecast_item_type   = 'U'
   AND    delete_flag          = 'N'
   AND    availability_flag    = 'Y'
   AND    overcommitment_flag  = 'N'
   AND    item_date            >= trunc(sysdate);
Line: 98

        select min(start_date)
        into l_end_date
        from pa_project_assignments
        where resource_id = p_resource_id
        and start_date > l_start_date
        and status_code in (select project_status_code
                         from pa_project_statuses
                         where project_system_status_code =
                         'STAFFED_ASGMT_CONF');
Line: 170

     SELECT
     RSCH.START_DATE
       , RSCH.END_DATE
       , RSCH.SCALE_TYPE
       INTO
       l_start_date1,
       l_end_date1,
       l_scale_type
       FROM  PA_RES_SCH_TIME_CHART  RSCH
       WHERE RSCH.ROW_LABEL_ID = p_ROW_LABEL_ID
       AND END_DATE >= to_date('2000-10-23', 'YYYY-MM-DD')
       AND START_DATE <=  to_date('2000-11-26', 'YYYY-MM-DD')
       AND SCALE_TYPE = 'MONTH';*/
Line: 217

PROCEDURE Insert_resource_denorm
  ( p_resource_denorm_rec  IN    Resource_denorm_Rec_type,
    x_return_status        OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data             OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count            OUT   NOCOPY NUMBER) --File.Sql.39 bug 4440895
IS
   l_resource_denorm_rec         PA_RESOURCE_PVT.Resource_denorm_Rec_type;
Line: 231

   PA_DEBUG.init_err_stack('PA_RESOURCE_PVT.Insert_resource_denorm');
Line: 237

   savepoint RES_PVT_INSERT_RES_DENORM;
Line: 265

   SELECT 'Y'
     INTO l_rows_exists
     FROM dual
    WHERE EXISTS (SELECT 'Y'
                    FROM pa_resources_denorm
                   WHERE l_resource_denorm_rec.person_id = person_id
                     AND l_resource_denorm_rec.job_id = job_id);
Line: 301

   INSERT into pa_resources_denorm
     (
     PERSON_ID,
     RESOURCE_ID,
     RESOURCE_NAME,
     RESOURCE_TYPE,
     RESOURCE_ORGANIZATION_ID,
     RESOURCE_COUNTRY_CODE,
     RESOURCE_COUNTRY,
     RESOURCE_REGION,
     RESOURCE_CITY,
     JOB_ID,
     RESOURCE_JOB_LEVEL,
     RESOURCE_EFFECTIVE_START_DATE,
     RESOURCE_EFFECTIVE_END_DATE,
     EMPLOYEE_FLAG,
     MANAGER_ID,
     MANAGER_NAME,
     BILLABLE_FLAG,
     UTILIZATION_FLAG,
     SCHEDULABLE_FLAG,
     RESOURCE_ORG_ID,
     REQUEST_ID,
     PROGRAM_APPLICATION_ID,
     PROGRAM_ID,
     PROGRAM_UPDATE_DATE,
     CREATION_DATE,
     CREATED_BY,
     LAST_UPDATE_DATE,
     LAST_UPDATED_BY,
     LAST_UPDATE_LOGIN
     -- ,RESOURCE_PERSON_TYPE
     )
     VALUES
     (
     l_resource_denorm_rec.person_id,
     l_resource_id,
     l_resource_denorm_rec.resource_name,
     l_resource_denorm_rec.resource_type,
     l_resource_denorm_rec.resource_organization_id,
     DECODE(l_resource_denorm_rec.resource_country_code, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.resource_country_code),
     DECODE(l_resource_denorm_rec.resource_country, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.RESOURCE_COUNTRY),
     DECODE(l_resource_denorm_rec.resource_region, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.resource_region),
     DECODE(l_resource_denorm_rec.resource_city, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.resource_city),
     DECODE(l_resource_denorm_rec.job_id, FND_API.G_MISS_NUM,
            NULL, l_resource_denorm_rec.job_id),
     DECODE(l_resource_denorm_rec.resource_job_level, FND_API.G_MISS_NUM,
            NULL, l_resource_denorm_rec.resource_job_level),
     l_resource_denorm_rec.resource_effective_start_date,
     DECODE(l_resource_denorm_rec.resource_effective_end_date, FND_API.G_MISS_DATE,
            NULL, l_resource_denorm_rec.resource_effective_end_date),
     l_resource_denorm_rec.employee_flag,
     DECODE(l_resource_denorm_rec.manager_id, FND_API.G_MISS_NUM,
            NULL, l_resource_denorm_rec.manager_id),
     DECODE(l_resource_denorm_rec.manager_name, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.manager_name),
     DECODE(l_resource_denorm_rec.billable_flag, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.billable_flag),
     DECODE(l_resource_denorm_rec.utilization_flag, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.utilization_flag),
     DECODE(l_resource_denorm_rec.schedulable_flag, FND_API.G_MISS_CHAR,
            NULL, l_resource_denorm_rec.schedulable_flag),
     DECODE(l_resource_denorm_rec.resource_org_id, FND_API.G_MISS_NUM,
            NULL,l_resource_denorm_rec.resource_org_id),
     null,               -- REQUEST_ID
     null,               -- PROGRAM_APPLICATION_ID
     null,               -- PROGRAM_ID
     null,               -- PROGRAM_UPDATE_DATE
     sysdate,            -- CREATION_DATE
     fnd_global.user_id, -- CREATED_BY
     sysdate,            -- LAST_UPDATE_DATE
     fnd_global.user_id, -- LAST_UPDATED_BY
     fnd_global.login_id -- LAST_UPDATE_LOGIN
     -- ,l_resource_person_type
     );
Line: 384

     ROLLBACK TO RES_PVT_INSERT_RES_DENORM;
Line: 405

     ROLLBACK TO RES_PVT_INSERT_RES_DENORM;
Line: 409

       (p_pkg_name       => 'PA_RESOURCE_PVT.Insert_resource_denorm'
       ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 414

END Insert_resource_denorm;
Line: 454

PROCEDURE Update_resource_denorm (
				  p_resource_denorm_old_rec  IN  Resource_denorm_Rec_type,
				  p_resource_denorm_new_rec  IN  Resource_denorm_Rec_type,
				  x_return_status            OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
				  x_msg_data                 OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
				  x_msg_count                OUT NOCOPY NUMBER )   --File.Sql.39 bug 4440895
IS
   l_resource_denorm_new_rec   PA_RESOURCE_PVT.Resource_denorm_Rec_type;
Line: 470

   PA_DEBUG.init_err_stack('PA_RESOURCE_PVT.Update_resource_denorm');
Line: 476

   savepoint RES_PVT_UPDATE_RES_DENORM;
Line: 505

      update_single_res_denorm_rec (
	      p_resource_denorm_rec     => l_resource_denorm_new_rec,
	      x_return_status           => l_return_status,
	      x_err_msg_code            => l_err_msg_code );
Line: 530

	 -- Update person related multiple records
	 update_person_res_denorm_recs (
	   p_resource_denorm_rec  => l_resource_denorm_new_rec,
	   x_return_status            => l_return_status,
	   x_err_msg_code             => l_err_msg_code );
Line: 544

	   -- If job_id has been passed but not person_id, usually update attribute
	   -- job_level or billable_flag on multiple records.
      ELSIF l_resource_denorm_new_rec.person_id = FND_API.G_MISS_NUM
	    AND l_resource_denorm_new_rec.job_id <> FND_API.G_MISS_NUM
            AND l_resource_denorm_new_rec.job_id is not null THEN

	 -- Update job related multiple records.
	 update_job_res_denorm_recs (
	   p_resource_denorm_rec      => l_resource_denorm_new_rec,
	   x_return_status            => l_return_status,
	   x_err_msg_code             => l_err_msg_code );
Line: 570

     ROLLBACK TO RES_PVT_UPDATE_RES_DENORM;
Line: 591

     ROLLBACK TO RES_PVT_UPDATE_RES_DENORM;
Line: 595

       (p_pkg_name       => 'PA_RESOURCE_PVT.Update_resource_denorm'
       ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 600

END Update_resource_denorm;
Line: 610

PROCEDURE update_single_res_denorm_rec(
				       p_resource_denorm_rec  IN  resource_denorm_rec_type,
				       x_return_status        OUT NOCOPY VARCHAR, --File.Sql.39 bug 4440895
				       x_err_msg_code         OUT NOCOPY VARCHAR) --File.Sql.39 bug 4440895
IS
   num_of_rec                 NUMBER;
Line: 633

   UPDATE pa_resources_denorm
     SET
     resource_type               = DECODE(p_resource_denorm_rec.resource_type, FND_API.G_MISS_CHAR,
                                          resource_type,p_resource_denorm_rec.resource_type),
     resource_organization_id    = DECODE(p_resource_denorm_rec.resource_organization_ID,
                                          FND_API.G_MISS_NUM, resource_organization_id,
                                          p_resource_denorm_rec.resource_organization_id),
     resource_country_code       = DECODE(p_resource_denorm_rec.resource_country_code, FND_API.G_MISS_CHAR,
                                          resource_country_code,p_resource_denorm_rec.resource_country_code),
     resource_country            = DECODE(p_resource_denorm_rec.resource_country, FND_API.G_MISS_CHAR,
                                          resource_country,p_resource_denorm_rec.resource_country),
     resource_region             = DECODE(p_resource_denorm_rec.resource_region, FND_API.G_MISS_CHAR,
                                          resource_region,p_resource_denorm_rec.resource_region),
     resource_city               = DECODE(p_resource_denorm_rec.resource_city, FND_API.G_MISS_CHAR,
                                          resource_city,p_resource_denorm_rec.resource_city),
     job_id                      = DECODE(p_resource_denorm_rec.job_id, FND_API.G_MISS_NUM,
                                          job_id,p_resource_denorm_rec.job_id),
     resource_job_level          = DECODE(p_resource_denorm_rec.resource_job_level, FND_API.G_MISS_NUM,
                                          resource_job_level,p_resource_denorm_rec.resource_job_level),
     resource_effective_end_date = DECODE(p_resource_denorm_rec.resource_effective_end_date,
                                          FND_API.G_MISS_DATE, resource_effective_end_date,
                                          p_resource_denorm_rec. resource_effective_end_date),
     employee_flag               = DECODE(p_resource_denorm_rec.employee_flag, FND_API.G_MISS_CHAR,
                                          employee_flag,p_resource_denorm_rec.employee_flag),
     manager_id                  = DECODE(p_resource_denorm_rec.manager_id, FND_API.G_MISS_NUM,
                                          manager_id,p_resource_denorm_rec.manager_id),
     manager_name                = DECODE(p_resource_denorm_rec.manager_name, FND_API.G_MISS_CHAR,
                                          manager_name,p_resource_denorm_rec.manager_name),
     billable_flag               = DECODE(p_resource_denorm_rec.billable_flag, FND_API.G_MISS_CHAR,
                                          billable_flag,p_resource_denorm_rec.billable_flag),
     utilization_flag            = DECODE(p_resource_denorm_rec.utilization_flag, FND_API.G_MISS_CHAR,
                                          utilization_flag,p_resource_denorm_rec.utilization_flag),
     schedulable_flag            = DECODE(p_resource_denorm_rec.schedulable_flag, FND_API.G_MISS_CHAR,
                                          schedulable_flag,p_resource_denorm_rec.schedulable_flag),
     resource_org_id             = DECODE(p_resource_denorm_rec.resource_org_id, FND_API.G_MISS_NUM,
                                          resource_org_id,p_resource_denorm_rec.resource_org_id),
     LAST_UPDATE_date            = sysdate,
     LAST_UPDATED_by             = fnd_global.user_id,
     LAST_UPDATE_login           = fnd_global.login_id
     WHERE person_id = p_resource_denorm_rec.person_id
     AND resource_effective_start_date = p_resource_denorm_rec.resource_effective_start_date;
Line: 680

     (p_pkg_name        => 'PA_RESOURCE_PVT.update_person_res_denorm_recs',
      p_procedure_name  => PA_DEBUG.G_Err_Stack );
Line: 685

END update_single_res_denorm_rec;
Line: 697

PROCEDURE update_person_res_denorm_recs
  ( p_resource_denorm_rec  IN  resource_denorm_rec_type,
    x_return_status        OUT NOCOPY VARCHAR,  --File.Sql.39 bug 4440895
    x_err_msg_code         OUT NOCOPY VARCHAR) --File.Sql.39 bug 4440895
IS
   num_of_rec       NUMBER;
Line: 725

   UPDATE pa_resources_denorm
     SET
     resource_name         = DECODE(p_resource_denorm_rec.resource_name, FND_API.G_MISS_CHAR,
                                    resource_name,p_resource_denorm_rec.resource_name),
     resource_country_code = DECODE(p_resource_denorm_rec.resource_country_code, FND_API.G_MISS_CHAR,
                                    resource_country_code,p_resource_denorm_rec.resource_country_code),
     resource_country      = DECODE(p_resource_denorm_rec.resource_country, fnd_API.G_MISS_CHAR,
                                    resource_country,p_resource_denorm_rec.resource_country),
     resource_region       = DECODE(p_resource_denorm_rec.resource_region, FND_API.G_MISS_CHAR,
                                    resource_region,p_resource_denorm_rec.resource_region),
     resource_city         = DECODE(p_resource_denorm_rec.resource_city, FND_API.G_MISS_CHAR,
                                    resource_city,p_resource_denorm_rec.resource_city),
     last_update_date      = sysdate,
     last_updated_by       = fnd_global.user_id,
     last_update_login     = fnd_global.login_id
     WHERE p_resource_denorm_rec.person_id = person_id;
Line: 751

     (p_pkg_name       => 'PA_RESOURCE_PVT.update_person_res_denorm_recs'
      ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 756

END update_person_res_denorm_recs;
Line: 787

   SELECT 'Y' INTO l_name_changed
   FROM dual
   WHERE exists
      (SELECT 'Y'
       FROM pa_resources_denorm
       WHERE person_id = p_new_resource_denorm_rec.person_id
       AND resource_name <> l_new_resource_name) ;
Line: 802

      UPDATE pa_resources_denorm
       	 SET manager_name = l_new_resource_name
	      WHERE manager_id = p_new_resource_denorm_rec.person_id;
Line: 814

     (p_pkg_name       => 'PA_RESOURCE_PVT.update_person_res_denorm_recs',
      p_procedure_name => 'PA_RESOURCE_PVT.syncronize_manager_name'); --PA_DEBUG.G_Err_Stack ); 5336386
Line: 827

PROCEDURE update_job_res_denorm_recs
  (p_resource_denorm_rec  IN  resource_denorm_rec_type,
   p_start_rowid          IN  rowid default NULL,
   p_end_rowid            IN  rowid default NULL,
   x_return_status        OUT NOCOPY VARCHAR, --File.Sql.39 bug 4440895
   x_err_msg_code         OUT NOCOPY VARCHAR ) --File.Sql.39 bug 4440895
IS
BEGIN
   -- Initialize the return status to success
   x_return_status := FND_API.G_RET_STS_SUCCESS;
Line: 839

   UPDATE pa_resources_denorm
     SET
     resource_job_level = DECODE(p_resource_denorm_rec.resource_job_level, FND_API.G_MISS_NUM,
                                 resource_job_level,p_resource_denorm_rec.resource_job_level),
     employee_flag      = DECODE(p_resource_denorm_rec.employee_flag, FND_API.G_MISS_CHAR,
                                 employee_flag, p_resource_denorm_rec.employee_flag),
     billable_flag      = DECODE(p_resource_denorm_rec.billable_flag, FND_API.G_MISS_CHAR,
                                 billable_flag, p_resource_denorm_rec.billable_flag),
     utilization_flag   = DECODE(p_resource_denorm_rec.utilization_flag, FND_API.G_MISS_CHAR,
                                 utilization_flag, p_resource_denorm_rec.utilization_flag),
     schedulable_flag   = DECODE(p_resource_denorm_rec.schedulable_flag, FND_API.G_MISS_CHAR,
                                schedulable_flag, p_resource_denorm_rec.schedulable_flag),
     last_update_date   = sysdate,
     last_updated_by    = fnd_global.user_id,
     last_update_login  = fnd_global.login_id
     WHERE p_resource_denorm_rec.job_id = job_id
       AND rowid between nvl(p_start_rowid, rowid)
                     and nvl(p_end_rowid, rowid);
Line: 862

     (p_pkg_name       => 'PA_RESOURCE_PVT.update_person_res_denorm_recs'
      ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 868

END update_job_res_denorm_recs;
Line: 877

PROCEDURE delete_resource_denorm
  ( p_person_id                  IN   pa_resources_denorm.person_id%type,
    p_res_effective_start_date   IN   pa_resources_denorm.resource_effective_start_date%type,
    x_return_status              OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data                   OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count                  OUT   NOCOPY NUMBER) --File.Sql.39 bug 4440895
IS
--   l_manager_id       pa_resources_denorm.manager_id%TYPE;
Line: 894

   DELETE FROM PA_RESOURCES_DENORM
   WHERE person_id = p_person_id
     AND resource_effective_start_date = p_res_effective_start_date
     AND resource_effective_end_date > trunc(sysdate);
Line: 904

     ( p_pkg_name       => 'PA_RESOURCE_PVT.delete_resource_denorm'
      ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 908

END delete_resource_denorm;
Line: 937

SELECT jei_information2, jei_information3,jei_information6
  INTO l_billable_flag, l_utilization_flag, l_schedulable_flag
  FROM per_job_extra_info
  WHERE job_id = p_job_id
  AND information_type = l_job_info_type;
Line: 1027

      SELECT date_from,
             date_to
      FROM   per_addresses
      WHERE  person_id                        = l_person_id
      AND    date_from                       <= l_asgn_end_date
      AND    nvl(date_to, l_asgn_end_date)   >= l_asgn_start_date
      AND    primary_flag                     = 'Y'
      ORDER BY date_from
  ;
Line: 1050

    DELETE FROM  pa_resources_denorm
        WHERE  person_id                      = p_resource_source_id
        AND    resource_effective_start_date <= p_assignment_end_date
        AND    resource_effective_end_date   >= p_assignment_start_date
    ;
Line: 1059

    l_resource_job_level := PA_HR_UPDATE_API.Get_Job_Level(
                                           p_job_id => p_resource_job_id,
                                           p_job_group_id => p_resource_job_group_id);
Line: 1072

   l_billable_flag := PA_HR_UPDATE_API.check_job_billability(
                                           p_job_id => p_resource_job_id,
                                           p_person_id => p_resource_source_id,
                                           p_date => p_assignment_start_date);
Line: 1079

    l_utilization_flag := PA_HR_UPDATE_API.check_job_utilization(
                                           p_job_id => p_resource_job_id,
                                           p_person_id => p_resource_source_id,
                                           p_date => p_assignment_start_date);
Line: 1085

    l_schedulable_flag := PA_HR_UPDATE_API.check_job_schedulable
                                          (p_job_id => p_resource_job_id);
Line: 1156

                        INSERT INTO PA_RESOURCES_DENORM ( person_id
                                      , resource_id
                                      , resource_name
                                      , resource_type
                                      , resource_org_id
                                      , resource_organization_id
                                      , resource_country_code
                                      , resource_country
                                      , resource_region
                                      , resource_city
                                      , resource_job_level
                                      , resource_effective_start_date
                                      , resource_effective_end_date
                                      , employee_flag
                                      , manager_id
                                      , manager_name
                                      , billable_flag
                                      , job_id
                                      , utilization_flag
                                      , schedulable_flag
                                      , request_id
                                      , program_application_id
                                      , program_id
                                      , program_update_date
                                      , creation_date
                                      , created_by
                                      , last_update_date
                                      , last_updated_by
                                      , last_update_login
                                      , resource_person_type
                                      )
                              SELECT    p_resource_source_id
                                      , p_resource_id
                                      , p_resource_name
                                      , p_resource_type
                                      , p_resource_org_id
                                      , p_resource_organization_id
                                      , l_resource_country_code
                                      , l_resource_country
                                      , l_resource_region
                                      , l_resource_city
                                      , l_resource_job_level
                                      , l_rec_start_date
                                      , l_rec_end_date
                                      , l_employee_flag
                                      , p_manager_id
                                      , p_manager_name
                                      , l_billable_flag
                                      , p_resource_job_id
                                      , l_utilization_flag
                                      , l_schedulable_flag
                                      , p_request_id
                                      , p_program_application_id
                                      , p_program_id
                                      , sysdate
                                      , sysdate
/*----- Bug 1992257 commented
                                      , TO_NUMBER(FND_PROFILE.VALUE('USER_ID'))
                                      , sysdate
                                      , TO_NUMBER(FND_PROFILE.VALUE('USER_ID'))
                                      , TO_NUMBER(FND_PROFILE.VALUE('LOGIN_ID'))
        End of Comment, added next 4 lines */
                                      , TO_NUMBER(FND_GLOBAL.USER_ID)
                                      , sysdate
                                      , TO_NUMBER(FND_GLOBAL.USER_ID)
                                      , TO_NUMBER(FND_GLOBAL.LOGIN_ID)
                                      , p_person_type
                                FROM  dual;
Line: 1265

	   proceeding on inserting into pa_resources_denorm. This will show the
	   error as an exception in the report output. */
	IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
		IF l_error_msg_code IS NOT NULL THEN
		     pa_utils.add_message
      		      ( p_app_short_name   => 'PA',
			p_msg_name	   => l_error_msg_code);
Line: 1277

     	INSERT INTO PA_RESOURCES_DENORM ( person_id
                                      , resource_id
                                      , resource_name
                                      , resource_type
                                      , resource_org_id
                                      , resource_organization_id
                                      , resource_country_code
                                      , resource_country
                                      , resource_region
                                      , resource_city
                                      , resource_job_level
                                      , resource_effective_start_date
                                      , resource_effective_end_date
                                      , employee_flag
                                      , manager_id
                                      , manager_name
                                      , billable_flag
                                      , job_id
                                      , utilization_flag
                                      , schedulable_flag
                                      , request_id
                                      , program_application_id
                                      , program_id
                                      , program_update_date
                                      , creation_date
                                      , created_by
                                      , last_update_date
                                      , last_updated_by
                                      , last_update_login
                                      , resource_person_type
                                      )
                              SELECT    p_resource_source_id
                                      , p_resource_id
                                      , p_resource_name
                                      , p_resource_type
                                      , p_resource_org_id
                                      , p_resource_organization_id
                                      , l_resource_country_code
                                      , l_resource_country
                                      , l_resource_region
                                      , l_resource_city
                                      , l_resource_job_level
                                      , l_rec_start_date
                                      , l_rec_end_date
                                      , l_employee_flag
                                      , p_manager_id
                                      , p_manager_name
                                      , l_billable_flag
                                      , p_resource_job_id
                                      , l_utilization_flag
                                      , l_schedulable_flag
                                      , p_request_id
                                      , p_program_application_id
                                      , p_program_id
                                      , sysdate
                                      , sysdate
/*----- Bug 1992257 commented
                                      , TO_NUMBER(FND_PROFILE.VALUE('USER_ID'))
                                      , sysdate
                                      , TO_NUMBER(FND_PROFILE.VALUE('USER_ID'))
                                      , TO_NUMBER(FND_PROFILE.VALUE('LOGIN_ID'))
        End of Comment, added next 4 lines */
                                      , TO_NUMBER(FND_GLOBAL.USER_ID)
                                      , sysdate
                                      , TO_NUMBER(FND_GLOBAL.USER_ID)
                                      , TO_NUMBER(FND_GLOBAL.LOGIN_ID)
                                      , p_person_type
                                FROM  dual;
Line: 1428

  SELECT parties.resource_source_id
  INTO l_party_id
  from   pa_project_parties          parties
  where  parties.project_role_id        = 1
  AND  parties.project_id             = p_project_id
  AND  trunc(sysdate) between  parties.start_date_active AND  NVL(parties.end_date_active,trunc(sysdate) + 1)--;
Line: 1440

   select resource_name
   into   g_manager_name
   from   pa_resources_denorm
   where  person_id = l_party_id
   and    trunc(sysdate) between resource_effective_start_date and resource_effective_end_date;
Line: 1446

   select resource_id
   into   g_manager_resource_id
   from   pa_resources_denorm
   where  person_id = l_party_id
   and     trunc(sysdate) between resource_effective_start_date and resource_effective_end_date;
Line: 1523

        select min(start_date)-1
        into l_avl_to_date
        from pa_res_availability
        where resource_id = p_resource_id
          and record_type = 'C'
          and start_date  > p_avl_from_date
          -- Commented for 4725606 and percent     < FND_NUMBER.CANONICAL_TO_NUMBER(fnd_profile.value('PA_RES_CAPACITY_PERCENTAGE'));
Line: 1569

       select min(start_date)-1
       into l_ovc_to_date
       from pa_res_availability
       where resource_id   = p_resource_id
          and record_type  = 'C'
          and start_date   > p_ovc_from_date
          -- Commented for 4725606 and -1 * percent < FND_NUMBER.CANONICAL_TO_NUMBER(fnd_profile.value('PA_OVERCOMMITMENT_PERCENTAGE'));
Line: 1617

        select sum(hours) * -1
        into l_ovc_hours
        from pa_res_availability
        where resource_id       = p_resource_id
        and   record_type       = 'C'
        and   start_date       >= p_ovc_from_date
        and   end_date         <= p_ovc_to_date;
Line: 1747

     SELECT sum(nvl(capacity_quantity,0) - nvl(confirmed_qty,0))
     INTO   l_conf_availability
     FROM   pa_forecast_items
     WHERE  resource_id      = p_resource_id
     AND    delete_flag      = 'N'
     AND    forecast_item_type = 'U'
     AND    item_date  between p_start_date
                       and     p_end_date;
Line: 1779

     SELECT sum(nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))
     INTO   l_prov_conf_availability
     FROM   pa_forecast_items
     WHERE  resource_id      = p_resource_id
     AND    delete_flag      = 'N'
     AND    forecast_item_type = 'U'
     AND    item_date  between p_start_date
                       and     p_end_date;
Line: 1822

l_last_updated_by number;
Line: 1823

l_last_update_login number;
Line: 1836

  l_last_updated_by   := fnd_global.user_id;
Line: 1837

  l_last_update_login := fnd_global.login_id;
Line: 1850

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         ' || '''C''' ||
         ' , resource_id,
         pa_resource_pvt.get_res_conf_availability(resource_id, nvl(item_date,' || '''' || p_cstart_date || ''''||  '),
         nvl((lead(item_date) over(order by item_date)),' || '''' || p_cend_date || ''''||  ') - 1),
         sysdate,
         sysdate,
         ' || l_created_by || ',
         ' || l_last_updated_by || ',
         ' || l_last_update_login || '
    from (  select (nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/nvl(capacity_quantity,0) a,
                    lag((nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/nvl(capacity_quantity,0),1,1000) -- bug 3229929
		               over ( order by item_date) as b,
                   (nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/capacity_quantity c,
                   item_date,
                   resource_id
            from pa_forecast_items
            where forecast_item_type = ' || '''U''' ||
            ' and resource_id = ' || p_resource_id || '
            and capacity_quantity > 0
            and delete_flag = ' || '''N''' || '
            and item_date  between ' || '''' || p_cstart_date || '''' || ' and ' ||
                '''' || p_cend_date || ''''||  ')
    where nvl(a,0) - nvl(b,0) <> 0';
Line: 1892

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         :c,
         resource_id,
         pa_resource_pvt.get_res_conf_availability(resource_id, nvl(item_date, :cstart_date ),
         nvl((lead(item_date) over(order by item_date)), :cend_date ) - 1),
         sysdate,
         sysdate,
         :created_by,
         :last_updated_by,
         :last_update_login
    from (  select (nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/nvl(capacity_quantity,0) a,
                    lag((nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/nvl(capacity_quantity,0),1,1000) -- bug 3229929
		               over ( order by item_date) as b,
                   (nvl(capacity_quantity,0) - nvl(confirmed_qty,0))/capacity_quantity c,
                   item_date,
                   resource_id
            from pa_forecast_items
            where forecast_item_type = :u
            and resource_id = :resource_id
            and capacity_quantity > 0
            and delete_flag = :n
            and item_date  between :cstart_date and :cend_date )
    where nvl(a,0) - nvl(b,0) <> 0' using 'C', p_cstart_date, p_cend_date, l_created_by,
    l_last_updated_by, l_last_update_login, 'U', p_resource_id, 'N', p_cstart_date, p_cend_date;
Line: 1935

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         ' || '''B''' ||
         ' , resource_id,
         pa_resource_pvt.get_res_prov_conf_availability(resource_id, nvl(item_date,' || '''' || p_bstart_date || '''' || '), nvl((lead(item_date) over(order by item_date)),' || '''' || p_bend_date || ''''||  ') - 1),
         sysdate,
         sysdate,
         ' || l_created_by || '  ,
         ' || l_last_updated_by || '  ,
         ' || l_last_update_login || '
    from (  select (nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/nvl(capacity_quantity,0) a,
                   lag((nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/nvl(capacity_quantity,0))
		               over ( order by item_date) as b,
                   (nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/capacity_quantity c,
                   item_date,
                   resource_id
            from pa_forecast_items
            where forecast_item_type = ' || '''U''' ||
            ' and resource_id = ' || p_resource_id || '
            and capacity_quantity > 0
            and delete_flag = ' || '''N''' || '
            and item_date between ' || '''' || p_bstart_date || '''' || ' and ' ||
                '''' || p_bend_date || ''''||  ')
    where nvl(a,0) - nvl(b,0) <> 0';
Line: 1976

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         :b,
         resource_id,
         pa_resource_pvt.get_res_prov_conf_availability(resource_id, nvl(item_date, :bstart_date ), nvl((lead(item_date) over(order by item_date)), :bend_date ) - 1),
         sysdate,
         sysdate,
         :created_by,
         :last_updated_by,
         :last_update_login
    from (  select (nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/nvl(capacity_quantity,0) a,
                   lag((nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/nvl(capacity_quantity,0))
		               over ( order by item_date) as b,
                   (nvl(capacity_quantity,0) - nvl(confirmed_qty,0) - nvl(provisional_qty,0))/capacity_quantity c,
                   item_date,
                   resource_id
            from pa_forecast_items
            where forecast_item_type = :u
            and resource_id = :resource_id
            and capacity_quantity > 0
            and delete_flag = :n
            and item_date between :bstart_date and :bend_date )
    where nvl(a,0) - nvl(b,0) <> 0' using 'B', p_bstart_date, p_bend_date, l_created_by,
    l_last_updated_by, l_last_update_login, 'U', p_resource_id, 'N', p_bstart_date, p_bend_date;
Line: 2016

    update pa_res_availability avl
    set start_date = p_cstart_date
    where resource_id = p_resource_id
    and record_type = 'C'
    and start_date is null;
Line: 2022

    update pa_res_availability avl
    set end_date = p_cend_date
    where resource_id = p_resource_id
    and record_type = 'C'
    and end_date is null;
Line: 2029

    select min(start_date)
    into   l_start_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'C';
Line: 2037

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      and start_date = l_start_date;
Line: 2048

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select min(start_date) - 1,
             min(start_date) - 1,
	         0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      group by 0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2083

    select max(end_date)
    into   l_end_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'C';
Line: 2091

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      and end_date = l_end_date;
Line: 2101

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select max(end_date) + 1,
             max(end_date) + 1,
		     0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      group by 0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2136

    update pa_res_availability avl
    set start_date = p_bstart_date
    where resource_id = p_resource_id
    and record_type = 'B'
    and start_date is null;
Line: 2142

    update pa_res_availability avl
    set end_date = p_bend_date
    where resource_id = p_resource_id
    and record_type = 'B'
    and end_date is null;
Line: 2149

    select min(start_date)
    into   l_start_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'B';
Line: 2157

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      and start_date = l_start_date;
Line: 2169

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select min(start_date) - 1,
             min(start_date) - 1,
	         0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      group by 0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2203

    select max(end_date)
    into   l_end_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'B';
Line: 2211

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      and end_date = l_end_date;
Line: 2222

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select max(end_date) + 1,
             max(end_date) + 1,
		     0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      group by 0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2263

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         ' || '''C''' ||
         ' , resource_id,
         pa_resource_pvt.get_res_conf_availability(resource_id, nvl(item_date,' || '''' || p_cstart_date || '''' || '), nvl((lead(item_date) over(order by item_date)),' || '''' || p_cend_date || ''''||  ') - 1),
         sysdate,
         sysdate,
         ' || l_created_by || ',
         ' || l_last_updated_by || ',
         ' || l_last_update_login || '
    from (
      select (nvl(a1,0) - nvl(a2,0))/nvl(a1,1) a,
             lag((nvl(a1,0) - nvl(a2,0))/nvl(a1,1))
		       over ( order by d) as b,
             (nvl(a1,0) - nvl(a2,0))/nvl(a1,1) c,
             d item_date,
             resource_id
      from (
        select (global_exp_period_end_date - 6) d,
               resource_id,
               sum(capacity_quantity) a1,
               sum(confirmed_qty) a2
        from   pa_forecast_items
        where  forecast_item_type = ' || '''U''' ||
        'and resource_id = ' || p_resource_id || '
        and capacity_quantity > 0
        and delete_flag = ' || '''N''' || '
        and item_date between ' || '''' || p_cstart_date || '''' || ' and ' ||
          '''' || p_cend_date || ''''||
        'group by global_exp_period_end_date - 6,
         resource_id))
    where nvl(a,0) - nvl(b,0) <> 0 ';
Line: 2312

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         :c,
         resource_id,
         pa_resource_pvt.get_res_conf_availability(resource_id, nvl(item_date, :cstart_date), nvl((lead(item_date) over(order by item_date)), :cend_date ) - 1),
         sysdate,
         sysdate,
         :created_by,
         :last_updated_by,
         :last_update_login
    from (
      select (nvl(a1,0) - nvl(a2,0))/nvl(a1,1) a,
             lag((nvl(a1,0) - nvl(a2,0))/nvl(a1,1))
		       over ( order by d) as b,
             (nvl(a1,0) - nvl(a2,0))/nvl(a1,1) c,
             d item_date,
             resource_id
      from (
        select (global_exp_period_end_date - 6) d,
               resource_id,
               sum(capacity_quantity) a1,
               sum(confirmed_qty) a2
        from   pa_forecast_items
        where  forecast_item_type = :u
        and resource_id = :resource_id
        and capacity_quantity > 0
        and delete_flag = :n
        and item_date between :cstart_date and :cend_date
        group by global_exp_period_end_date - 6,
         resource_id))
    where nvl(a,0) - nvl(b,0) <> 0 ' using 'C', p_cstart_date, p_cend_date, l_created_by,
    l_last_updated_by, l_last_update_login, 'U', p_resource_id, 'N', p_cstart_date, p_cend_date;
Line: 2362

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         ' || '''B''' ||
         ' , resource_id,
         pa_resource_pvt.get_res_prov_conf_availability(resource_id, nvl(item_date,' || '''' || p_bstart_date || '''' || '), nvl((lead(item_date) over(order by item_date)),' || '''' || p_bend_date || ''''||  ') - 1),
         sysdate,
         sysdate,
         ' || l_created_by || ',
         ' || l_last_updated_by ||',
         ' || l_last_update_login || '
    from (
      select (nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1) a,
             lag((nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1))
		       over ( order by d) as b,
             (nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1) c,
             d item_date,
             resource_id
      from (
        select (global_exp_period_end_date - 6) d,
               resource_id,
               sum(capacity_quantity) a1,
               sum(confirmed_qty) a2,
               sum(provisional_qty) a3
        from   pa_forecast_items
        where  forecast_item_type = ' || '''U''' ||
        'and resource_id = ' || p_resource_id || '
        and capacity_quantity > 0
        and delete_flag = ' || '''N''' || '
        and item_date between ' || '''' || p_bstart_date || '''' || ' and ' ||
          '''' || p_bend_date || ''''||
        'group by global_exp_period_end_date - 6,
         resource_id))
    where nvl(a,0) - nvl(b,0) <> 0 ';
Line: 2412

    'insert into PA_RES_AVAILABILITY
    ( start_date,
      end_date,
      percent,
      record_type,
      resource_id,
      hours,
      creation_date,
      last_update_date,
      created_by,
	  last_updated_by,
      last_update_login
    )
    select item_date,
         (lead(item_date) over(order by item_date)) - 1,
         c * 100 ,
         :b,
         resource_id,
         pa_resource_pvt.get_res_prov_conf_availability(resource_id, nvl(item_date, :bstart_date ), nvl((lead(item_date) over(order by item_date)), :bend_date ) - 1),
         sysdate,
         sysdate,
         :created_by,
         :last_updated_by,
         :last_update_login
    from (
      select (nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1) a,
             lag((nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1))
		       over ( order by d) as b,
             (nvl(a1,0) - nvl(a2,0) - nvl(a3,0))/nvl(a1,1) c,
             d item_date,
             resource_id
      from (
        select (global_exp_period_end_date - 6) d,
               resource_id,
               sum(capacity_quantity) a1,
               sum(confirmed_qty) a2,
               sum(provisional_qty) a3
        from   pa_forecast_items
        where  forecast_item_type = :u
        and resource_id = :resource_id
        and capacity_quantity > 0
        and delete_flag = :n
        and item_date between :bstart_date and :bend_date
        group by global_exp_period_end_date - 6,
         resource_id))
    where nvl(a,0) - nvl(b,0) <> 0 ' using 'B', p_bstart_date, p_bend_date, l_created_by,
    l_last_updated_by, l_last_update_login, 'U', p_resource_id, 'N', p_bstart_date, p_bend_date;
Line: 2463

    update pa_res_availability avl
    set start_date = p_cstart_date
    where resource_id = p_resource_id
    and record_type = 'C'
    and start_date is null;
Line: 2471

    update pa_res_availability avl
    set end_date = p_cend_date
    where resource_id = p_resource_id
    and record_type = 'C'
    and end_date is null;
Line: 2480

    select min(start_date)
    into   l_start_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'C';
Line: 2489

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      and start_date = l_start_date
      and percent = 0;
Line: 2506

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select min(start_date) - 1,
             min(start_date) - 1,
	         0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      group by 0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2540

    select max(end_date)
    into   l_end_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'C';
Line: 2549

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      and end_date = l_end_date
      and percent = 0;
Line: 2566

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select max(end_date) + 1,
             max(end_date) + 1,
		     0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'C'
      group by 0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2601

    update pa_res_availability avl
    set start_date = p_bstart_date
    where resource_id = p_resource_id
    and record_type = 'B'
    and start_date is null;
Line: 2607

    update pa_res_availability avl
    set end_date = p_bend_date
    where resource_id = p_resource_id
    and record_type = 'B'
    and end_date is null;
Line: 2614

    select min(start_date)
    into   l_start_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'B';
Line: 2623

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      and start_date = l_start_date
      and percent    = 0;
Line: 2639

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select min(start_date) - 1,
             min(start_date) - 1,
	         0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      group by 0,
             record_type,
	         resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2673

    select max(end_date)
    into   l_end_date
    from pa_res_availability
    where resource_id = p_resource_id
    and record_type = 'B';
Line: 2682

      select percent
      into   l_percent
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      and end_date = l_end_date
      and percent = 0;
Line: 2697

      insert into PA_RES_AVAILABILITY
      ( start_date,
        end_date,
        percent,
        record_type,
        resource_id,
	    creation_date,
	    last_update_date,
	    created_by,
	    last_updated_by,
        last_update_login)
      select max(end_date) + 1,
             max(end_date) + 1,
		     0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login
      from pa_res_availability
      where resource_id = p_resource_id
      and record_type = 'B'
      group by 0,
		     record_type,
		     resource_id,
		     sysdate,
		     sysdate,
		     l_created_by,
		     l_last_updated_by,
             l_last_update_login;
Line: 2749

  select min(RESOURCE_EFFECTIVE_START_DATE)
  into   l_earliest_start_date
  from   pa_resources_denorm
  where  RESOURCE_ID        = p_resource_id;
Line: 2754

  update pa_res_availability
    set  start_date  = l_earliest_start_date
  where  resource_id = p_resource_id
  and    start_date  <  l_earliest_start_date
  and    percent     > 0;
Line: 2760

  select count(*)
  into   l_rec_count
  from pa_res_availability
  where  resource_id = p_resource_id
  and    start_date  <  l_earliest_start_date
  and    record_type = 'B'
  and    percent     = 0;
Line: 2770

    delete
    from pa_res_availability
    where  resource_id = p_resource_id
    and    start_date  <  l_earliest_start_date - 1
    and    record_type = 'B'
    and    percent     = 0;
Line: 2779

  select count(*)
  into   l_rec_count
  from pa_res_availability
  where  resource_id = p_resource_id
  and    start_date  <  l_earliest_start_date
  and    record_type = 'C'
  and    percent     = 0;
Line: 2789

    delete
    from pa_res_availability
    where  resource_id = p_resource_id
    and    start_date  <  l_earliest_start_date - 1
    and    record_type = 'C'
    and    percent     = 0;
Line: 2798

  update pa_res_availability
    set  start_date = l_earliest_start_date -1,
         end_date   = l_earliest_start_date -1
  where  resource_id = p_resource_id
  and    start_date  <  l_earliest_start_date
  and    percent     = 0;
Line: 2824

PROCEDURE update_res_availability (
  p_resource_id   IN NUMBER,
  p_start_date    IN DATE,
  p_end_date      IN DATE,
  x_return_status OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
  x_msg_data      OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
  x_msg_count     OUT   NOCOPY NUMBER ) --File.Sql.39 bug 4440895
IS

  l_msg_index_out number;
Line: 2844

   PA_DEBUG.init_err_stack('PA_RESOURCE_PVT.Update_Res_Availability');
Line: 2851

     select min(resource_effective_start_date)
     into   l_start_date
     from pa_resources_denorm
     where resource_id = p_resource_id;
Line: 2857

     select max(resource_effective_end_date)
     into   l_end_date
     from pa_resources_denorm
     where resource_id = p_resource_id;
Line: 2869

   delete
   from pa_res_availability
   where resource_id = p_resource_id;
Line: 2911

       (p_pkg_name       => 'PA_RESOURCE_PVT.Update_Res_Availability'
       ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2918

END Update_Res_Availability;
Line: 2934

  select resource_id,
       min(resource_effective_start_date) start_date,
	   max(resource_effective_end_date) end_date
  from pa_resources_denorm
  group by resource_id;
Line: 2941

  select resource_id
  from pa_res_availability
  where resource_id not in (Select resource_id from pa_resources_denorm)
  and resource_id <> -1;
Line: 2956

     delete
      from PA_RES_AVAILABILITY where RESOURCE_ID = rec.resource_id;
Line: 2977

      delete
      from PA_RES_AVAILABILITY where RESOURCE_ID = rec.resource_id;  --Added for bug 4928773
Line: 3003

   delete
   from PA_RES_AVAILABILITY where RESOURCE_ID = -1;      --Added for bug 4928773
Line: 3006

   INSERT
   INTO PA_RES_AVAILABILITY
   (
     RESOURCE_ID,
     START_DATE,
     RECORD_TYPE,
     CREATION_DATE,
     CREATED_BY,
     LAST_UPDATE_DATE,
     LAST_UPDATED_BY
   )
   VALUES
   (
     -1,
     sysdate,
     decode(l_profile, 'DAILY', 'D', 'W'),
     sysdate,
     -1,
     sysdate,
     -1
   );