Monday, June 2, 2014

API to Create External Learning

DECLARE
   l_nota_history_id         NUMBER := NULL;
   l_object_version_number   NUMBER := NULL;
   l_some_warning            BOOLEAN := NULL;
   l_duration                NUMBER := NULL;

   CURSOR c1
   IS
      SELECT 98364 person_id,
             1107 business_group_id,
             TO_CHAR (TO_DATE ('01-MAY-2014'), 'YYYY/MM/DD HH24:MI:SS')
                date_from,
             TO_DATE ('01-MAY-2014') date_to,
             'Loading Data with API II' course
        FROM DUAL;
BEGIN
   FOR i IN c1
   LOOP
      l_nota_history_id := NULL;
      l_object_version_number := NULL;
      l_some_warning := NULL;

      BEGIN
         l_duration :=
            (TO_DATE (i.date_from, 'YYYY/MM/DD HH24:MI:SS') - i.date_to) + 1;

         ota_nhs_api.
          create_non_ota_histories (
            p_validate                => FALSE,
            p_effective_date          => SYSDATE,
            p_nota_history_id         => l_nota_history_id,
            p_person_id               => i.person_id,
            p_trng_title              => i.course,
            p_provider                => '.',
            p_completion_date         => i.date_to,
            p_duration                => l_duration,
            p_duration_units          => 'D',
            p_nth_information2        => i.date_from,
            p_object_version_number   => l_object_version_number,
            p_business_group_id       => i.business_group_id,
            p_some_warning            => l_some_warning);

         COMMIT;

         DBMS_OUTPUT.
          put_line (
            l_nota_history_id || ' has been created Successfully !!!');
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line (
               'Inner Exception: ' || SQLERRM || ' - ' || i.person_id);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);

END;

No comments:

Post a Comment