Sunday, January 24, 2021

PER POSITIONS API - hr_position_api.create_position

DECLARE

   CURSOR l_data

   IS

      SELECT position_id,

             business_group_id,

             (SELECT new_job_id

                FROM xx.xx_per_jobs pj

               WHERE pj.job_name = xpp.job_name)

                job_id,

             job_name,

             organization_id,

             POSITION_DEFINITION_ID,

             date_effective,

             date_end,

             frequency,

             name,

             REPLACEMENT_REQUIRED_FLAG,

             TIME_NORMAL_FINISH,

             TIME_NORMAL_START,

             WORKING_HOURS,

             attribute1,

             new_position_id,

             new_position_definition_id,

             new_position_name

        FROM XX.XX_PER_POSITIONS xpp

       WHERE NEW_POSITION_ID IS  NULL ;


   lv_position_name            VARCHAR2 (500);

   ln_position_definition_id   NUMBER ;

   ln_object_version_number    NUMBER:=1;

   ln_position_id              NUMBER ;

BEGIN

   FOR n_data IN l_data

   LOOP

   

   lv_position_name :=NULL;

   ln_position_definition_id:=NULL;

   ln_object_version_number :=NULL;

   ln_position_id    :=NULL;

   

   DBMS_OUTPUT.PUT_LINE(n_data.job_id||  ','  ||n_data.name ||  ','  || n_data.date_effective||  ','  ||n_data.FREQUENCY );

   

      hr_position_api.create_position (

         p_validate                    => FALSE, -- If it was set as true, only         validation will happen.

         p_job_id                      => n_data.job_id,             -- Job id

         p_organization_id             => n_data.organization_id, -- Business Group id

         p_date_effective              => TO_DATE('01-01-1996','DD-MM-YYYY'),

         p_date_end                    => n_data.date_end,

         p_frequency                   => n_data.FREQUENCY,

         p_segment1                    => n_data.name,

         p_replacement_required_flag   => n_data.REPLACEMENT_REQUIRED_FLAG,

         p_time_normal_finish          => n_data.TIME_NORMAL_FINISH,

         p_time_normal_start           => n_data.TIME_NORMAL_START,

         p_working_hours               => n_data.WORKING_HOURS,

         p_attribute1                  => n_data.attribute1,

         p_status                      => NULL,

         p_position_id                 => ln_position_id,

         p_object_version_number       => ln_object_version_number,

         p_position_definition_id      => ln_position_definition_id,

         p_name                        => lv_position_name);


IF  ln_position_id IS NOT NULL THEN


      UPDATE XX.XX_PER_POSITIONS

         SET NEW_POSITION_ID = ln_position_id,

             NEW_POSITION_DEFINITION_ID = ln_position_definition_id,

             NEW_POSITION_NAME = lv_position_name

       WHERE position_id = n_data.position_id;


    COMMIT;

    

END IF;    

   END LOOP;

END;

No comments:

Post a Comment