Tuesday, December 13, 2016

API to Create User Table Rows


DECLARE
   l_user_table_id           NUMBER := NULL;
   l_object_version_number   NUMBER := NULL;
   l_display_sequence        NUMBER := 10;
   l_user_row_id             NUMBER := NULL;
   l_effective_start_date    DATE := NULL;
   l_effective_end_date      DATE := NULL;

   CURSOR c1
   IS
      SELECT pbg.business_group_id, pbg.name entity
        FROM per_business_groups pbg
       WHERE pbg.business_group_id = 81;
BEGIN
   FOR i IN c1
   LOOP
      l_user_table_id := NULL;
      l_user_row_id := NULL;
      l_object_version_number := NULL;
      l_effective_start_date := NULL;
      l_effective_end_date := NULL;

      SELECT user_table_id
        INTO l_user_table_id
        FROM pay_user_tables
       WHERE     user_table_name = 'XXHR_USER_HOOKS'
             AND business_group_id = i.business_group_id;


      BEGIN
         pay_user_row_api.create_user_row (
            p_validate                     => FALSE,
            p_effective_date               => '01-JAN-1951',
            p_user_table_id                => l_user_table_id,
            p_row_low_range_or_name        => 'VALIDATE_EMIRATES_ID',
            p_display_sequence             => l_display_sequence,
            p_business_group_id            => i.business_group_id,
            p_user_row_id                  => l_user_row_id,
            p_object_version_number        => l_object_version_number,
            p_effective_start_date         => l_effective_start_date,
            p_effective_end_date           => l_effective_end_date,
            p_base_row_low_range_or_name   => 'VALIDATE_EMIRATES_ID');
         COMMIT;
         DBMS_OUTPUT.put_line (
            l_user_row_id || ' has been Created --> ' || i.business_group_id);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (i.business_group_id || '--> Failed!');
      END;
   END LOOP;

END;

No comments:

Post a Comment