DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGS_UC_LOAD_HERCULES_DATA

Source


1 PACKAGE BODY igs_uc_load_hercules_data AS
2 /* $Header: IGSUC42B.pls 120.10 2006/08/21 06:18:28 jbaber ship $  */
3 
4 
5   -- global cursors and variables
6      -- Get the cycle information from defaults
7      CURSOR c_cyc_info IS
8      SELECT MAX(current_cycle) current_cycle , MAX(configured_cycle) configured_cycle
9      FROM   igs_uc_defaults ;
10      g_cyc_info_rec         c_cyc_info%ROWTYPE ;
11 
12      CURSOR c_ucas_cycle (cp_system_code igs_uc_ucas_control.system_code%TYPE) IS
13      SELECT entry_year
14      FROM igs_uc_ucas_control
15      WHERE system_code = cp_system_code
16      AND ucas_cycle = g_cyc_info_rec.configured_cycle;
17      c_ucas_cycle_rec  c_ucas_cycle%ROWTYPE ;
18 
19      -- Cursor to get the UCAS_INTERFACE
20      CURSOR c_ucas_interface (cp_system_code igs_uc_cyc_defaults.system_code%TYPE) IS
21      SELECT ucas_interface
22      FROM IGS_UC_CYC_DEFAULTS
23      WHERE system_code = cp_system_code
24      AND ucas_cycle = g_cyc_info_rec.configured_cycle;
25      c_ucas_interface_rec    igs_uc_cyc_defaults.ucas_interface%TYPE;
26 
27      -- get the timestamp value of the hercules views from cvrefammendment
28      -- modified by jbaber
29      --    added country and nationality so that 2003 version looks like 2007 version
30      --    this allows us to base the global variable on 2007 version of refamendments
31      CURSOR c_refamend_timestamp IS
32      SELECT aprdate, disdate, errordate, ethnicdate, examdate, feedate,
33             keyworddate, oeqdate, offerabbrevdate, offersubjdate, poccdate,
34             rescatdate, awardbodydate, statusdate, ucasgroupdate, estabgroup,
35             schooltype, tariffdate, jointadmissions,
36             sysdate AS COUNTRY, sysdate AS NATIONALITY
37      FROM igs_uc_u_cvrefamendments_2003 a;
38 
39      CURSOR c_refamend_timestamp_2007 IS
40      SELECT aprdate, disdate, errordate, ethnicdate, examdate, feedate,
41             keyworddate, oeqdate, offerabbrevdate, offersubjdate, poccdate,
42             rescatdate, awardbodydate, statusdate, ucasgroupdate, estabgroup,
43             schooltype, tariffdate, jointadmissions, country, nationality
44      FROM igs_uc_u_cvrefamendments_2007 ;
45      g_refamend_timestamp   c_refamend_timestamp_2007%ROWTYPE ;
46 
47      -- Added GTTR timestamp value of the hercules views from cvgrefamendments
48      -- for bug 4638126
49      CURSOR c_grefamend_timestamp IS
50      SELECT *
51      FROM igs_uc_g_cvgrefamendments_2006;
52      g_grefamend_timestamp   c_grefamend_timestamp%ROWTYPE ;
53 
54      -- variable declarations
55      g_sync_reqd            BOOLEAN;
56 
57 
58    PROCEDURE write_to_log(p_message    IN VARCHAR2)
59    IS
60     /******************************************************************
61      Created By      :  smaddali
62      Date Created By :   11-Jun-03
63      Purpose         :   writes the passed message into the log file
64      Known limitations,enhancements,remarks:
65      Change History
66      Who       When         What
67     ***************************************************************** */
68    BEGIN
69 
70       Fnd_File.Put_Line(Fnd_File.Log, p_message);
71 
72    END write_to_log;
73 
74 
75   PROCEDURE herc_timestamp_exists ( p_view IN igs_uc_hrc_timstmps.view_name%TYPE ,
76                                     p_herc_timestamp OUT NOCOPY igs_uc_hrc_timstmps.timestamp%TYPE )  IS
77     /******************************************************************
78      Created By      :  smaddali
79      Date Created By :   11-Jun-03
80      Purpose         :   checks if the timestamp record for the passed view exists or not
81      Known limitations,enhancements,remarks:
82      Change History
83      Who       When         What
84     ***************************************************************** */
85 
86     -- Get the timestamp value for the passed view for the passed ucas cycle
87     CURSOR c_timestamp IS
88     SELECT hrc.timestamp
89     FROM igs_uc_hrc_timstmps hrc
90     WHERE view_name = p_view
91      AND  ucas_cycle = g_cyc_info_rec.configured_cycle ;
92     c_timestamp_rec c_timestamp%ROWTYPE ;
93 
94     l_rowid VARCHAR2(50) ;
95 
96   BEGIN
97 
98       -- if timestamp record exists for this view then return true else return false
99       c_timestamp_rec := NULL ;
100       OPEN c_timestamp ;
101       FETCH c_timestamp INTO c_timestamp_rec ;
102       IF c_timestamp%NOTFOUND THEN
103           p_herc_timestamp := NULL ;
104       ELSE
105            p_herc_timestamp := c_timestamp_rec.timestamp ;
106       END IF ;
107       CLOSE c_timestamp ;
108       RETURN  ;
109 
110 
111   EXCEPTION
112       WHEN OTHERS THEN
113                ROLLBACK;
114                write_to_log(SQLERRM);
115                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
116                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.HERC_TIMESTAMP_EXISTS');
117                igs_ge_msg_stack.add;
118                app_exception.raise_exception ;
119   END herc_timestamp_exists;
120 
121 
122   PROCEDURE ins_upd_timestamp( p_view IN igs_uc_hrc_timstmps.view_name%TYPE ,
123                                p_new_max_timestamp IN igs_uc_hrc_timstmps.timestamp%TYPE )
124   IS
125     /******************************************************************
126      Created By      :  smaddali
127      Date Created By :   11-Jun-03
128      Purpose         :   inserts/updates hercules timestamp record for passed view
129      Known limitations,enhancements,remarks:
130      Change History
131      Who       When         What
132     ***************************************************************** */
133 
134     l_rowid VARCHAR2(50) ;
135 
136   BEGIN
137 
138       -- Initializations
139       l_rowid := NULL ;
140 
141       -- if timestamp record is not found for this view in passed cycle then insert new record with the passed timestamp
142       -- else update its timestamp value with the passed timestamp
143           igs_uc_hrc_timstmps_pkg.add_row(
144                       x_rowid           => l_rowid,
145                       x_view_name       => p_view ,
146                       x_ucas_cycle      => g_cyc_info_rec.configured_cycle ,
147                       x_timestamp       => p_new_max_timestamp,
148                       x_mode            => 'R' );
149 
150           RETURN  ;
151 
152   EXCEPTION
153       WHEN OTHERS THEN
154                ROLLBACK;
155                write_to_log(SQLERRM);
156                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
157                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.INS_UPD_TIMESTAMP');
158                igs_ge_msg_stack.add;
159                app_exception.raise_exception ;
160   END ins_upd_timestamp;
161 
162 
163   PROCEDURE log_start ( p_view_name VARCHAR2)
164   IS
165    /******************************************************************
166      Created By      :  smaddali
167      Date Created By :   11-Jun-03
168      Purpose         :   logs messages of start of loading views
169      Known limitations,enhancements,remarks:
170      Change History
171      Who       When         What
172     ***************************************************************** */
173   BEGIN
174        -- log message that this view is being loaded
175        fnd_message.set_name('IGS','IGS_UC_VW_PROCESSING' );
176        fnd_message.set_token('VIEW_NAME', p_view_name ||TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
177        fnd_file.put_line(fnd_file.Log, fnd_message.get);
178 
179   EXCEPTION
180       WHEN OTHERS THEN
181                ROLLBACK;
182                write_to_log(SQLERRM);
183                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
184                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOG_START');
185                igs_ge_msg_stack.add;
186                app_exception.raise_exception ;
187   END log_start;
188 
189   PROCEDURE log_complete (  p_view_name VARCHAR2 ,
190                 p_count NUMBER )
191   IS
192    /******************************************************************
193      Created By      :  smaddali
194      Date Created By :   11-Jun-03
195      Purpose         :   logs messages of completion of loading views
196      Known limitations,enhancements,remarks:
197      Change History
198      Who       When         What
199     ***************************************************************** */
200   BEGIN
201        -- log message that this view has been succesfully loaded
202        fnd_message.set_name('IGS','IGS_UC_VW_SYNC_COMPLETE' );
203        fnd_message.set_token('VIEW_NAME', p_view_name );
204        fnd_file.put_line(fnd_file.Log, fnd_message.get ) ;
205 
206        -- log message that p_count number of records have been processed
207        fnd_message.set_name('IGS','IGS_UC_REC_CNT_PROC' );
208        fnd_message.set_token('REC_CNT', p_count );
209        fnd_file.put_line(fnd_file.Log, fnd_message.get ) ;
210 
211 
212   EXCEPTION
213       WHEN OTHERS THEN
214                ROLLBACK;
215                write_to_log(SQLERRM);
216                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
217                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOG_COMPLETE');
218                igs_ge_msg_stack.add;
219                app_exception.raise_exception ;
220   END log_complete;
221 
222 
223   PROCEDURE log_already_insync(  p_view_name VARCHAR2)
224   IS
225    /******************************************************************
226      Created By      :  smaddali
227      Date Created By :   11-Jun-03
228      Purpose         :   logs messages of completion of loading views
229      Known limitations,enhancements,remarks:
230      Change History
231      Who       When         What
232     ***************************************************************** */
233   BEGIN
234        -- log message that this view has been succesfully loaded
235        fnd_message.set_name('IGS','IGS_UC_VW_ALREADY_IN_SYNC' );
236        fnd_message.set_token('VIEW_NAME', p_view_name );
237        fnd_file.put_line(fnd_file.Log, fnd_message.get) ;
238 
239   EXCEPTION
240       WHEN OTHERS THEN
241                ROLLBACK;
242                write_to_log(SQLERRM);
243                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
244                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOG_ALREADY_INSYNC');
245                igs_ge_msg_stack.add;
246                app_exception.raise_exception ;
247   END log_already_insync;
248 
249 
250   PROCEDURE get_appno (p_appno_in       IN  VARCHAR2,
251                        p_checkdigit_in  IN  VARCHAR2,
252                        p_appno_out      OUT NOCOPY NUMBER,
253                        p_checkdigit_out OUT NOCOPY NUMBER ) IS
254     /******************************************************************
255      Created By      :  jbaber
256      Date Created By :  12-Jul-05
257      Purpose         :  return appno and checkdigit according to configured year
258      Known limitations,enhancements,remarks:
259      Change History
260      Who       When         What
261     ***************************************************************** */
262 
263   BEGIN
264 
265 
266       -- Check configure year
267       IF g_cyc_info_rec.configured_cycle < 2006 THEN
268           -- If 2003-2005 appno_out = appno_in
269           p_appno_out := p_appno_in;
270           p_checkdigit_out := p_checkdigit_in;
271       ELSE
272           -- If 2006(+) must extract appno and check_digit
273           p_appno_out := TO_NUMBER(SUBSTR(LPAD(p_appno_in,9,0),1,8));
274           p_checkdigit_out := TO_NUMBER(SUBSTR(LPAD(p_appno_in,9,0),9,1));
275 
276       END IF;
277 
278   EXCEPTION
279       WHEN OTHERS THEN
280                ROLLBACK;
281                write_to_log(SQLERRM);
282                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
283                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.GET_APPNO');
284                igs_ge_msg_stack.add;
285                app_exception.raise_exception ;
286 
287   END get_appno;
288 
289 
290   FUNCTION is_valid(  p_value      VARCHAR2,
291                       p_viewname   VARCHAR2,
292                       p_fieldname  VARCHAR2,
293                       p_datatype   VARCHAR2
294                      ) RETURN BOOLEAN AS
295 
296     /*
297     ||  Created By : jbaber
298     ||  Created On :
299     ||  Purpose    : function which return TRUE if the passed value
300     ||               can be convertable into NUMBER else return FALSE and logs error.
301     ||  Known limitations, enhancements or remarks :
302     ||  Change History :
303     ||  Who             When            What
304     ||  (reverse chronological order - newest change first)
305     */
306     return_value        BOOLEAN         := FALSE;
307     ln_number           NUMBER;
308 
309   BEGIN
310 
311     -- Check whether the passed value can be convertable to number of not.
312     -- If the value can not be convertable to number catch the exception and return FALSE.
313     BEGIN
314       ln_number := TO_NUMBER(p_value);
315       return_value := TRUE;
316 
317     EXCEPTION
318       WHEN VALUE_ERROR THEN
319         -- log message that this line has not been loaded
320     fnd_message.set_name('IGS','IGS_UC_VAR_VALIDATE' );
321     fnd_message.set_token('VIEW_NAME', p_viewname);
322     fnd_message.set_token('FIELD_NAME', p_fieldname );
323     fnd_message.set_token('FIELD_VALUE', p_value );
324     fnd_message.set_token('DATA_TYPE',p_datatype);
325         fnd_file.put_line(fnd_file.Log, fnd_message.get ) ;
326 
327         return_value := FALSE;
328     END;
329 
330     RETURN return_value;
331 
332   EXCEPTION
333     WHEN OTHERS THEN
334       fnd_message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
335       fnd_message.set_token('NAME','IGS_UC_LOAD_HERCULES_DATA.IS_VALID - '||SQLERRM);
336       igs_ge_msg_stack.add;
337       app_exception.raise_exception;
338 
339   END is_valid;
340 
341 
342   PROCEDURE load_cvcourse_2003 IS
343     /******************************************************************
344      Created By      :  smaddali
345      Date Created By :   11-Jun-03
346      Purpose         :   loads each record in the hercules view CVCOURSE into the interface table
347                          igs_uc_ccrse_ints with record status N
348      Known limitations,enhancements,remarks:
349      Change History
350      Who       When         What
351      jbaber    15-Sep-05    Replace campus value with '*' if NULL for bug 4589994
352      jbaber    11-Jul-06    Added system_code field to igs_uc_ccrse_ints
353     ***************************************************************** */
354 
355       -- Get all the records from hercules  view whose timestamp is > passed timestamp
356       -- or get all the records in hercules view if the timestamp passed is null
357       CURSOR c_cvcourse( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
358       SELECT DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
359           ,DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
360           ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
361           ,timestamp
362           ,RTRIM(faculty) faculty
363           ,RTRIM(shortname) shortname
364           ,RTRIM(longname) longname
365           ,RTRIM(validcurrent) validcurrent
366           ,RTRIM(validdefer) validdefer
367           ,RTRIM(jointadmission) jointadmission
368           ,RTRIM(openextra) openextra
369       FROM igs_uc_u_cvcourse_2003
370       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
371 
372       -- get the max timestamp value of the hercules view
373       CURSOR c_max_timestamp IS
374       SELECT MAX(timestamp)
375       FROM igs_uc_u_cvcourse_2003 ;
376 
377       -- Variables
378       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
379       l_new_max_timestamp igs_uc_u_cvcourse_2003.timestamp%TYPE ;
380       l_count NUMBER ;
381 
382   BEGIN
383        -- set syncronization required to false
384        g_sync_reqd := FALSE;
385        l_count := 0 ;
386 
387       -- log message that this view is being loaded
388        log_start('CVCOURSE ON ') ;
389 
390       -- Get the old timestamp for this view in the configured cycle
391       Herc_timestamp_exists('CVCOURSE', p_old_timestamp) ;
392 
393        -- create interface records for each record in the hercules view whose timestamp > old timestamp
394        FOR c_cvcourse_rec IN c_cvcourse(p_old_timestamp) LOOP
395               -- set x_sync_read to true if the loop is entered even once
396               g_sync_reqd := TRUE;
397 
398               -- Obsolete matching records in interface table with status N
399               UPDATE igs_uc_ccrse_ints SET record_status = 'O'
400               WHERE record_status = 'N' AND course = c_cvcourse_rec.course
401               AND campus = c_cvcourse_rec.campus AND inst = c_cvcourse_rec.inst ;
402 
403               -- copy hercules record into interface table with record status N
404               INSERT INTO igs_uc_ccrse_ints (    inst,
405                                                  course,
406                                                  campus,
407                                                  faculty,
408                                                  shortname,
409                                                  longname,
410                                                  validcurrent,
411                                                  validdefer,
412                                                  jointadmission,
413                                                  openextra,
414                                                  system_code,
415                                                  record_status,
416                                                  error_code  )
417                                      VALUES (    c_cvcourse_rec.inst,
418                                                  c_cvcourse_rec.course,
419                                                  c_cvcourse_rec.campus,
420                                                  c_cvcourse_rec.faculty,
421                                                  c_cvcourse_rec.shortname,
422                                                  c_cvcourse_rec.longname,
423                                                  c_cvcourse_rec.validcurrent,
424                                                  c_cvcourse_rec.validdefer,
425                                                  c_cvcourse_rec.jointadmission,
426                                                  c_cvcourse_rec.openextra,
427                                                  'U',
428                                                  'N',
429                                                  NULL) ;
430               -- increment count of records
431               l_count := l_count + 1;
432 
433        END LOOP ;
434 
435        IF g_sync_reqd THEN
436               -- get the max timestamp of this hercules view
437               OPEN c_max_timestamp ;
438               FETCH c_max_timestamp INTO l_new_max_timestamp ;
439               CLOSE c_max_timestamp ;
440 
441                -- update /insert the timestamp record with new max timestamp
442                ins_upd_timestamp ('CVCOURSE',l_new_max_timestamp) ;
443 
444                -- log message that this view has been loaded
445                log_complete('CVCOURSE', l_count) ;
446        ELSE
447                 -- log message that this view is already in sync and need not be loaded
448                log_already_insync('CVCOURSE') ;
449        END IF ;
450        COMMIT;
451 
452     EXCEPTION
453       WHEN OTHERS THEN
454                ROLLBACK;
455                write_to_log(SQLERRM);
456                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
457                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVCOURSE_2003');
458                igs_ge_msg_stack.add;
459                app_exception.raise_exception ;
460   END   load_cvcourse_2003  ;
461 
462 
463   PROCEDURE load_cvgcourse_2007 IS
464     /******************************************************************
465      Created By      :   jbaber
466      Date Created By :   11-Jun-06
467      Purpose         :   loads each record in the hercules view CVGCOURSE into the interface table
468                          igs_uc_ccrse_ints with record status N
469      Known limitations,enhancements,remarks:
470      Change History
471      Who       When         What
472     ***************************************************************** */
473 
474       -- Get all the records from hercules  view whose timestamp is > passed timestamp
475       -- or get all the records in hercules view if the timestamp passed is null
476       CURSOR c_cvgcourse( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
477       SELECT DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
478           ,DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
479           ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
480           ,timestamp
481           ,RTRIM(SUBSTR(longname,1,20)) shortname
482           ,RTRIM(longname) longname
483       FROM igs_uc_g_cvgcourse_2007
484       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
485 
486       -- get the max timestamp value of the hercules view
487       CURSOR c_max_timestamp IS
488       SELECT MAX(timestamp)
489       FROM igs_uc_g_cvgcourse_2007 ;
490 
491       -- Variables
492       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
493       l_new_max_timestamp igs_uc_g_cvgcourse_2007.timestamp%TYPE ;
494       l_count NUMBER ;
495 
496   BEGIN
497        -- set syncronization required to false
498        g_sync_reqd := FALSE;
499        l_count := 0 ;
500 
501       -- log message that this view is being loaded
502        log_start('CVGCOURSE ON ') ;
503 
504       -- Get the old timestamp for this view in the configured cycle
505       Herc_timestamp_exists('CVGCOURSE', p_old_timestamp) ;
506 
507        -- create interface records for each record in the hercules view whose timestamp > old timestamp
508        FOR c_cvgcourse_rec IN c_cvgcourse(p_old_timestamp) LOOP
509               -- set x_sync_read to true if the loop is entered even once
510               g_sync_reqd := TRUE;
511 
512               -- Obsolete matching records in interface table with status N
513               UPDATE igs_uc_ccrse_ints SET record_status = 'O'
514               WHERE record_status = 'N' AND course = c_cvgcourse_rec.course
515               AND campus = c_cvgcourse_rec.campus AND inst = c_cvgcourse_rec.inst ;
516 
517               -- copy hercules record into interface table with record status N
518               INSERT INTO igs_uc_ccrse_ints (    inst,
519                                                  course,
520                                                  campus,
521                                                  shortname,
522                                                  longname,
523                                                  system_code,
524                                                  record_status,
525                                                  error_code  )
526                                      VALUES (    c_cvgcourse_rec.inst,
527                                                  c_cvgcourse_rec.course,
528                                                  c_cvgcourse_rec.campus,
529                                                  c_cvgcourse_rec.shortname,
530                                                  c_cvgcourse_rec.longname,
531                                                  'G',
532                                                  'N',
533                                                  NULL) ;
534               -- increment count of records
535               l_count := l_count + 1;
536 
537        END LOOP ;
538 
539        IF g_sync_reqd THEN
540               -- get the max timestamp of this hercules view
541               OPEN c_max_timestamp ;
542               FETCH c_max_timestamp INTO l_new_max_timestamp ;
543               CLOSE c_max_timestamp ;
544 
545                -- update /insert the timestamp record with new max timestamp
546                ins_upd_timestamp ('CVGCOURSE',l_new_max_timestamp) ;
547 
548                -- log message that this view has been loaded
549                log_complete('CVGCOURSE', l_count) ;
550        ELSE
551                 -- log message that this view is already in sync and need not be loaded
552                log_already_insync('CVGCOURSE') ;
553        END IF ;
554        COMMIT;
555 
556     EXCEPTION
557       WHEN OTHERS THEN
558                ROLLBACK;
559                write_to_log(SQLERRM);
560                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
561                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVGCOURSE_2007');
562                igs_ge_msg_stack.add;
563                app_exception.raise_exception ;
564   END   load_cvgcourse_2007  ;
565 
566 
567   PROCEDURE load_cvncourse_2007 IS
568     /******************************************************************
569      Created By      :   jbaber
570      Date Created By :   11-Jun-06
571      Purpose         :   loads each record in the hercules view CVNCOURSE into the interface table
572                          igs_uc_ccrse_ints with record status N
573      Known limitations,enhancements,remarks:
574      Change History
575      Who       When         What
576     ***************************************************************** */
577 
578       -- Get all the records from hercules  view whose timestamp is > passed timestamp
579       -- or get all the records in hercules view if the timestamp passed is null
580       CURSOR c_cvncourse( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
581       SELECT DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
582           ,DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
583           ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
584           ,timestamp
585           ,RTRIM(shortname) shortname
586           ,RTRIM(longname) longname
587       FROM igs_uc_n_cvncourse_2007
588       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
589 
590       -- get the max timestamp value of the hercules view
591       CURSOR c_max_timestamp IS
592       SELECT MAX(timestamp)
593       FROM igs_uc_n_cvncourse_2007 ;
594 
595       -- Variables
596       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
597       l_new_max_timestamp igs_uc_n_cvncourse_2007.timestamp%TYPE ;
598       l_count NUMBER ;
599 
600   BEGIN
601        -- set syncronization required to false
602        g_sync_reqd := FALSE;
603        l_count := 0 ;
604 
605       -- log message that this view is being loaded
606        log_start('CVNCOURSE ON ') ;
607 
608       -- Get the old timestamp for this view in the configured cycle
609       Herc_timestamp_exists('CVNCOURSE', p_old_timestamp) ;
610 
611        -- create interface records for each record in the hercules view whose timestamp > old timestamp
612        FOR c_cvncourse_rec IN c_cvncourse(p_old_timestamp) LOOP
613               -- set x_sync_read to true if the loop is entered even once
614               g_sync_reqd := TRUE;
615 
616               -- Obsolete matching records in interface table with status N
617               UPDATE igs_uc_ccrse_ints SET record_status = 'O'
618               WHERE record_status = 'N' AND course = c_cvncourse_rec.course
619               AND campus = c_cvncourse_rec.campus AND inst = c_cvncourse_rec.inst ;
620 
621               -- copy hercules record into interface table with record status N
622               INSERT INTO igs_uc_ccrse_ints (    inst,
623                                                  course,
624                                                  campus,
625                                                  shortname,
626                                                  longname,
627                                                  system_code,
628                                                  record_status,
629                                                  error_code  )
630                                      VALUES (    c_cvncourse_rec.inst,
631                                                  c_cvncourse_rec.course,
632                                                  c_cvncourse_rec.campus,
633                                                  c_cvncourse_rec.shortname,
634                                                  c_cvncourse_rec.longname,
635                                                  'N',
636                                                  'N',
637                                                  NULL) ;
638               -- increment count of records
639               l_count := l_count + 1;
640 
641        END LOOP ;
642 
643        IF g_sync_reqd THEN
644               -- get the max timestamp of this hercules view
645               OPEN c_max_timestamp ;
646               FETCH c_max_timestamp INTO l_new_max_timestamp ;
647               CLOSE c_max_timestamp ;
648 
649                -- update /insert the timestamp record with new max timestamp
650                ins_upd_timestamp ('CVNCOURSE',l_new_max_timestamp) ;
651 
652                -- log message that this view has been loaded
653                log_complete('CVNCOURSE', l_count) ;
654        ELSE
655                 -- log message that this view is already in sync and need not be loaded
656                log_already_insync('CVNCOURSE') ;
657        END IF ;
658        COMMIT;
659 
660     EXCEPTION
661       WHEN OTHERS THEN
662                ROLLBACK;
663                write_to_log(SQLERRM);
664                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
665                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVNCOURSE_2007');
666                igs_ge_msg_stack.add;
667                app_exception.raise_exception ;
668   END   load_cvncourse_2007  ;
669 
670 
671   PROCEDURE load_cveblsubject_2003 IS
672     /******************************************************************
673      Created By      :  smaddali
674      Date Created By :   11-Jun-03
675      Purpose         :   loads each record in the hercules view CVEBLSUBJECT into the interface table
676                          igs_uc_ceblsbj_ints with record status N
677      Known limitations,enhancements,remarks:
678      Change History
679      Who       When         What
680      jbaber    15-Sep-05    Replace sitting and awardingbody values with '*' if NULL
681                             for bug 4589994
682      jchakrab  24-Mar-06    Removed ROWID from columns selected in c_cvebl - 5114377
683     ***************************************************************** */
684 
685       -- Get all the records from hercules view whose timestamp is > passed timestamp
686       -- or get all the records in hercules view if the timestamp passed is null
687       CURSOR c_cvebl( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
688       SELECT
689            subjectid
690           ,timestamp
691           ,year
692           ,NVL(DECODE(RTRIM(sitting),NULL, RPAD('*',LENGTH(sitting),'*'), RTRIM(sitting)),'*') sitting
693           ,NVL(DECODE(RTRIM(awardingbody),NULL, RPAD('*',LENGTH(awardingbody),'*'), RTRIM(awardingbody)),'*') awardingbody
694           ,RTRIM(externalref) externalref
695           ,DECODE(RTRIM(examlevel),NULL, RPAD('*',LENGTH(examlevel),'*'), RTRIM(examlevel)) examlevel
696           ,RTRIM(title) title
697           ,RTRIM(subjcode) subjcode
698       FROM igs_uc_u_cveblsubject_2003
699       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
700 
701       -- get the max timestamp value of the hercules view
702       CURSOR c_max_timestamp IS
703       SELECT MAX(timestamp)
704       FROM igs_uc_u_cveblsubject_2003 ;
705 
706       -- Variables
707       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
708       l_new_max_timestamp igs_uc_u_cveblsubject_2003.timestamp%TYPE ;
709       l_count NUMBER ;
710 
711 
712   BEGIN
713        -- set syncronization required to false
714        g_sync_reqd := FALSE;
715        l_count := 0 ;
716 
717       -- log message that this view is being loaded
718        log_start('CVEBLSUBJECT ON ') ;
719 
720       -- Get the old timestamp for this view in the configured cycle
721       Herc_timestamp_exists('CVEBLSUBJECT',p_old_timestamp) ;
722 
723        -- create interface records for each record in the hercules view whose timestamp > old timestamp
724        FOR c_cvebl_rec IN c_cvebl(p_old_timestamp) LOOP
725               -- set x_sync_read to true if the loop is entered even once
726               g_sync_reqd := TRUE;
727 
728               -- Obsolete matching records in interface table with status N
729               UPDATE igs_uc_ceblsbj_ints SET record_status = 'O'
730               WHERE  record_status = 'N' AND subjectid = c_cvebl_rec.subjectid  ;
731 
732               -- copy hercules record into interface table with record status N
733               INSERT INTO igs_uc_ceblsbj_ints ( subjectid,
734                                                 year,
735                                                 sitting,
736                                                 awardingbody,
737                                                 externalref,
738                                                 examlevel,
739                                                 title,
740                                                 subjcode,
741                                                 record_status,
742                                                 error_code  )
743                                      VALUES (    c_cvebl_rec.subjectid,
744                                                  c_cvebl_rec.year,
745                                                  c_cvebl_rec.sitting,
746                                                  c_cvebl_rec.awardingbody,
747                                                  c_cvebl_rec.externalref,
748                                                  c_cvebl_rec.examlevel,
749                                                  c_cvebl_rec.title,
750                                                  c_cvebl_rec.subjcode,
751                                                  'N',
752                                                  NULL) ;
753           -- increment count of records
754           l_count := l_count + 1;
755 
756        END LOOP ;
757 
758        IF g_sync_reqd THEN
759               -- get the max timestamp of this hercules view
760               OPEN c_max_timestamp ;
761               FETCH c_max_timestamp INTO l_new_max_timestamp ;
762               CLOSE c_max_timestamp ;
763 
764                -- update /insert the timestamp record with new max timestamp
765                ins_upd_timestamp ('CVEBLSUBJECT',l_new_max_timestamp) ;
766                -- log message that this view has been loaded
767                 log_complete('CVEBLSUBJECT', l_count) ;
768        ELSE
769                 -- log message that this view is already in sync and need not be loaded
770                log_already_insync('CVEBLSUBJECT') ;
771        END IF ;
772       COMMIT;
773 
774   EXCEPTION
775       WHEN OTHERS THEN
776                ROLLBACK;
777                write_to_log(SQLERRM);
778                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
779                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVEBLSUBJECT_2003');
780                igs_ge_msg_stack.add;
781                app_exception.raise_exception ;
782   END   load_cveblsubject_2003  ;
783 
784 
785   PROCEDURE load_cvinstitution_2003 IS
786     /******************************************************************
787      Created By      :  smaddali
788      Date Created By :   11-Jun-03
789      Purpose         :    loads each record in the hercules view CVINSTITUTION into the interface table
790                          igs_uc_ceblsbj_ints with record status N
791      Known limitations,enhancements,remarks:
792      Change History
793      Who       When         What
794      jchin     7-Mar-05     Modified for bug #4103556/4124010 Defaulted SWAS column to 'N'
795     ***************************************************************** */
796 
797       -- Get all the records from hercules view whose timestamp is > passed timestamp
798       -- or get all the records in hercules view if the timestamp passed is null
799       CURSOR c_cvinst( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
800       SELECT DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
801           ,timestamp
802           ,RTRIM(instcode) instcode
803           ,RTRIM(instname) instname
804           ,RTRIM(ucas) ucas
805           ,RTRIM(gttr) gttr
806           ,'N' swas
807           ,RTRIM(nmas) nmas
808       FROM igs_uc_u_cvinstitution_2003
809       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
810 
811       -- get the max timestamp value of the hercules view
812       CURSOR c_max_timestamp IS
813       SELECT MAX(timestamp)
814       FROM igs_uc_u_cvinstitution_2003 ;
815 
816       -- Variables
817       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
818       l_new_max_timestamp igs_uc_u_cvinstitution_2003.timestamp%TYPE ;
819       l_count NUMBER ;
820 
821   BEGIN
822        -- set syncronization required to false
823        g_sync_reqd := FALSE;
824        l_count := 0 ;
825 
826       -- log message that this view is being loaded
827         log_start('CVINSTITUTION ON ') ;
828 
829       -- Get the old timestamp for this view in the configured cycle
830       Herc_timestamp_exists('CVINSTITUTION', p_old_timestamp) ;
831 
832        -- create interface records for each record in the hercules view whose timestamp > old timestamp
833        FOR c_cvinst_rec IN c_cvinst(p_old_timestamp) LOOP
834               -- set x_sync_read to true if the loop is entered even once
835               g_sync_reqd := TRUE;
836 
837               -- Obsolete matching records in interface table with status N
838               UPDATE igs_uc_cinst_ints SET record_status = 'O'
839               WHERE record_status = 'N' AND inst = c_cvinst_rec.inst  ;
840 
841               -- copy hercules record into interface table with record status N
842               INSERT INTO igs_uc_cinst_ints (   inst,
843                                                 instcode,
844                                                 instname,
845                                                 ucas,
846                                                 gttr,
847                                                 swas,
848                                                 nmas,
849                                                 record_status,
850                                                 error_code  )
851                                      VALUES (    c_cvinst_rec.inst,
852                                                  c_cvinst_rec.instcode,
853                                                  c_cvinst_rec.instname,
854                                                  c_cvinst_rec.ucas,
855                                                  c_cvinst_rec.gttr,
856                                                  c_cvinst_rec.swas,
857                                                  c_cvinst_rec.nmas,
858                                                  'N',
859                                                  NULL) ;
860         -- increment count of records
861         l_count := l_count + 1;
862 
863        END LOOP ;
864 
865        IF g_sync_reqd THEN
866               -- get the max timestamp of this hercules view
867               OPEN c_max_timestamp ;
868               FETCH c_max_timestamp INTO l_new_max_timestamp ;
869               CLOSE c_max_timestamp ;
870 
871                -- update /insert the timestamp record with new max timestamp
872                ins_upd_timestamp ('CVINSTITUTION', l_new_max_timestamp) ;
873 
874               -- log message that this view has been loaded
875               log_complete('CVINSTITUTION', l_count) ;
876        ELSE
877                -- log message that this view is already in sync and need not be loaded
878                log_already_insync('CVINSTITUTION') ;
879        END IF ;
880       COMMIT;
881 
882   EXCEPTION
883       WHEN OTHERS THEN
884                ROLLBACK;
885                write_to_log(SQLERRM);
886                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
887                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVINSTITUTION_2003');
888                igs_ge_msg_stack.add;
889                app_exception.raise_exception ;
890   END   load_cvinstitution_2003  ;
891 
892 
893   PROCEDURE load_cvjointadmissions_2003 IS
894     /******************************************************************
895      Created By      :  smaddali
896      Date Created By :   11-Jun-03
897      Purpose         :   loads each record in the hercules view CVJOINTADMISSIONS into the interface table
898                          igs_uc_cjntadm_ints with record status N
899      Known limitations,enhancements,remarks:
900      Change History
901      Who       When         What
902      jbaber    15-Sep-05    Replace parentinst1 value with '*' if NULL for bug 4589994
903     ***************************************************************** */
904 
905       -- Get all the records from hercules view whose timestamp is > passed timestamp
906       -- or get all the records in hercules view if the timestamp passed is null
907       CURSOR c_cvjntadm IS
908       SELECT DECODE(RTRIM(childinst),NULL, RPAD('*',LENGTH(childinst),'*'), RTRIM(childinst)) childinst
909           ,NVL(DECODE(RTRIM(parentinst1),NULL, RPAD('*',LENGTH(parentinst1),'*'), RTRIM(parentinst1)),'*') parentinst1
910           ,RTRIM(parentinst2) parentinst2
911           ,RTRIM(parentinst3) parentinst3
912           ,RTRIM(parentinst4) parentinst4
913           ,RTRIM(parentinst5) parentinst5
914       FROM igs_uc_u_cvjntadmissions_2003 ;
915 
916       -- Variables
917       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
918       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.jointadmissions%TYPE ;
919       l_count NUMBER ;
920 
921   BEGIN
922        -- set syncronization required to false
923        g_sync_reqd := FALSE;
924        l_count := 0 ;
925 
926       -- log message that this view is being loaded
927        log_start('CVJOINTADMISSIONS ON ') ;
928 
929       -- get the max timestamp of this hercules view
930       l_new_max_timestamp := g_refamend_timestamp.jointadmissions ;
931 
932       -- Get the old timestamp for this view in the configured cycle
933       Herc_timestamp_exists('CVJOINTADMISSIONS', p_old_timestamp) ;
934 
935 
936       -- if there is a difference in the timestamps then load all records from hercules view
937       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
938 
939               -- Obsolete all records in interface table with status N
940               UPDATE igs_uc_cjntadm_ints SET record_status = 'O' WHERE record_status = 'N' ;
941 
942                -- create interface records for each record in the hercules view
943                FOR c_cvjntadm_rec IN c_cvjntadm LOOP
944                       -- set x_sync_read to true if the loop is entered even once
945                       g_sync_reqd := TRUE;
946 
947                       -- copy hercules record into interface table with record status N
948                       INSERT INTO igs_uc_cjntadm_ints ( childinst,
949                                                         parentinst1,
950                                                         parentinst2,
951                                                         parentinst3,
952                                                         parentinst4,
953                                                         parentinst5,
954                                                         record_status,
955                                                         error_code )
956                                              VALUES (    c_cvjntadm_rec.childinst,
957                                                          c_cvjntadm_rec.parentinst1,
958                                                          c_cvjntadm_rec.parentinst2,
959                                                          c_cvjntadm_rec.parentinst3,
960                                                          c_cvjntadm_rec.parentinst4,
961                                                          c_cvjntadm_rec.parentinst5,
962                                                          'N',
963                                                          NULL) ;
964             -- increment count of records
965             l_count := l_count + 1;
966 
967                END LOOP ;
968       END IF ;
969 
970       IF g_sync_reqd THEN
971                -- update /insert the timestamp record with new max timestamp
972                ins_upd_timestamp ('CVJOINTADMISSIONS', l_new_max_timestamp) ;
973 
974               -- log message that this view has been loaded
975               log_complete('CVJOINTADMISSIONS', l_count) ;
976       ELSE
977               -- log message that this view is already in sync and need not be loaded
978               log_already_insync('CVJOINTADMISSIONS') ;
979       END IF ;
980       COMMIT;
981 
982   EXCEPTION
983       WHEN OTHERS THEN
984                ROLLBACK;
985                write_to_log(SQLERRM);
986                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
987                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVJOINTADMISSIONS_2003');
988                igs_ge_msg_stack.add;
989                app_exception.raise_exception ;
990   END   load_cvjointadmissions_2003  ;
991 
992 
993   PROCEDURE load_cvrefapr_2003 IS
994     /******************************************************************
995      Created By      :  smaddali
996      Date Created By :   11-Jun-03
997      Purpose         :   loads each record in the hercules view CVREFAPR into the interface table
998                          igs_uc_crapr_ints  with record status N
999      Known limitations,enhancements,remarks:
1000      Change History
1001      Who       When         What
1002     ***************************************************************** */
1003 
1004       -- Get all the records from hercules view whose timestamp is > passed timestamp
1005       -- or get all the records in hercules view if the timestamp passed is null
1006       CURSOR c_cvapr IS
1007       SELECT dom
1008            ,RTRIM(domtext) domtext
1009            ,RTRIM(leaflag) leaflag
1010       FROM igs_uc_u_cvrefapr_2003  ;
1011 
1012 
1013       -- Variables
1014       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1015       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.aprdate%TYPE ;
1016       l_count NUMBER ;
1017 
1018 
1019   BEGIN
1020        -- set syncronization required to false
1021        g_sync_reqd := FALSE;
1022        l_count := 0 ;
1023 
1024       -- log message that this view is being loaded
1025        log_start('CVREFAPR ON ') ;
1026 
1027       -- get the max timestamp of this hercules view
1028       l_new_max_timestamp := g_refamend_timestamp.aprdate ;
1029 
1030       -- Get the old timestamp for this view in the configured cycle
1031       Herc_timestamp_exists('CVREFAPR', p_old_timestamp) ;
1032 
1033       -- if there is a difference in the timestamps then load all records from hercules view
1034       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1035 
1036                -- Obsolete all records in interface table with status N
1037                UPDATE igs_uc_crapr_ints SET record_status = 'O' WHERE record_status = 'N' ;
1038 
1039                -- create interface records for each record in the hercules view
1040                FOR c_cvapr_rec IN c_cvapr LOOP
1041                       -- set x_sync_read to true if the loop is entered even once
1042                       g_sync_reqd := TRUE;
1043 
1044                       --Validate varchar to number conversion
1045                       IF  is_valid(c_cvapr_rec.dom,'CVREFAPR','DOM','NUMBER') THEN
1046 
1047                           -- copy hercules record into interface table with record status N
1048                           INSERT INTO igs_uc_crapr_ints (   dom,
1049                                                             domtext,
1050                                                             leaflag,
1051                                                             record_status,
1052                                                             error_code )
1053                                                  VALUES (    c_cvapr_rec.dom,
1054                                                              c_cvapr_rec.domtext,
1055                                                              c_cvapr_rec.leaflag,
1056                                                              'N',
1057                                                              NULL) ;
1058                           -- increment count of records
1059                           l_count := l_count + 1;
1060 
1061                       END IF;
1062 
1063                END LOOP ;
1064       END IF ;  -- old and new timetamps differ
1065 
1066       IF g_sync_reqd THEN
1067                -- update /insert the timestamp record with new max timestamp
1068                ins_upd_timestamp ('CVREFAPR',l_new_max_timestamp) ;
1069 
1070               -- log message that this view has been loaded
1071               log_complete('CVREFAPR', l_count) ;
1072       ELSE
1073                 -- log message that this view is already in sync and need not be loaded
1074                log_already_insync('CVREFAPR') ;
1075       END IF ;
1076       COMMIT;
1077 
1078   EXCEPTION
1079       WHEN OTHERS THEN
1080                ROLLBACK;
1081                write_to_log(SQLERRM);
1082                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1083                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFAPR_2003');
1084                igs_ge_msg_stack.add;
1085                app_exception.raise_exception ;
1086   END   load_cvrefapr_2003  ;
1087 
1088 
1089   PROCEDURE load_cvrefawardbody_2003 IS
1090     /******************************************************************
1091      Created By      :  smaddali
1092      Date Created By :   11-Jun-03
1093      Purpose         :   loads each record in the hercules view CVREFAWARDBODY into the interface table
1094                          igs_uc_crawdbd_ints   with record status N
1095      Known limitations,enhancements,remarks:
1096      Change History
1097      Who       When         What
1098     ***************************************************************** */
1099 
1100       -- Get all the records from hercules view whose timestamp is > passed timestamp
1101       -- or get all the records in hercules view if the timestamp passed is null
1102       CURSOR c_cvawb IS
1103       SELECT year
1104            ,DECODE(RTRIM(sitting),NULL, RPAD('*',LENGTH(sitting),'*'), RTRIM(sitting)) sitting
1105            ,DECODE(RTRIM(awardingbody),NULL, RPAD('*',LENGTH(awardingbody),'*'), RTRIM(awardingbody)) awardingbody
1106            ,RTRIM(bodyname) bodyname
1107            ,RTRIM(bodyabbrev) bodyabbrev
1108       FROM igs_uc_u_cvrefawardbody_2003   ;
1109 
1110       -- Variables
1111       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1112       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.awardbodydate%TYPE ;
1113       l_count NUMBER ;
1114 
1115   BEGIN
1116        -- set syncronization required to false
1117        g_sync_reqd := FALSE;
1118        l_count := 0 ;
1119 
1120       -- log message that this view is being loaded
1121        log_start('CVREFAWARDBODY ON ' ) ;
1122 
1123       -- get the max timestamp of this hercules view
1124       l_new_max_timestamp := g_refamend_timestamp.awardbodydate ;
1125 
1126 
1127       -- Get the old timestamp for this view in the configured cycle
1128       Herc_timestamp_exists('CVREFAWARDBODY', p_old_timestamp) ;
1129       -- if there is a difference in the timestamps then load all records from hercules view
1130       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1131 
1132                -- Obsolete all records in interface table with status N
1133                UPDATE igs_uc_crawdbd_ints SET record_status = 'O' WHERE record_status = 'N' ;
1134 
1135                -- create interface records for each record in the hercules view
1136                FOR c_cvawb_rec IN c_cvawb LOOP
1137                       -- set x_sync_read to true if the loop is entered even once
1138                       g_sync_reqd := TRUE;
1139 
1140                       -- copy hercules record into interface table with record status N
1141                       INSERT INTO igs_uc_crawdbd_ints (  year,
1142                                                          sitting,
1143                                                          awardingbody,
1144                                                          bodyname,
1145                                                          bodyabbrev,
1146                                                          record_status,
1147                                                          error_code)
1148                                              VALUES (    c_cvawb_rec.year,
1149                                                          c_cvawb_rec.sitting,
1150                                                          c_cvawb_rec.awardingbody,
1151                                                          c_cvawb_rec.bodyname,
1152                                                          c_cvawb_rec.bodyabbrev,
1153                                                          'N',
1154                                                          NULL) ;
1155             -- increment count of records
1156             l_count := l_count + 1;
1157 
1158                END LOOP ;
1159       END IF ;  -- old and new timetamps differ
1160 
1161       IF g_sync_reqd THEN
1162                -- update /insert the timestamp record with new max timestamp
1163                ins_upd_timestamp ('CVREFAWARDBODY', l_new_max_timestamp) ;
1164 
1165                 -- log message that this view has been loaded
1166                 log_complete('CVREFAWARDBODY', l_count ) ;
1167       ELSE
1168                 -- log message that this view is already in sync and need not be loaded
1169                log_already_insync('CVREFAWARDBODY') ;
1170       END IF ;
1171       COMMIT;
1172 
1173   EXCEPTION
1174       WHEN OTHERS THEN
1175                ROLLBACK;
1176                write_to_log(SQLERRM);
1177                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1178                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFAWARDBODY_2003');
1179                igs_ge_msg_stack.add;
1180                app_exception.raise_exception ;
1181   END  load_cvrefawardbody_2003   ;
1182 
1183   PROCEDURE load_cvrefdis_2003 IS
1184     /******************************************************************
1185      Created By      :  smaddali
1186      Date Created By :   11-Jun-03
1187      Purpose         :    loads each record in the hercules view cvrefdis into the interface table
1188                          igs_uc_crfcode_ints with record status N and code_type = DC
1189      Known limitations,enhancements,remarks:
1190      Change History
1191      Who       When         What
1192     ***************************************************************** */
1193 
1194       -- Get all the records from hercules view whose timestamp is > passed timestamp
1195       -- or get all the records in hercules view if the timestamp passed is null
1196       CURSOR c_cvdis IS
1197       SELECT dis
1198            ,RTRIM(distext) distext
1199       FROM igs_uc_u_cvrefdis_2003    ;
1200 
1201       -- Variables
1202       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1203       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.disdate%TYPE ;
1204       l_count NUMBER ;
1205 
1206   BEGIN
1207        -- set syncronization required to false
1208        g_sync_reqd := FALSE;
1209        l_count := 0 ;
1210 
1211       -- log message that this view is being loaded
1212         log_start('CVREFDIS ON ') ;
1213 
1214       -- get the max timestamp of this hercules view
1215       l_new_max_timestamp := g_refamend_timestamp.disdate ;
1216 
1217       -- Get the old timestamp for this view in the configured cycle
1218       Herc_timestamp_exists('CVREFDIS',p_old_timestamp) ;
1219       -- if there is a difference in the timestamps then load all records from hercules view
1220       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1221 
1222                -- Obsolete all records in interface table with status N
1223                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'DC' ;
1224 
1225                -- create interface records for each record in the hercules view
1226                FOR c_cvdis_rec IN c_cvdis LOOP
1227                       -- set x_sync_read to true if the loop is entered even once
1228                       g_sync_reqd := TRUE;
1229 
1230                       -- copy hercules record into interface table with record status N
1231                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1232                                                          code,
1233                                                          code_text,
1234                                                          record_status,
1235                                                          error_code )
1236                                              VALUES (    'DC',
1237                                                          c_cvdis_rec.dis,
1238                                                          c_cvdis_rec.distext,
1239                                                          'N',
1240                                                          NULL) ;
1241             -- increment count of records
1242             l_count := l_count + 1;
1243 
1244                END LOOP ;
1245       END IF ;  -- old and new timetamps differ
1246 
1247       IF g_sync_reqd THEN
1248                -- update /insert the timestamp record with new max timestamp
1249                ins_upd_timestamp ('CVREFDIS', l_new_max_timestamp) ;
1250 
1251                  -- log message that this view has been loaded
1252                  log_complete('CVREFDIS', l_count) ;
1253       ELSE
1254                 -- log message that this view is already in sync and need not be loaded
1255                log_already_insync('CVREFDIS') ;
1256       END IF ;
1257       COMMIT;
1258 
1259   EXCEPTION
1260       WHEN OTHERS THEN
1261                ROLLBACK;
1262                write_to_log(SQLERRM);
1263                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1264                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFDIS_2003');
1265                igs_ge_msg_stack.add;
1266                app_exception.raise_exception ;
1267   END    load_cvrefdis_2003 ;
1268 
1269   PROCEDURE load_cvreferror_2003 IS
1270     /******************************************************************
1271      Created By      :  smaddali
1272      Date Created By :   11-Jun-03
1273      Purpose         :    loads each record in the hercules view cvreferror into the interface table
1274                          igs_uc_crfcode_ints with record status N and code_type = EC
1275      Known limitations,enhancements,remarks:
1276      Change History
1277      Who       When         What
1278     ***************************************************************** */
1279 
1280       -- Get all the records from hercules view whose timestamp is > passed timestamp
1281       -- or get all the records in hercules view if the timestamp passed is null
1282       CURSOR c_cverr IS
1283       SELECT errorcode
1284            ,RTRIM(errordescription) errordescription
1285       FROM igs_uc_u_cvreferror_2003     ;
1286 
1287       -- Variables
1288       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1289       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.errordate%TYPE ;
1290       l_count NUMBER ;
1291 
1292   BEGIN
1293        -- set syncronization required to false
1294        g_sync_reqd := FALSE;
1295        l_count := 0 ;
1296 
1297       -- log message that this view is being loaded
1298        log_start('CVREFERROR ON ' ) ;
1299 
1300       -- get the max timestamp of this hercules view
1301       l_new_max_timestamp := g_refamend_timestamp.errordate ;
1302 
1303       -- Get the old timestamp for this view in the configured cycle
1304       Herc_timestamp_exists('CVREFERROR',p_old_timestamp) ;
1305       -- if there is a difference in the timestamps then load all records from hercules view
1306       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1307 
1308                -- Obsolete all records in interface table with status N
1309                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'EC' ;
1310 
1311                -- create interface records for each record in the hercules view
1312                FOR c_cverr_rec IN c_cverr LOOP
1313                       -- set x_sync_read to true if the loop is entered even once
1314                       g_sync_reqd := TRUE;
1315 
1316                       -- copy hercules record into interface table with record status N
1317                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1318                                                          code,
1319                                                          code_text,
1320                                                          record_status,
1321                                                          error_code )
1322                                              VALUES (    'EC',
1323                                                          c_cverr_rec.errorcode,
1324                                                          c_cverr_rec.errordescription,
1325                                                          'N',
1326                                                          NULL) ;
1327             -- increment count of records
1328             l_count := l_count + 1;
1329 
1330                END LOOP ;
1331       END IF ;  -- old and new timetamps differ
1332 
1333       IF g_sync_reqd THEN
1334                -- update /insert the timestamp record with new max timestamp
1335                ins_upd_timestamp ('CVREFERROR',l_new_max_timestamp) ;
1336 
1337                  -- log message that this view has been loaded
1338                 log_complete('CVREFERROR', l_count ) ;
1339       ELSE
1340                 -- log message that this view is already in sync and need not be loaded
1341                log_already_insync('CVREFERROR') ;
1342       END IF ;
1343       COMMIT;
1344 
1345   EXCEPTION
1346       WHEN OTHERS THEN
1347                ROLLBACK;
1348                write_to_log(SQLERRM);
1349                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1350                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFERROR_2003');
1351                igs_ge_msg_stack.add;
1352                app_exception.raise_exception ;
1353   END  load_cvreferror_2003   ;
1354 
1355 
1356   PROCEDURE load_cvrefestgroup_2003 IS
1357     /******************************************************************
1358      Created By      :  smaddali
1359      Date Created By :   11-Jun-03
1360      Purpose         :    loads each record in the hercules view cvrefestgroup into the interface table
1361                          igs_uc_crfcode_ints with record status N and code_type = EG
1362      Known limitations,enhancements,remarks:
1363      Change History
1364      Who       When         What
1365     ***************************************************************** */
1366 
1367       -- Get all the records from hercules view whose timestamp is > passed timestamp
1368       -- or get all the records in hercules view if the timestamp passed is null
1369       CURSOR c_cvest IS
1370       SELECT DECODE(RTRIM(estabgrp),NULL, RPAD('*',LENGTH(estabgrp),'*'), RTRIM(estabgrp)) estabgrp
1371            ,RTRIM(estabtext) estabtext
1372       FROM igs_uc_u_cvrefestgroup_2003      ;
1373 
1374       -- Variables
1375       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1376       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.estabgroup%TYPE ;
1377       l_count NUMBER ;
1378 
1379 
1380   BEGIN
1381        -- set syncronization required to false
1382        g_sync_reqd := FALSE;
1383        l_count := 0 ;
1384 
1385       -- log message that this view is being loaded
1386        log_start('CVREFESTGROUP ON ') ;
1387 
1388       -- get the max timestamp of this hercules view
1389       l_new_max_timestamp := g_refamend_timestamp.estabgroup ;
1390 
1391       -- Get the old timestamp for this view in the configured cycle
1392       Herc_timestamp_exists('CVREFESTGROUP', p_old_timestamp) ;
1393       -- if there is a difference in the timestamps then load all records from hercules view
1394       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1395 
1396                -- Obsolete all records in interface table with status N
1397                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'EG' ;
1398 
1399                -- create interface records for each record in the hercules view
1400                FOR c_cvest_rec IN c_cvest LOOP
1401                       -- set x_sync_read to true if the loop is entered even once
1402                       g_sync_reqd := TRUE;
1403 
1404                       -- copy hercules record into interface table with record status N
1405                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1406                                                          code,
1407                                                          code_text,
1408                                                          record_status,
1409                                                          error_code )
1410                                              VALUES (    'EG',
1411                                                          c_cvest_rec.estabgrp,
1412                                                          c_cvest_rec.estabtext,
1413                                                          'N',
1414                                                          NULL) ;
1415             -- increment count of records
1416             l_count := l_count + 1;
1417 
1418                END LOOP ;
1419       END IF ;  -- old and new timetamps differ
1420 
1421       IF g_sync_reqd THEN
1422                -- update /insert the timestamp record with new max timestamp
1423                ins_upd_timestamp ('CVREFESTGROUP', l_new_max_timestamp) ;
1424 
1425                 -- log message that this view has been loaded
1426                 log_complete('CVREFESTGROUP', l_count) ;
1427       ELSE
1428                 -- log message that this view is already in sync and need not be loaded
1429                log_already_insync('CVREFESTGROUP') ;
1430       END IF ;
1431       COMMIT;
1432 
1433   EXCEPTION
1434       WHEN OTHERS THEN
1435                ROLLBACK;
1436                write_to_log(SQLERRM);
1437                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1438                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFESTGROUP_2003');
1439                igs_ge_msg_stack.add;
1440                app_exception.raise_exception ;
1441   END   load_cvrefestgroup_2003  ;
1442 
1443 
1444   PROCEDURE load_cvrefethnic_2003 IS
1445     /******************************************************************
1446      Created By      :  smaddali
1447      Date Created By :   11-Jun-03
1448      Purpose         :   loads each record in the hercules view cvrefethnic into the interface table
1449                          igs_uc_crfcode_ints with record status N and code_type = ET
1450      Known limitations,enhancements,remarks:
1451      Change History
1452      Who       When         What
1453     ***************************************************************** */
1454 
1455       -- Get all the records from hercules view whose timestamp is > passed timestamp
1456       -- or get all the records in hercules view if the timestamp passed is null
1457       CURSOR c_cveth IS
1458       SELECT ethnic
1459            ,RTRIM(ethnictext) ethnictext
1460       FROM igs_uc_u_cvrefethnic_2003       ;
1461 
1462       -- Variables
1463       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1464       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.ethnicdate%TYPE ;
1465       l_count NUMBER ;
1466 
1467   BEGIN
1468        -- set syncronization required to false
1469        g_sync_reqd := FALSE;
1470        l_count := 0 ;
1471 
1472       -- log message that this view is being loaded
1473        log_start('CVREFETHNIC ON ') ;
1474 
1475       -- get the max timestamp of this hercules view
1476       l_new_max_timestamp := g_refamend_timestamp.ethnicdate ;
1477 
1478       -- Get the old timestamp for this view in the configured cycle
1479       Herc_timestamp_exists('CVREFETHNIC', p_old_timestamp) ;
1480       -- if there is a difference in the timestamps then load all records from hercules view
1481       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1482 
1483                -- Obsolete all records in interface table with status N
1484                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'ET' ;
1485 
1486                -- create interface records for each record in the hercules view
1487                FOR c_cveth_rec IN c_cveth LOOP
1488                       -- set x_sync_read to true if the loop is entered even once
1489                       g_sync_reqd := TRUE;
1490 
1491                       -- copy hercules record into interface table with record status N
1492                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1493                                                          code,
1494                                                          code_text,
1495                                                          record_status,
1496                                                          error_code )
1497                                              VALUES (    'ET',
1498                                                          c_cveth_rec.ethnic,
1499                                                          c_cveth_rec.ethnictext,
1500                                                          'N',
1501                                                          NULL) ;
1502             -- increment count of records
1503             l_count := l_count + 1;
1504 
1505                END LOOP ;
1506       END IF ;  -- old and new timetamps differ
1507 
1508       IF g_sync_reqd THEN
1509                -- update /insert the timestamp record with new max timestamp
1510                ins_upd_timestamp ('CVREFETHNIC', l_new_max_timestamp) ;
1511 
1512                  -- log message that this view has been loaded
1513                   log_complete('CVREFETHNIC', l_count) ;
1514       ELSE
1515                 -- log message that this view is already in sync and need not be loaded
1516                log_already_insync('CVREFETHNIC') ;
1517        END IF ;
1518       COMMIT;
1519 
1520   EXCEPTION
1521       WHEN OTHERS THEN
1522                ROLLBACK;
1523                write_to_log(SQLERRM);
1524                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1525                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFETHNIC_2003');
1526                igs_ge_msg_stack.add;
1527                app_exception.raise_exception ;
1528   END   load_cvrefethnic_2003  ;
1529 
1530   PROCEDURE load_cvrefexam_2003 IS
1531     /******************************************************************
1532      Created By      :  smaddali
1533      Date Created By :   11-Jun-03
1534      Purpose         :   loads each record in the hercules view cvrefexam into the interface table
1535                          igs_uc_crfcode_ints with record status N and code_type = EL
1536      Known limitations,enhancements,remarks:
1537      Change History
1538      Who       When         What
1539     ***************************************************************** */
1540 
1541       -- Get all the records from hercules view whose timestamp is > passed timestamp
1542       -- or get all the records in hercules view if the timestamp passed is null
1543       CURSOR c_cvexam IS
1544       SELECT DECODE(RTRIM(examlevel),NULL, RPAD('*',LENGTH(examlevel),'*'), RTRIM(examlevel)) examlevel
1545            ,RTRIM(examtext) examtext
1546       FROM igs_uc_u_cvrefexam_2003  ;
1547 
1548       -- Variables
1549       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1550       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.examdate%TYPE ;
1551       l_count NUMBER ;
1552 
1553   BEGIN
1554        -- set syncronization required to false
1555        g_sync_reqd := FALSE;
1556        l_count := 0 ;
1557 
1558       -- log message that this view is being loaded
1559         log_start('CVREFEXAM ON ' ) ;
1560 
1561       -- get the max timestamp of this hercules view
1562       l_new_max_timestamp := g_refamend_timestamp.examdate ;
1563 
1564       -- Get the old timestamp for this view in the configured cycle
1565       Herc_timestamp_exists('CVREFEXAM', p_old_timestamp) ;
1566       -- if there is a difference in the timestamps then load all records from hercules view
1567       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1568 
1569                -- Obsolete all records in interface table with status N
1570                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'EL' ;
1571 
1572                -- create interface records for each record in the hercules view
1573                FOR c_cvexam_rec IN c_cvexam LOOP
1574                       -- set x_sync_read to true if the loop is entered even once
1575                       g_sync_reqd := TRUE;
1576 
1577                       -- copy hercules record into interface table with record status N
1578                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1579                                                          code,
1580                                                          code_text,
1581                                                          record_status,
1582                                                          error_code )
1583                                              VALUES (    'EL',
1584                                                          c_cvexam_rec.examlevel,
1585                                                          c_cvexam_rec.examtext,
1586                                                          'N',
1587                                                          NULL) ;
1588             -- increment count of records
1589             l_count := l_count + 1;
1590 
1591                END LOOP ;
1592       END IF ;  -- old and new timetamps differ
1593 
1594       IF g_sync_reqd THEN
1595                -- update /insert the timestamp record with new max timestamp
1596                ins_upd_timestamp ('CVREFEXAM',  l_new_max_timestamp) ;
1597 
1598             -- log message that this view has been loaded
1599             log_complete('CVREFEXAM', l_count ) ;
1600       ELSE
1601                 -- log message that this view is already in sync and need not be loaded
1602                log_already_insync('CVREFEXAM') ;
1603       END IF ;
1604       COMMIT;
1605 
1606   EXCEPTION
1607       WHEN OTHERS THEN
1608                ROLLBACK;
1609                write_to_log(SQLERRM);
1610                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1611                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFEXAM_2003');
1612                igs_ge_msg_stack.add;
1613                app_exception.raise_exception ;
1614   END   load_cvrefexam_2003  ;
1615 
1616   PROCEDURE load_cvreffee_2003 IS
1617     /******************************************************************
1618      Created By      :  smaddali
1619      Date Created By :   11-Jun-03
1620      Purpose         :   loads each record in the hercules view cvreffee into the interface table
1621                          igs_uc_crfcode_ints with record status N and code_type = FC
1622      Known limitations,enhancements,remarks:
1623      Change History
1624      Who       When         What
1625     ***************************************************************** */
1626 
1627       -- Get all the records from hercules view whose timestamp is > passed timestamp
1628       -- or get all the records in hercules view if the timestamp passed is null
1629       CURSOR c_cvfee IS
1630       SELECT feepayer
1631            ,RTRIM(feetext) feetext
1632       FROM igs_uc_u_cvreffee_2003 ;
1633 
1634       -- Variables
1635       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1636       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.feedate%TYPE ;
1637       l_count NUMBER ;
1638 
1639   BEGIN
1640        -- set syncronization required to false
1641        g_sync_reqd := FALSE;
1642        l_count := 0 ;
1643 
1644       -- log message that this view is being loaded
1645        log_start('CVREFFEE ON ') ;
1646 
1647       -- get the max timestamp of this hercules view
1648       l_new_max_timestamp := g_refamend_timestamp.feedate ;
1649 
1650       -- Get the old timestamp for this view in the configured cycle
1651       Herc_timestamp_exists('CVREFFEE', p_old_timestamp) ;
1652       -- if there is a difference in the timestamps then load all records from hercules view
1653       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1654 
1655                -- Obsolete all records in interface table with status N
1656                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'FC' ;
1657 
1658                -- create interface records for each record in the hercules view
1659                FOR c_cvfee_rec IN c_cvfee LOOP
1660                       -- set x_sync_read to true if the loop is entered even once
1661                       g_sync_reqd := TRUE;
1662 
1663                       -- copy hercules record into interface table with record status N
1664                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1665                                                          code,
1666                                                          code_text,
1667                                                          record_status,
1668                                                          error_code )
1669                                              VALUES (    'FC',
1670                                                          c_cvfee_rec.feepayer,
1671                                                          c_cvfee_rec.feetext,
1672                                                          'N',
1673                                                          NULL) ;
1674             -- increment count of records
1675             l_count := l_count + 1;
1676 
1677                END LOOP ;
1678       END IF ;  -- old and new timetamps differ
1679 
1680       IF g_sync_reqd THEN
1681                -- update /insert the timestamp record with new max timestamp
1682                ins_upd_timestamp ('CVREFFEE', l_new_max_timestamp) ;
1683 
1684                 -- log message that this view has been loaded
1685                 log_complete('CVREFFEE', l_count) ;
1686       ELSE
1687                 -- log message that this view is already in sync and need not be loaded
1688                 log_already_insync('CVREFFEE') ;
1689        END IF ;
1690       COMMIT;
1691 
1692   EXCEPTION
1693       WHEN OTHERS THEN
1694                ROLLBACK;
1695                write_to_log(SQLERRM);
1696                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1697                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFFEE_2003');
1698                igs_ge_msg_stack.add;
1699                app_exception.raise_exception ;
1700   END   load_cvreffee_2003  ;
1701 
1702   PROCEDURE load_cvrefkeyword_2003 IS
1703     /******************************************************************
1704      Created By      :  smaddali
1705      Date Created By :   11-Jun-03
1706      Purpose         :   loads each record in the hercules view cvrefkeyword into the interface table
1707                          igs_uc_crkywd_ints  with record status N
1708      Known limitations,enhancements,remarks:
1709      Change History
1710      Who       When         What
1711     ***************************************************************** */
1712 
1713       -- Get all the records from hercules view whose timestamp is > passed timestamp
1714       -- or get all the records in hercules view if the timestamp passed is null
1715       CURSOR c_cvkyw IS
1716       SELECT DECODE(RTRIM(keyword),NULL, RPAD('*',LENGTH(keyword),'*'), RTRIM(keyword)) keyword
1717       FROM igs_uc_u_cvrefkeyword_2003 ;
1718 
1719       -- Variables
1720       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1721       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.keyworddate%TYPE ;
1722       l_count NUMBER ;
1723 
1724   BEGIN
1725        -- set syncronization required to false
1726        g_sync_reqd := FALSE;
1727        l_count := 0 ;
1728 
1729       -- log message that this view is being loaded
1730        log_start('CVREFKEYWORD ON ') ;
1731 
1732       -- get the max timestamp of this hercules view
1733       l_new_max_timestamp := g_refamend_timestamp.keyworddate ;
1734 
1735       -- Get the old timestamp for this view in the configured cycle
1736       Herc_timestamp_exists('CVREFKEYWORD', p_old_timestamp) ;
1737       -- if there is a difference in the timestamps then load all records from hercules view
1738       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1739 
1740                -- Obsolete all records in interface table with status N
1741                UPDATE igs_uc_crkywd_ints   SET record_status = 'O' WHERE record_status = 'N' ;
1742 
1743                -- create interface records for each record in the hercules view
1744                FOR c_cvkyw_rec IN c_cvkyw LOOP
1745                       -- set x_sync_read to true if the loop is entered even once
1746                       g_sync_reqd := TRUE;
1747 
1748                       -- copy hercules record into interface table with record status N
1749                       INSERT INTO igs_uc_crkywd_ints (   keyword,
1750                                                          record_status,
1751                                                          error_code )
1752                                              VALUES (    c_cvkyw_rec.keyword,
1753                                                          'N',
1754                                                          NULL) ;
1755             -- increment count of records
1756             l_count := l_count + 1;
1757 
1758                END LOOP ;
1759       END IF ;  -- old and new timestamps differ
1760 
1761       IF g_sync_reqd THEN
1762                -- update /insert the timestamp record with new max timestamp
1763                ins_upd_timestamp ('CVREFKEYWORD',l_new_max_timestamp) ;
1764 
1765                   -- log message that this view has been loaded
1766                  log_complete('CVREFKEYWORD', l_count) ;
1767       ELSE
1768                 -- log message that this view is already in sync and need not be loaded
1769                log_already_insync('CVREFKEYWORD') ;
1770       END IF ;
1771       COMMIT;
1772 
1773   EXCEPTION
1774       WHEN OTHERS THEN
1775                ROLLBACK;
1776                write_to_log(SQLERRM);
1777                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1778                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFKEYWORD_2003');
1779                igs_ge_msg_stack.add;
1780                app_exception.raise_exception ;
1781   END   load_cvrefkeyword_2003  ;
1782 
1783   PROCEDURE load_cvrefoeq_2003 IS
1784     /******************************************************************
1785      Created By      :  smaddali
1786      Date Created By :   11-Jun-03
1787      Purpose         :   loads each record in the hercules view cvrefoeq into the interface table
1788                           igs_uc_crfcode_ints with record status N and code_type = OC
1789      Known limitations,enhancements,remarks:
1790      Change History
1791      Who       When         What
1792     ***************************************************************** */
1793 
1794       -- Get all the records from hercules view whose timestamp is > passed timestamp
1795       -- or get all the records in hercules view if the timestamp passed is null
1796       CURSOR c_cvoeq IS
1797       SELECT DECODE(RTRIM(oeq),NULL, RPAD('*',LENGTH(oeq),'*'), RTRIM(oeq)) oeq
1798            ,RTRIM(oeqtext) oeqtext
1799       FROM igs_uc_u_cvrefoeq_2003  ;
1800 
1801       -- Variables
1802       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1803       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.oeqdate%TYPE ;
1804       l_count NUMBER ;
1805 
1806   BEGIN
1807        -- set syncronization required to false
1808        g_sync_reqd := FALSE;
1809        l_count := 0 ;
1810 
1811       -- log message that this view is being loaded
1812       log_start('CVREFOEQ ON ') ;
1813 
1814       -- get the max timestamp of this hercules view
1815       l_new_max_timestamp := g_refamend_timestamp.oeqdate ;
1816 
1817       -- Get the old timestamp for this view in the configured cycle
1818       Herc_timestamp_exists('CVREFOEQ', p_old_timestamp) ;
1819       -- if there is a difference in the timestamps then load all records from hercules view
1820       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1821 
1822                -- Obsolete all records in interface table with status N
1823                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'OC' ;
1824 
1825                -- create interface records for each record in the hercules view
1826                FOR c_cvoeq_rec IN c_cvoeq LOOP
1827                       -- set x_sync_read to true if the loop is entered even once
1828                       g_sync_reqd := TRUE;
1829 
1830                       -- copy hercules record into interface table with record status N
1831                       INSERT INTO igs_uc_crfcode_ints (  code_type,
1832                                                          code,
1833                                                          code_text,
1834                                                          record_status,
1835                                                          error_code )
1836                                              VALUES (    'OC',
1837                                                          c_cvoeq_rec.oeq,
1838                                                          c_cvoeq_rec.oeqtext,
1839                                                          'N',
1840                                                          NULL) ;
1841             -- increment count of records
1842             l_count := l_count + 1;
1843 
1844                END LOOP ;
1845       END IF ;  -- old and new timetamps differ
1846 
1847       IF g_sync_reqd THEN
1848                -- update /insert the timestamp record with new max timestamp
1849                ins_upd_timestamp ('CVREFOEQ',  l_new_max_timestamp) ;
1850 
1851            -- log message that this view has been loaded
1852               log_complete('CVREFOEQ', l_count) ;
1853       ELSE
1854                 -- log message that this view is already in sync and need not be loaded
1855                log_already_insync('CVREFOEQ') ;
1856       END IF ;
1857       COMMIT;
1858 
1859   EXCEPTION
1860       WHEN OTHERS THEN
1861                ROLLBACK;
1862                write_to_log(SQLERRM);
1863                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1864                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFOEQ_2003');
1865                igs_ge_msg_stack.add;
1866                app_exception.raise_exception ;
1867   END   load_cvrefoeq_2003  ;
1868 
1869   PROCEDURE load_cvrefofferabbrev_2003 IS
1870     /******************************************************************
1871      Created By      :  smaddali
1872      Date Created By :   11-Jun-03
1873      Purpose         :   loads each record in the hercules view cvrefofferabbrev into the interface table
1874                          igs_uc_croffab_ints  with record status N
1875      Known limitations,enhancements,remarks:
1876      Change History
1877      Who       When         What
1878     ***************************************************************** */
1879 
1880       -- Get all the records from hercules view whose timestamp is > passed timestamp
1881       -- or get all the records in hercules view if the timestamp passed is null
1882       CURSOR c_cvoffabr IS
1883       SELECT DECODE(RTRIM(abbrevcode),NULL, RPAD('*',LENGTH(abbrevcode),'*'), RTRIM(abbrevcode)) abbrevcode
1884         ,RTRIM(abbrevtext) abbrevtext
1885         ,DECODE(RTRIM(letterformat),NULL, RPAD('*',LENGTH(letterformat),'*'), RTRIM(letterformat)) letterformat
1886         ,RTRIM(summarychar) summarychar
1887         ,RTRIM(uncond) uncond
1888         ,RTRIM(withdrawal) withdrawal
1889         ,RTRIM(release) release
1890         ,RTRIM(tariff) tariff
1891       FROM igs_uc_u_cvrefofferabbrev_2003  ;
1892 
1893       -- Variables
1894       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1895       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.offerabbrevdate%TYPE ;
1896       l_count NUMBER ;
1897 
1898   BEGIN
1899        -- set syncronization required to false
1900        g_sync_reqd := FALSE;
1901        l_count := 0 ;
1902 
1903       -- log message that this view is being loaded
1904        log_start('CVREFOFFERABBREV ON ') ;
1905 
1906       -- get the max timestamp of this hercules view
1907       l_new_max_timestamp := g_refamend_timestamp.offerabbrevdate ;
1908 
1909       -- Get the old timestamp for this view in the configured cycle
1910       Herc_timestamp_exists('CVREFOFFERABBREV', p_old_timestamp) ;
1911       -- if there is a difference in the timestamps then load all records from hercules view
1912       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
1913 
1914                -- Obsolete all records in interface table with status N
1915                UPDATE igs_uc_croffab_ints   SET record_status = 'O' WHERE record_status = 'N' ;
1916 
1917                -- create interface records for each record in the hercules view
1918                FOR c_cvoffabr_rec IN c_cvoffabr LOOP
1919                       -- set x_sync_read to true if the loop is entered even once
1920                       g_sync_reqd := TRUE;
1921 
1922                       -- copy hercules record into interface table with record status N
1923                       INSERT INTO igs_uc_croffab_ints ( abbrevcode,
1924                                                         abbrevtext,
1925                                                         letterformat,
1926                                                         summarychar,
1927                                                         uncond,
1928                                                         withdrawal,
1929                                                         release,
1930                                                         tariff,
1931                                                         record_status,
1932                                                         error_code )
1933                                              VALUES (   c_cvoffabr_rec.abbrevcode,
1934                                                         c_cvoffabr_rec.abbrevtext,
1935                                                         c_cvoffabr_rec.letterformat,
1936                                                         c_cvoffabr_rec.summarychar,
1937                                                         c_cvoffabr_rec.uncond,
1938                                                         c_cvoffabr_rec.withdrawal,
1939                                                         c_cvoffabr_rec.release,
1940                                                         c_cvoffabr_rec.tariff,
1941                                                         'N',
1942                                                         NULL) ;
1943             -- increment count of records
1944             l_count := l_count + 1;
1945 
1946                END LOOP ;
1947       END IF ;  -- old and new timestamps differ
1948 
1949       IF g_sync_reqd THEN
1950                -- update /insert the timestamp record with new max timestamp
1951                ins_upd_timestamp ('CVREFOFFERABBREV',l_new_max_timestamp) ;
1952 
1953               -- log message that this view has been loaded
1954               log_complete('CVREFOFFERABBREV', l_count) ;
1955       ELSE
1956                 -- log message that this view is already in sync and need not be loaded
1957                log_already_insync('CVREFOFFERABBREV') ;
1958       END IF ;
1959       COMMIT;
1960 
1961   EXCEPTION
1962       WHEN OTHERS THEN
1963                ROLLBACK;
1964                write_to_log(SQLERRM);
1965                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
1966                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFOFFERABBREV_2003');
1967                igs_ge_msg_stack.add;
1968                app_exception.raise_exception ;
1969   END  load_cvrefofferabbrev_2003   ;
1970 
1971 
1972   PROCEDURE load_cvrefoffersubj_2003 IS
1973     /******************************************************************
1974      Created By      :  smaddali
1975      Date Created By :   11-Jun-03
1976      Purpose         :   loads each record in the hercules view cvrefoffersubj into the interface table
1977                           igs_uc_crfcode_ints with record status N and code_type = SB
1978      Known limitations,enhancements,remarks:
1979      Change History
1980      Who       When         What
1981     ***************************************************************** */
1982 
1983       -- Get all the records from hercules view whose timestamp is > passed timestamp
1984       -- or get all the records in hercules view if the timestamp passed is null
1985       CURSOR c_cvoffsbj IS
1986       SELECT DECODE(RTRIM(subjcode),NULL, RPAD('*',LENGTH(subjcode),'*'), RTRIM(subjcode)) subjcode
1987            ,RTRIM(subjtext) subjtext
1988       FROM igs_uc_u_cvrefoffersubj_2003   ;
1989 
1990       -- Variables
1991       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
1992       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.offersubjdate%TYPE ;
1993       l_count NUMBER ;
1994 
1995   BEGIN
1996        -- set syncronization required to false
1997        g_sync_reqd := FALSE;
1998        l_count := 0 ;
1999 
2000       -- log message that this view is being loaded
2001        log_start('CVREFOFFERSUBJ ON ') ;
2002 
2003       -- get the max timestamp of this hercules view
2004       l_new_max_timestamp := g_refamend_timestamp.offersubjdate ;
2005 
2006       -- Get the old timestamp for this view in the configured cycle
2007       Herc_timestamp_exists('CVREFOFFERSUBJ', p_old_timestamp) ;
2008       -- if there is a difference in the timestamps then load all records from hercules view
2009       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2010 
2011                -- Obsolete all records in interface table with status N
2012                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'SB' ;
2013 
2014                -- create interface records for each record in the hercules view
2015                FOR c_cvoffsbj_rec IN c_cvoffsbj LOOP
2016                       -- set x_sync_read to true if the loop is entered even once
2017                       g_sync_reqd := TRUE;
2018 
2019                       -- copy hercules record into interface table with record status N
2020                       INSERT INTO igs_uc_crfcode_ints (  code_type,
2021                                                          code,
2022                                                          code_text,
2023                                                          record_status,
2024                                                          error_code )
2025                                              VALUES (    'SB',
2026                                                          c_cvoffsbj_rec.subjcode,
2027                                                          c_cvoffsbj_rec.subjtext,
2028                                                          'N',
2029                                                          NULL) ;
2030             -- increment count of records
2031             l_count := l_count + 1;
2032 
2033                END LOOP ;
2034       END IF ;  -- old and new timetamps differ
2035 
2036       IF g_sync_reqd THEN
2037                -- update /insert the timestamp record with new max timestamp
2038                ins_upd_timestamp ('CVREFOFFERSUBJ',  l_new_max_timestamp) ;
2039 
2040                 -- log message that this view has been loaded
2041                 log_complete('CVREFOFFERSUBJ', l_count) ;
2042       ELSE
2043                 -- log message that this view is already in sync and need not be loaded
2044                log_already_insync('CVREFOFFERSUBJ') ;
2045       END IF;
2046       COMMIT;
2047 
2048   EXCEPTION
2049       WHEN OTHERS THEN
2050                ROLLBACK;
2051                write_to_log(SQLERRM);
2052                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2053                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFOFFERSUBJ_2003');
2054                igs_ge_msg_stack.add;
2055                app_exception.raise_exception ;
2056   END   load_cvrefoffersubj_2003  ;
2057 
2058   PROCEDURE load_cvrefpocc_2003 IS
2059     /******************************************************************
2060      Created By      :  smaddali
2061      Date Created By :   11-Jun-03
2062      Purpose         :   loads each record in the hercules view cvrefpocc into the interface table
2063                           igs_uc_crefpoc_ints  with record status N
2064      Known limitations,enhancements,remarks:
2065      Change History
2066      Who       When         What
2067     ***************************************************************** */
2068 
2069       -- Get all the records from hercules view whose timestamp is > passed timestamp
2070       -- or get all the records in hercules view if the timestamp passed is null
2071       CURSOR c_cvpocc IS
2072       SELECT pocc
2073           ,socialclass
2074           ,RTRIM(occupationtext) occupationtext
2075           ,RTRIM(alternativetext) alternativetext
2076           ,alternateclass1
2077           ,alternateclass2
2078           ,socioeconomic
2079       FROM igs_uc_u_cvrefpocc_2003 ;
2080 
2081       -- Variables
2082       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2083       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.poccdate%TYPE ;
2084       l_count NUMBER ;
2085 
2086   BEGIN
2087        -- set syncronization required to false
2088        g_sync_reqd := FALSE;
2089        l_count := 0 ;
2090 
2091       -- log message that this view is being loaded
2092        log_start('CVREFPOCC ON ') ;
2093 
2094       -- get the max timestamp of this hercules view
2095       l_new_max_timestamp := g_refamend_timestamp.poccdate ;
2096 
2097       -- Get the old timestamp for this view in the configured cycle
2098       Herc_timestamp_exists('CVREFPOCC', p_old_timestamp) ;
2099       -- if there is a difference in the timestamps then load all records from hercules view
2100       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2101 
2102                -- Obsolete all records in interface table with status N
2103                UPDATE igs_uc_crefpoc_ints   SET record_status = 'O' WHERE record_status = 'N' ;
2104 
2105                -- create interface records for each record in the hercules view
2106                FOR c_cvpocc_rec IN c_cvpocc LOOP
2107                       -- set x_sync_read to true if the loop is entered even once
2108                       g_sync_reqd := TRUE;
2109 
2110                       --Validate varchar to number conversion
2111                       IF  is_valid(c_cvpocc_rec.pocc ,'CVREFPOCC','POCC','NUMBER') AND
2112                           is_valid(c_cvpocc_rec.socialclass ,'CVREFPOCC','SocialClass','NUMBER') AND
2113                           is_valid(c_cvpocc_rec.alternateclass1,'CVREFPOCC','AlternateClass1','NUMBER') AND
2114                           is_valid(c_cvpocc_rec.alternateclass2,'CVREFPOCC','AlternateClass2','NUMBER') AND
2115                           is_valid(c_cvpocc_rec.socioeconomic,'CVREFPOCC','SocioEconomic','NUMBER') THEN
2116 
2117                           -- copy hercules record into interface table with record status N
2118                           INSERT INTO igs_uc_crefpoc_ints  ( pocc,
2119                                                              socialclass,
2120                                                              occupationtext,
2121                                                              alternativetext,
2122                                                              alternateclass1,
2123                                                              alternateclass2,
2124                                                              socioeconomic,
2125                                                              record_status,
2126                                                              error_code )
2127                                                  VALUES (   c_cvpocc_rec.pocc,
2128                                                             c_cvpocc_rec.socialclass,
2129                                                             c_cvpocc_rec.occupationtext,
2130                                                             c_cvpocc_rec.alternativetext,
2131                                                             c_cvpocc_rec.alternateclass1,
2132                                                             c_cvpocc_rec.alternateclass2,
2133                                                             c_cvpocc_rec.socioeconomic,
2134                                                             'N',
2135                                                             NULL) ;
2136                           -- increment count of records
2137                           l_count := l_count + 1;
2138 
2139                       END IF;
2140 
2141                END LOOP ;
2142       END IF ;  -- old and new timestamps differ
2143 
2144       IF g_sync_reqd THEN
2145                -- update /insert the timestamp record with new max timestamp
2146                ins_upd_timestamp ('CVREFPOCC',  l_new_max_timestamp) ;
2147 
2148               -- log message that this view has been loaded
2149                log_complete('CVREFPOCC', l_count) ;
2150       ELSE
2151                 -- log message that this view is already in sync and need not be loaded
2152                log_already_insync('CVREFPOCC') ;
2153       END IF ;
2154       COMMIT;
2155 
2156   EXCEPTION
2157       WHEN OTHERS THEN
2158                ROLLBACK;
2159                write_to_log(SQLERRM);
2160                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2161                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFPOCC_2003');
2162                igs_ge_msg_stack.add;
2163                app_exception.raise_exception ;
2164   END  load_cvrefpocc_2003   ;
2165 
2166   PROCEDURE load_cvrefrescat_2003 IS
2167     /******************************************************************
2168      Created By      :  smaddali
2169      Date Created By :   11-Jun-03
2170      Purpose         :    loads each record in the hercules view cvrefrescat into the interface table
2171                            igs_uc_crfcode_ints with record status N and code_type = RC
2172      Known limitations,enhancements,remarks:
2173      Change History
2174      Who       When         What
2175     ***************************************************************** */
2176 
2177       -- Get all the records from hercules view whose timestamp is > passed timestamp
2178       -- or get all the records in hercules view if the timestamp passed is null
2179       CURSOR c_cvrescat IS
2180       SELECT DECODE(RTRIM(rescat),NULL, RPAD('*',LENGTH(rescat),'*'), RTRIM(rescat)) rescat
2181            ,RTRIM(rescattext) rescattext
2182       FROM igs_uc_u_cvrefrescat_2003  ;
2183 
2184       -- Variables
2185       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2186       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.rescatdate%TYPE ;
2187       l_count NUMBER ;
2188 
2189   BEGIN
2190        -- set syncronization required to false
2191        g_sync_reqd := FALSE;
2192        l_count := 0 ;
2193 
2194       -- log message that this view is being loaded
2195        log_start('CVREFRESCAT ON ') ;
2196 
2197       -- get the max timestamp of this hercules view
2198       l_new_max_timestamp := g_refamend_timestamp.rescatdate ;
2199 
2200       -- Get the old timestamp for this view in the configured cycle
2201       Herc_timestamp_exists('CVREFRESCAT', p_old_timestamp) ;
2202       -- if there is a difference in the timestamps then load all records from hercules view
2203       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2204 
2205                -- Obsolete all records in interface table with status N
2206                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'RC' ;
2207 
2208                -- create interface records for each record in the hercules view
2209                FOR c_cvrescat_rec IN c_cvrescat LOOP
2210                       -- set x_sync_read to true if the loop is entered even once
2211                       g_sync_reqd := TRUE;
2212 
2213                       -- copy hercules record into interface table with record status N
2214                       INSERT INTO igs_uc_crfcode_ints (  code_type,
2215                                                          code,
2216                                                          code_text,
2217                                                          record_status,
2218                                                          error_code )
2219                                              VALUES (    'RC',
2220                                                          c_cvrescat_rec.rescat,
2221                                                          c_cvrescat_rec.rescattext,
2222                                                          'N',
2223                                                          NULL) ;
2224             -- increment count of records
2225             l_count := l_count + 1;
2226 
2227                END LOOP ;
2228       END IF ;  -- old and new timetamps differ
2229 
2230       IF g_sync_reqd THEN
2231                -- update /insert the timestamp record with new max timestamp
2232                ins_upd_timestamp ('CVREFRESCAT',l_new_max_timestamp) ;
2233 
2234                -- log message that this view has been loaded
2235                 log_complete('CVREFRESCAT', l_count) ;
2236       ELSE
2237                 -- log message that this view is already in sync and need not be loaded
2238                log_already_insync('CVREFRESCAT') ;
2239       END IF ;
2240       COMMIT;
2241 
2242   EXCEPTION
2243       WHEN OTHERS THEN
2244                ROLLBACK;
2245                write_to_log(SQLERRM);
2246                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2247                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFRESCAT_2003');
2248                igs_ge_msg_stack.add;
2249                app_exception.raise_exception ;
2250   END    load_cvrefrescat_2003 ;
2251 
2252   PROCEDURE load_cvrefschooltype_2003 IS
2253     /******************************************************************
2254      Created By      :  smaddali
2255      Date Created By :   11-Jun-03
2256      Purpose         :   loads each record in the hercules view cvrefschooltype into the interface table
2257                            igs_uc_crfcode_ints with record status N and code_type = ST
2258      Known limitations,enhancements,remarks:
2259      Change History
2260      Who       When         What
2261     ***************************************************************** */
2262 
2263       -- Get all the records from hercules view whose timestamp is > passed timestamp
2264       -- or get all the records in hercules view if the timestamp passed is null
2265       CURSOR c_cvschtyp IS
2266       SELECT DECODE(RTRIM(schooltype),NULL, RPAD('*',LENGTH(schooltype),'*'), RTRIM(schooltype)) schooltype
2267            ,RTRIM(schooltext) schooltext
2268       FROM igs_uc_u_cvrefschooltype_2003   ;
2269 
2270       -- Variables
2271       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2272       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.schooltype%TYPE ;
2273       l_count NUMBER ;
2274 
2275   BEGIN
2276        -- set syncronization required to false
2277        g_sync_reqd := FALSE;
2278        l_count := 0 ;
2279 
2280       -- log message that this view is being loaded
2281        log_start('CVREFSCHOOLTYPE ON ') ;
2282 
2283       -- get the max timestamp of this hercules view
2284       l_new_max_timestamp := g_refamend_timestamp.schooltype ;
2285 
2286       -- Get the old timestamp for this view in the configured cycle
2287       Herc_timestamp_exists('CVREFSCHOOLTYPE',p_old_timestamp) ;
2288       -- if there is a difference in the timestamps then load all records from hercules view
2289       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2290 
2291                -- Obsolete all records in interface table with status N
2292                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'ST' ;
2293 
2294                -- create interface records for each record in the hercules view
2295                FOR c_cvschtyp_rec IN c_cvschtyp LOOP
2296                       -- set x_sync_read to true if the loop is entered even once
2297                       g_sync_reqd := TRUE;
2298 
2299                       -- copy hercules record into interface table with record status N
2300                       INSERT INTO igs_uc_crfcode_ints (  code_type,
2301                                                          code,
2302                                                          code_text,
2303                                                          record_status,
2304                                                          error_code )
2305                                              VALUES (    'ST',
2306                                                          c_cvschtyp_rec.schooltype,
2307                                                          c_cvschtyp_rec.schooltext,
2308                                                          'N',
2309                                                          NULL) ;
2310             -- increment count of records
2311             l_count := l_count + 1;
2312 
2313                END LOOP ;
2314       END IF ;  -- old and new timetamps differ
2315 
2316       IF g_sync_reqd THEN
2317                -- update /insert the timestamp record with new max timestamp
2318                ins_upd_timestamp ('CVREFSCHOOLTYPE',l_new_max_timestamp) ;
2319 
2320              -- log message that this view has been loaded
2321                log_complete('CVREFSCHOOLTYPE', l_count) ;
2322       ELSE
2323                 -- log message that this view is already in sync and need not be loaded
2324                log_already_insync('CVREFSCHOOLTYPE') ;
2325       END IF ;
2326       COMMIT;
2327 
2328   EXCEPTION
2329       WHEN OTHERS THEN
2330                ROLLBACK;
2331                write_to_log(SQLERRM);
2332                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2333                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFSCHOOLTYPE_2003');
2334                igs_ge_msg_stack.add;
2335                app_exception.raise_exception ;
2336   END    load_cvrefschooltype_2003 ;
2337 
2338   PROCEDURE load_cvrefstatus_2003 IS
2339     /******************************************************************
2340      Created By      :  smaddali
2341      Date Created By :   11-Jun-03
2342      Purpose         :   loads each record in the hercules view cvrefstatus into the interface table
2343                            igs_uc_crfcode_ints with record status N and code_type = SC
2344      Known limitations,enhancements,remarks:
2345      Change History
2346      Who       When         What
2347     ***************************************************************** */
2348 
2349       -- Get all the records from hercules view whose timestamp is > passed timestamp
2350       -- or get all the records in hercules view if the timestamp passed is null
2351       CURSOR c_cvstatus IS
2352       SELECT status
2353            ,RTRIM(statustext) statustext
2354       FROM igs_uc_u_cvrefstatus_2003    ;
2355 
2356       -- Variables
2357       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2358       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.statusdate%TYPE ;
2359       l_count NUMBER ;
2360 
2361   BEGIN
2362        -- set syncronization required to false
2363        g_sync_reqd := FALSE;
2364        l_count := 0 ;
2365 
2366       -- log message that this view is being loaded
2367        log_start('CVREFSTATUS ON ' ) ;
2368 
2369       -- get the max timestamp of this hercules view
2370       l_new_max_timestamp := g_refamend_timestamp.statusdate ;
2371 
2372       -- Get the old timestamp for this view in the configured cycle
2373       Herc_timestamp_exists('CVREFSTATUS', p_old_timestamp) ;
2374       -- if there is a difference in the timestamps then load all records from hercules view
2375       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2376 
2377                -- Obsolete all records in interface table with status N
2378                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'SC' ;
2379 
2380                -- create interface records for each record in the hercules view
2381                FOR c_cvstatus_rec IN c_cvstatus LOOP
2382                       -- set x_sync_read to true if the loop is entered even once
2383                       g_sync_reqd := TRUE;
2384 
2385                       -- copy hercules record into interface table with record status N
2386                       INSERT INTO igs_uc_crfcode_ints (  code_type,
2387                                                          code,
2388                                                          code_text,
2389                                                          record_status,
2390                                                          error_code )
2391                                              VALUES (    'SC',
2392                                                          c_cvstatus_rec.status,
2393                                                          c_cvstatus_rec.statustext,
2394                                                          'N',
2395                                                          NULL) ;
2396             -- increment count of records
2397             l_count := l_count + 1;
2398 
2399                END LOOP ;
2400       END IF ;  -- old and new timetamps differ
2401 
2402       IF g_sync_reqd THEN
2403                -- update /insert the timestamp record with new max timestamp
2404                ins_upd_timestamp ('CVREFSTATUS', l_new_max_timestamp) ;
2405 
2406               -- log message that this view has been loaded
2407                log_complete('CVREFSTATUS', l_count ) ;
2408       ELSE
2409                 -- log message that this view is already in sync and need not be loaded
2410                log_already_insync('CVREFSTATUS') ;
2411       END IF;
2412       COMMIT;
2413 
2414   EXCEPTION
2415       WHEN OTHERS THEN
2416                ROLLBACK;
2417                write_to_log(SQLERRM);
2418                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2419                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFSTATUS_2003');
2420                igs_ge_msg_stack.add;
2421                app_exception.raise_exception ;
2422   END    load_cvrefstatus_2003 ;
2423 
2424   PROCEDURE load_cvreftariff_2003 IS
2425     /******************************************************************
2426      Created By      :  smaddali
2427      Date Created By :   11-Jun-03
2428      Purpose         :  loads each record in the hercules view cvreftariff into the interface table
2429                           igs_uc_ctariff_ints  with record status N
2430      Known limitations,enhancements,remarks:
2431      Change History
2432      Who       When         What
2433     ***************************************************************** */
2434 
2435       -- Get all the records from hercules view whose timestamp is > passed timestamp
2436       -- or get all the records in hercules view if the timestamp passed is null
2437       CURSOR c_cvtariff IS
2438       SELECT DECODE(RTRIM(examlevel),NULL, RPAD('*',LENGTH(examlevel),'*'), RTRIM(examlevel)) examlevel
2439           ,DECODE(RTRIM(examgrade),NULL, RPAD('*',LENGTH(examgrade),'*'), RTRIM(examgrade)) examgrade
2440           ,DECODE(RTRIM(tariffscore),NULL, RPAD('*',LENGTH(tariffscore),'*'), RTRIM(tariffscore)) tariffscore
2441       FROM igs_uc_u_cvreftariff_2003  ;
2442 
2443       -- Variables
2444       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2445       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.tariffdate%TYPE ;
2446       l_count NUMBER ;
2447 
2448   BEGIN
2449        -- set syncronization required to false
2450        g_sync_reqd := FALSE;
2451        l_count := 0 ;
2452 
2453       -- log message that this view is being loaded
2454        log_start('CVREFTARIFF ON ') ;
2455 
2456       -- get the max timestamp of this hercules view
2457       l_new_max_timestamp := g_refamend_timestamp.tariffdate ;
2458 
2459       -- Get the old timestamp for this view in the configured cycle
2460       Herc_timestamp_exists('CVREFTARIFF', p_old_timestamp) ;
2461       -- if there is a difference in the timestamps then load all records from hercules view
2462       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2463 
2464                -- Obsolete all records in interface table with status N
2465                UPDATE igs_uc_ctariff_ints   SET record_status = 'O' WHERE record_status = 'N' ;
2466 
2467                -- create interface records for each record in the hercules view
2468                FOR c_cvtariff_rec IN c_cvtariff LOOP
2469                       -- set x_sync_read to true if the loop is entered even once
2470                       g_sync_reqd := TRUE;
2471 
2472                       -- copy hercules record into interface table with record status N
2473                       INSERT INTO igs_uc_ctariff_ints  ( examlevel,
2474                                                          examgrade,
2475                                                          tariffscore,
2476                                                          record_status,
2477                                                          error_code )
2478                                              VALUES (   c_cvtariff_rec.examlevel,
2479                                                         c_cvtariff_rec.examgrade,
2480                                                         c_cvtariff_rec.tariffscore,
2481                                                         'N',
2482                                                         NULL) ;
2483             -- increment count of records
2484             l_count := l_count + 1;
2485 
2486                END LOOP ;
2487       END IF ;  -- old and new timestamps differ
2488 
2489       IF g_sync_reqd THEN
2490                -- update /insert the timestamp record with new max timestamp
2491                ins_upd_timestamp ('CVREFTARIFF',  l_new_max_timestamp) ;
2492 
2493               -- log message that this view has been loaded
2494                log_complete('CVREFTARIFF', l_count) ;
2495       ELSE
2496                 -- log message that this view is already in sync and need not be loaded
2497                log_already_insync('CVREFTARIFF') ;
2498        END IF ;
2499       COMMIT;
2500 
2501   EXCEPTION
2502       WHEN OTHERS THEN
2503                ROLLBACK;
2504                write_to_log(SQLERRM);
2505                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2506                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFTARIFF_2003');
2507                igs_ge_msg_stack.add;
2508                app_exception.raise_exception ;
2509   END   load_cvreftariff_2003  ;
2510 
2511   PROCEDURE load_cvrefucasgroup_2003 IS
2512     /******************************************************************
2513      Created By      :  smaddali
2514      Date Created By :   11-Jun-03
2515      Purpose         :   loads each record in the hercules view cvrefucasgroup into the interface table
2516                            igs_uc_crfcode_ints with record status N and code_type = GN
2517      Known limitations,enhancements,remarks:
2518      Change History
2519      Who       When         What
2520     ***************************************************************** */
2521 
2522       -- Get all the records from hercules view whose timestamp is > passed timestamp
2523       -- or get all the records in hercules view if the timestamp passed is null
2524       CURSOR c_cvugroup IS
2525       SELECT groupno
2526            ,RTRIM(groupname) groupname
2527       FROM igs_uc_u_cvrefucasgroup_2003   ;
2528 
2529       -- Variables
2530       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
2531       l_new_max_timestamp igs_uc_u_cvrefamendments_2003.ucasgroupdate%TYPE ;
2532       l_count NUMBER ;
2533 
2534   BEGIN
2535        -- set syncronization required to false
2536        g_sync_reqd := FALSE;
2537        l_count := 0 ;
2538 
2539       -- log message that this view is being loaded
2540        log_start('CVREFUCASGROUP ON ') ;
2541 
2542       -- get the max timestamp of this hercules view
2543       l_new_max_timestamp := g_refamend_timestamp.ucasgroupdate ;
2544 
2545       -- Get the old timestamp for this view in the configured cycle
2546       Herc_timestamp_exists('CVREFUCASGROUP', p_old_timestamp) ;
2547       -- if there is a difference in the timestamps then load all records from hercules view
2548       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
2549 
2550                -- Obsolete all records in interface table with status N
2551                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'GN' ;
2552 
2553                -- create interface records for each record in the hercules view
2554                FOR c_cvugroup_rec IN c_cvugroup LOOP
2555                       -- set x_sync_read to true if the loop is entered even once
2556                       g_sync_reqd := TRUE;
2557 
2558                       -- copy hercules record into interface table with record status N
2559                       INSERT INTO igs_uc_crfcode_ints (  code_type,
2560                                                          code,
2561                                                          code_text,
2562                                                          record_status,
2563                                                          error_code )
2564                                              VALUES (    'GN',
2565                                                          c_cvugroup_rec.groupno,
2566                                                          c_cvugroup_rec.groupname,
2567                                                          'N',
2568                                                          NULL) ;
2569             -- increment count of records
2570             l_count := l_count + 1;
2571 
2572                END LOOP ;
2573       END IF ;  -- old and new timetamps differ
2574 
2575       IF g_sync_reqd THEN
2576                -- update /insert the timestamp record with new max timestamp
2577                ins_upd_timestamp ('CVREFUCASGROUP', l_new_max_timestamp) ;
2578 
2579               -- log message that this view has been loaded
2580                log_complete('CVREFUCASGROUP', l_count) ;
2581       ELSE
2582                 -- log message that this view is already in sync and need not be loaded
2583                log_already_insync('CVREFUCASGROUP') ;
2584       END IF ;
2585       COMMIT;
2586 
2587   EXCEPTION
2588       WHEN OTHERS THEN
2589                ROLLBACK;
2590                write_to_log(SQLERRM);
2591                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2592                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFUCASGROUP_2003');
2593                igs_ge_msg_stack.add;
2594                app_exception.raise_exception ;
2595   END   load_cvrefucasgroup_2003  ;
2596 
2597   PROCEDURE load_cvschool_2003 IS
2598     /******************************************************************
2599      Created By      :  smaddali
2600      Date Created By :   11-Jun-03
2601      Purpose         :   loads each record in the hercules view cvschool into the interface table
2602                            igs_uc_cvsch_ints with record status N
2603      Known limitations,enhancements,remarks:
2604      Change History
2605      Who       When         What
2606      jbaber    15-Sep-05    Replace estabgrp value with '*' if NULL for bug 4589994
2607      jbaber    11-Jul-06    Truncate NCN to 5 chars for UCAS 2007 Support
2608     ***************************************************************** */
2609 
2610       -- Get all the records from hercules  view whose timestamp is > passed timestamp
2611       -- or get all the records in hercules view if the timestamp passed is null
2612       CURSOR c_cvschool( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
2613       SELECT school
2614           ,DECODE(RTRIM(sitecode),NULL, RPAD('*',LENGTH(sitecode),'*'), RTRIM(sitecode)) sitecode
2615           ,timestamp
2616           ,RTRIM(schoolname) schoolname
2617           ,namechangedate
2618           ,RTRIM(formername) formername
2619           ,RTRIM(SUBSTR(ncn,1,5)) ncn
2620           ,RTRIM(edexcelncn) edexcelncn
2621           ,RTRIM(dfeecode) dfeecode
2622           ,country
2623           ,RTRIM(lea) lea
2624           ,RTRIM(ucasstatus) ucasstatus
2625           ,NVL(DECODE(RTRIM(estabgrp),NULL, RPAD('*',LENGTH(estabgrp),'*'), RTRIM(estabgrp)),'*') estabgrp
2626           ,RTRIM(schooltype) schooltype
2627           ,statsdate
2628           ,noroll
2629           ,no5th
2630           ,no6th
2631           ,nohe
2632           ,RTRIM(address1) address1
2633           ,RTRIM(address2) address2
2634           ,RTRIM(address3) address3
2635           ,RTRIM(address4) address4
2636           ,RTRIM(postcode) postcode
2637           ,mailsort
2638           ,RTRIM(townkey) townkey
2639           ,RTRIM(countykey) countykey
2640           ,RTRIM(countrycode) countrycode
2641       FROM igs_uc_u_cvschool_2003
2642       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
2643 
2644       -- get the max timestamp value of the hercules view
2645       CURSOR c_max_timestamp IS
2646       SELECT MAX(timestamp)
2647       FROM igs_uc_u_cvschool_2003  ;
2648 
2649       -- Variables
2650       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
2651       l_new_max_timestamp igs_uc_u_cvschool_2003.timestamp%TYPE ;
2652       l_count NUMBER ;
2653 
2654   BEGIN
2655        -- set syncronization required to false
2656        g_sync_reqd := FALSE;
2657        l_count := 0 ;
2658 
2659       -- log message that this view is being loaded
2660        log_start('CVSCHOOL ON ' ) ;
2661 
2662       -- Get the old timestamp for this view in the configured cycle
2663       Herc_timestamp_exists('CVSCHOOL', p_old_timestamp) ;
2664 
2665        -- create interface records for each record in the hercules view whose timestamp > old timestamp
2666        FOR c_cvschool_rec IN c_cvschool(p_old_timestamp) LOOP
2667               -- set x_sync_read to true if the loop is entered even once
2668               g_sync_reqd := TRUE;
2669 
2670               --Validate varchar to number conversion
2671               IF  is_valid(c_cvschool_rec.school,'CVSCHOOL','School','NUMBER') AND
2672                   is_valid(c_cvschool_rec.country,'CVSCHOOL','Country','NUMBER') THEN
2673 
2674                   -- Obsolete matching records in interface table with status N
2675                   UPDATE igs_uc_cvsch_ints SET record_status = 'O'
2676                   WHERE record_status = 'N' AND school = c_cvschool_rec.school ;
2677 
2678                   -- copy hercules record into interface table with record status N
2679                   INSERT INTO igs_uc_cvsch_ints (   school,
2680                                                     sitecode,
2681                                                     schoolname,
2682                                                     namechangedate,
2683                                                     formername,
2684                                                     ncn,
2685                                                     edexcelncn,
2686                                                     dfeecode,
2687                                                     country,
2688                                                     lea,
2689                                                     ucasstatus,
2690                                                     estabgrp,
2691                                                     schooltype,
2692                                                     statsdate,
2693                                                     noroll,
2694                                                     no5th,
2695                                                     no6th,
2696                                                     nohe,
2697                                                     address1,
2698                                                     address2,
2699                                                     address3,
2700                                                     address4,
2701                                                     postcode,
2702                                                     mailsort,
2703                                                     townkey,
2704                                                     countykey,
2705                                                     countrycode,
2706                                                     record_status,
2707                                                     error_code
2708                                                      )
2709                                          VALUES (   c_cvschool_rec.school,
2710                                                     NVL(c_cvschool_rec.sitecode,'A'),
2711                                                     c_cvschool_rec.schoolname,
2712                                                     c_cvschool_rec.namechangedate,
2713                                                     c_cvschool_rec.formername,
2714                                                     c_cvschool_rec.ncn,
2715                                                     c_cvschool_rec.edexcelncn,
2716                                                     c_cvschool_rec.dfeecode,
2717                                                     c_cvschool_rec.country,
2718                                                     c_cvschool_rec.lea,
2719                                                     c_cvschool_rec.ucasstatus,
2720                                                     c_cvschool_rec.estabgrp,
2721                                                     c_cvschool_rec.schooltype,
2722                                                     c_cvschool_rec.statsdate,
2723                                                     c_cvschool_rec.noroll,
2724                                                     c_cvschool_rec.no5th,
2725                                                     c_cvschool_rec.no6th,
2726                                                     c_cvschool_rec.nohe,
2727                                                     c_cvschool_rec.address1,
2728                                                     c_cvschool_rec.address2,
2729                                                     c_cvschool_rec.address3,
2730                                                     c_cvschool_rec.address4,
2731                                                     c_cvschool_rec.postcode,
2732                                                     c_cvschool_rec.mailsort,
2733                                                     c_cvschool_rec.townkey,
2734                                                     c_cvschool_rec.countykey,
2735                                                     c_cvschool_rec.countrycode,
2736                                                      'N',
2737                                                      NULL) ;
2738                   -- increment count of records
2739                   l_count := l_count + 1;
2740 
2741               END IF;
2742 
2743        END LOOP ;
2744 
2745       IF g_sync_reqd THEN
2746               -- get the max timestamp of this hercules view
2747               OPEN c_max_timestamp ;
2748               FETCH c_max_timestamp INTO l_new_max_timestamp ;
2749               CLOSE c_max_timestamp ;
2750 
2751                -- update /insert the timestamp record with new max timestamp
2752                ins_upd_timestamp ('CVSCHOOL',   l_new_max_timestamp) ;
2753 
2754               -- log message that this view has been loaded
2755                log_complete('CVSCHOOL', l_count ) ;
2756       ELSE
2757                 -- log message that this view is already in sync and need not be loaded
2758                log_already_insync('CVSCHOOL') ;
2759        END IF ;
2760       COMMIT;
2761 
2762   EXCEPTION
2763       WHEN OTHERS THEN
2764                ROLLBACK;
2765                write_to_log(SQLERRM);
2766                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2767                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVSCHOOL_2003');
2768                igs_ge_msg_stack.add;
2769                app_exception.raise_exception ;
2770   END  load_cvschool_2003   ;
2771 
2772 
2773   PROCEDURE load_cvschoolcontact_2003 IS
2774     /******************************************************************
2775      Created By      :  smaddali
2776      Date Created By :   11-Jun-03
2777      Purpose         :   loads each record in the hercules view cvschoolcontact into the interface table
2778                            igs_uc_cschcnt_ints with record status N
2779      Known limitations,enhancements,remarks:
2780      Change History
2781      Who       When         What
2782     ***************************************************************** */
2783 
2784       -- Get all the records from hercules  view whose timestamp is > passed timestamp
2785       -- or get all the records in hercules view if the timestamp passed is null
2786       CURSOR c_cvschcnt( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
2787       SELECT school
2788           ,DECODE(RTRIM(sitecode),NULL, RPAD('*',LENGTH(sitecode),'*'), RTRIM(sitecode)) sitecode
2789           ,contactcode
2790           ,timestamp
2791           ,RTRIM(contactpost) contactpost
2792           ,RTRIM(contactname) contactname
2793           ,RTRIM(telephone) telephone
2794           ,RTRIM(fax) fax
2795           ,RTRIM(email) email
2796           ,RTRIM(principal) principal
2797           ,RTRIM(lists) lists
2798           ,RTRIM(orders) orders
2799           ,RTRIM(forms) forms
2800           ,RTRIM(referee) referee
2801           ,RTRIM(careers) careers
2802           ,RTRIM(eascontact) eascontact
2803       FROM igs_uc_u_cvschoolcontact_2003
2804       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
2805 
2806       -- get the max timestamp value of the hercules view
2807       CURSOR c_max_timestamp IS
2808       SELECT MAX(timestamp)
2809       FROM igs_uc_u_cvschoolcontact_2003  ;
2810 
2811       -- Variables
2812       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
2813       l_new_max_timestamp igs_uc_u_cvschoolcontact_2003.timestamp%TYPE ;
2814       l_count NUMBER ;
2815 
2816   BEGIN
2817        -- set syncronization required to false
2818        g_sync_reqd := FALSE;
2819        l_count := 0 ;
2820 
2821       -- log message that this view is being loaded
2822         log_start('CVSCHOOLCONTACT ON ') ;
2823 
2824       -- Get the old timestamp for this view in the configured cycle
2825       Herc_timestamp_exists('CVSCHOOLCONTACT', p_old_timestamp) ;
2826 
2827        -- create interface records for each record in the hercules view whose timestamp > old timestamp
2828        FOR c_cvschcnt_rec IN c_cvschcnt(p_old_timestamp) LOOP
2829               -- set x_sync_read to true if the loop is entered even once
2830               g_sync_reqd := TRUE;
2831 
2832               --Validate varchar to number conversion
2833               IF  is_valid(c_cvschcnt_rec.school,'CVSCHOOLCONTACT','School','NUMBER') AND
2834                   is_valid(c_cvschcnt_rec.contactcode,'CVSCHOOLCONTACT','ContactCode','NUMBER') THEN
2835 
2836                   -- Obsolete matching records in interface table with status N
2837                   UPDATE igs_uc_cschcnt_ints SET record_status = 'O'
2838                   WHERE  record_status = 'N' AND school = c_cvschcnt_rec.school
2839                   AND sitecode = NVL(c_cvschcnt_rec.sitecode,'A') AND contactcode = c_cvschcnt_rec.contactcode  ;
2840 
2841                   -- copy hercules record into interface table with record status N
2842                   INSERT INTO igs_uc_cschcnt_ints ( school,
2843                                                     sitecode,
2844                                                     contactcode,
2845                                                     contactpost,
2846                                                     contactname,
2847                                                     telephone,
2848                                                     fax,
2849                                                     email,
2850                                                     principal,
2851                                                     lists,
2852                                                     orders,
2853                                                     forms,
2854                                                     referee,
2855                                                     careers,
2856                                                     eascontact,
2857                                                     record_status,
2858                                                     error_code
2859                                                      )
2860                                          VALUES (   c_cvschcnt_rec.school,
2861                                                     NVL(c_cvschcnt_rec.sitecode,'A'),
2862                                                     c_cvschcnt_rec.contactcode,
2863                                                     c_cvschcnt_rec.contactpost,
2864                                                     c_cvschcnt_rec.contactname,
2865                                                     c_cvschcnt_rec.telephone,
2866                                                     c_cvschcnt_rec.fax,
2867                                                     c_cvschcnt_rec.email,
2868                                                     c_cvschcnt_rec.principal,
2869                                                     c_cvschcnt_rec.lists,
2870                                                     c_cvschcnt_rec.orders,
2871                                                     c_cvschcnt_rec.forms,
2872                                                     c_cvschcnt_rec.referee,
2873                                                     c_cvschcnt_rec.careers,
2874                                                     c_cvschcnt_rec.eascontact,
2875                                                      'N',
2876                                                      NULL) ;
2877                   -- increment count of records
2878                   l_count := l_count + 1;
2879 
2880               END IF;
2881 
2882        END LOOP ;
2883 
2884       IF g_sync_reqd THEN
2885               -- get the max timestamp of this hercules view
2886               OPEN c_max_timestamp ;
2887               FETCH c_max_timestamp INTO l_new_max_timestamp ;
2888               CLOSE c_max_timestamp ;
2889 
2890                -- update /insert the timestamp record with new max timestamp
2891                ins_upd_timestamp ('CVSCHOOLCONTACT', l_new_max_timestamp) ;
2892 
2893               -- log message that this view has been loaded
2894                log_complete('CVSCHOOLCONTACT', l_count) ;
2895       ELSE
2896                 -- log message that this view is already in sync and need not be loaded
2897                log_already_insync('CVSCHOOLCONTACT') ;
2898       END IF ;
2899       COMMIT;
2900 
2901   EXCEPTION
2902       WHEN OTHERS THEN
2903                ROLLBACK;
2904                write_to_log(SQLERRM);
2905                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
2906                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVSCHOOLCONTACT_2003');
2907                igs_ge_msg_stack.add;
2908                app_exception.raise_exception ;
2909   END  load_cvschoolcontact_2003   ;
2910 
2911 
2912   PROCEDURE load_uvcontact_2003 IS
2913     /******************************************************************
2914      Created By      :  smaddali
2915      Date Created By :   11-Jun-03
2916      Purpose         :    loads each record in the hercules view uvcontact into the interface table
2917                            igs_uc_ucntact_ints with record status N
2918      Known limitations,enhancements,remarks:
2919      Change History
2920      Who       When         What
2921     ***************************************************************** */
2922 
2923       -- Get all the records from hercules  view whose timestamp is > passed timestamp
2924       -- or get all the records in hercules view if the timestamp passed is null
2925       CURSOR c_uvcnt( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
2926       SELECT DECODE(RTRIM(contactcode),NULL, RPAD('*',LENGTH(contactcode),'*'), RTRIM(contactcode)) contactcode
2927           ,timestamp
2928           ,RTRIM(updater) updater
2929           ,DECODE(RTRIM(name),NULL, RPAD('*',LENGTH(name),'*'), RTRIM(name)) name
2930           ,DECODE(RTRIM(post),NULL, RPAD('*',LENGTH(post),'*'), RTRIM(post)) post
2931           ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
2932           ,RTRIM(address2) address2
2933           ,RTRIM(address3) address3
2934           ,RTRIM(address4) address4
2935           ,RTRIM(telephone) telephone
2936           ,RTRIM(email) email
2937           ,RTRIM(fax) fax
2938       FROM igs_uc_u_uvcontact_2003
2939       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
2940 
2941       -- get the max timestamp value of the hercules view
2942       CURSOR c_max_timestamp IS
2943       SELECT MAX(timestamp)
2944       FROM igs_uc_u_uvcontact_2003  ;
2945 
2946       -- Variables
2947       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
2948       l_new_max_timestamp igs_uc_u_uvcontact_2003.timestamp%TYPE ;
2949       l_count NUMBER ;
2950 
2951   BEGIN
2952        -- set syncronization required to false
2953        g_sync_reqd := FALSE;
2954        l_count := 0 ;
2955 
2956       -- log message that this view is being loaded
2957         log_start('UVCONTACT ON ') ;
2958 
2959       -- Get the old timestamp for this view in the configured cycle
2960       Herc_timestamp_exists('UVCONTACT', p_old_timestamp) ;
2961 
2962        -- create interface records for each record in the hercules view whose timestamp > old timestamp
2963        FOR c_uvcnt_rec IN c_uvcnt(p_old_timestamp) LOOP
2964               -- set x_sync_read to true if the loop is entered even once
2965               g_sync_reqd := TRUE;
2966 
2967               -- Obsolete matching records in interface table with status N
2968               UPDATE igs_uc_ucntact_ints SET record_status = 'O'
2969               WHERE record_status = 'N' AND contactcode = c_uvcnt_rec.contactcode  ;
2970 
2971               -- copy hercules record into interface table with record status N
2972               INSERT INTO igs_uc_ucntact_ints (  contactcode,
2973                                                  updater,
2974                                                  name,
2975                                                  post,
2976                                                  address1,
2977                                                  address2,
2978                                                  address3,
2979                                                  address4,
2980                                                  telephone,
2981                                                  email,
2982                                                  fax,
2983                                                 record_status,
2984                                                 error_code
2985                                                  )
2986                                      VALUES (   c_uvcnt_rec.contactcode,
2987                                                 c_uvcnt_rec.updater,
2988                                                 c_uvcnt_rec.name,
2989                                                 c_uvcnt_rec.post,
2990                                                 c_uvcnt_rec.address1,
2991                                                 c_uvcnt_rec.address2,
2992                                                 c_uvcnt_rec.address3,
2993                                                 c_uvcnt_rec.address4,
2994                                                 c_uvcnt_rec.telephone,
2995                                                 c_uvcnt_rec.email,
2996                                                 c_uvcnt_rec.fax,
2997                                                  'N',
2998                                                  NULL) ;
2999         -- increment count of records
3000         l_count := l_count + 1;
3001 
3002        END LOOP ;
3003 
3004       IF g_sync_reqd THEN
3005               -- get the max timestamp of this hercules view
3006               OPEN c_max_timestamp ;
3007               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3008               CLOSE c_max_timestamp ;
3009 
3010                -- update /insert the timestamp record with new max timestamp
3011                ins_upd_timestamp ('UVCONTACT', l_new_max_timestamp) ;
3012 
3013               -- log message that this view has been loaded
3014                log_complete('UVCONTACT', l_count) ;
3015       ELSE
3016                 -- log message that this view is already in sync and need not be loaded
3017                log_already_insync('UVCONTACT') ;
3018       END IF ;
3019       COMMIT;
3020 
3021   EXCEPTION
3022       WHEN OTHERS THEN
3023                ROLLBACK;
3024                write_to_log(SQLERRM);
3025                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3026                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCONTACT_2003');
3027                igs_ge_msg_stack.add;
3028                app_exception.raise_exception ;
3029   END  load_uvcontact_2003   ;
3030 
3031 
3032   PROCEDURE load_uvcontgrp_2003 IS
3033     /******************************************************************
3034      Created By      :  smaddali
3035      Date Created By :   11-Jun-03
3036      Purpose         :    loads each record in the hercules view uvcontgrp into the interface table
3037                            igs_uc_ucntgrp_ints with record status N
3038      Known limitations,enhancements,remarks:
3039      Change History
3040      Who       When         What
3041     ***************************************************************** */
3042 
3043       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3044       -- or get all the records in hercules view if the timestamp passed is null
3045       CURSOR c_uvcntgr( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3046       SELECT DECODE(RTRIM(contactcode),NULL, RPAD('*',LENGTH(contactcode),'*'), RTRIM(contactcode)) contactcode
3047           ,ucasgroup
3048           ,RTRIM(updater) updater
3049           ,timestamp
3050       FROM igs_uc_u_uvcontgrp_2003
3051       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3052 
3053       -- get the max timestamp value of the hercules view
3054       CURSOR c_max_timestamp IS
3055       SELECT MAX(timestamp)
3056       FROM igs_uc_u_uvcontgrp_2003  ;
3057 
3058       -- Variables
3059       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3060       l_new_max_timestamp igs_uc_u_uvcontgrp_2003.timestamp%TYPE ;
3061       l_count NUMBER ;
3062 
3063   BEGIN
3064        -- set syncronization required to false
3065        g_sync_reqd := FALSE;
3066        l_count := 0 ;
3067 
3068       -- log message that this view is being loaded
3069        log_start('UVCONTGRP ON ') ;
3070 
3071       -- Get the old timestamp for this view in the configured cycle
3072       Herc_timestamp_exists('UVCONTGRP', p_old_timestamp) ;
3073 
3074        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3075        FOR c_uvcntgr_rec IN c_uvcntgr(p_old_timestamp) LOOP
3076               -- set x_sync_read to true if the loop is entered even once
3077               g_sync_reqd := TRUE;
3078 
3079               -- Obsolete matching records in interface table with status N
3080               UPDATE igs_uc_ucntgrp_ints SET record_status = 'O'
3081               WHERE record_status = 'N' AND contactcode = c_uvcntgr_rec.contactcode
3082               AND ucasgroup =  c_uvcntgr_rec.ucasgroup ;
3083 
3084               -- copy hercules record into interface table with record status N
3085               INSERT INTO igs_uc_ucntgrp_ints (  contactcode,
3086                                                  ucasgroup,
3087                                                  updater,
3088                                                  record_status,
3089                                                  error_code
3090                                                  )
3091                                      VALUES (   c_uvcntgr_rec.contactcode,
3092                                                 c_uvcntgr_rec.ucasgroup,
3093                                                 c_uvcntgr_rec.updater,
3094                                                  'N',
3095                                                  NULL) ;
3096         -- increment count of records
3097         l_count := l_count + 1;
3098 
3099        END LOOP ;
3100 
3101       IF g_sync_reqd THEN
3102               -- get the max timestamp of this hercules view
3103               OPEN c_max_timestamp ;
3104               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3105               CLOSE c_max_timestamp ;
3106 
3107                -- update /insert the timestamp record with new max timestamp
3108                ins_upd_timestamp ('UVCONTGRP', l_new_max_timestamp) ;
3109 
3110               -- log message that this view has been loaded
3111                log_complete('UVCONTGRP', l_count) ;
3112       ELSE
3113                 -- log message that this view is already in sync and need not be loaded
3114                log_already_insync('UVCONTGRP') ;
3115        END IF ;
3116       COMMIT;
3117 
3118   EXCEPTION
3119       WHEN OTHERS THEN
3120                ROLLBACK;
3121                write_to_log(SQLERRM);
3122                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3123                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCONTGRP_2003');
3124                igs_ge_msg_stack.add;
3125                app_exception.raise_exception ;
3126   END  load_uvcontgrp_2003   ;
3127 
3128 
3129   PROCEDURE load_uvcourse_2003 IS
3130     /******************************************************************
3131      Created By      :  smaddali
3132      Date Created By :   11-Jun-03
3133      Purpose         :   loads each record in the hercules view uvcourse into the interface table
3134                            igs_uc_ucrse_ints with record status N
3135      Known limitations,enhancements,remarks:
3136      Change History
3137      Who       When         What
3138      jbaber    15-Sep-05    Replace campus value with '*' if NULL for bug 4589994
3139     ***************************************************************** */
3140 
3141       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3142       -- or get all the records in hercules view if the timestamp passed is null
3143       CURSOR c_uvcrse( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3144       SELECT DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
3145           ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
3146           ,timestamp
3147           ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
3148           ,RTRIM(faculty) faculty
3149           ,RTRIM(shorttitle) shorttitle
3150           ,RTRIM(longtitle) longtitle
3151           ,RTRIM(validcurr) validcurr
3152           ,RTRIM(validdefer) validdefer
3153           ,term1start
3154           ,term1end
3155           ,term2start
3156           ,term2end
3157           ,term3start
3158           ,term3end
3159           ,term4start
3160           ,term4end
3161           ,RTRIM(jointadmission) jointadmission
3162           ,RTRIM(openextra) openextra
3163       FROM igs_uc_u_uvcourse_2003
3164       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3165 
3166       -- get the max timestamp value of the hercules view
3167       CURSOR c_max_timestamp IS
3168       SELECT MAX(timestamp)
3169       FROM igs_uc_u_uvcourse_2003  ;
3170 
3171       -- Variables
3172       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3173       l_new_max_timestamp igs_uc_u_uvcourse_2003.timestamp%TYPE ;
3174       l_count NUMBER ;
3175 
3176   BEGIN
3177        -- set syncronization required to false
3178        g_sync_reqd := FALSE;
3179        l_count := 0 ;
3180 
3181       -- log message that this view is being loaded
3182        log_start('UVCOURSE ON ') ;
3183 
3184       -- Get the old timestamp for this view in the configured cycle
3185       Herc_timestamp_exists('UVCOURSE', p_old_timestamp) ;
3186 
3187        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3188        FOR c_uvcrse_rec IN c_uvcrse(p_old_timestamp) LOOP
3189               -- set x_sync_read to true if the loop is entered even once
3190               g_sync_reqd := TRUE;
3191 
3192               -- Obsolete matching records in interface table with status N
3193               UPDATE igs_uc_ucrse_ints SET record_status = 'O'
3194               WHERE record_status = 'N' AND course = c_uvcrse_rec.course
3195               AND campus =  c_uvcrse_rec.campus ;
3196 
3197               -- copy hercules record into interface table with record status N
3198               INSERT INTO igs_uc_ucrse_ints (   course,
3199                                                 campus,
3200                                                 updater,
3201                                                 faculty,
3202                                                 shorttitle,
3203                                                 longtitle,
3204                                                 validcurr,
3205                                                 validdefer,
3206                                                 term1start,
3207                                                 term1end,
3208                                                 term2start,
3209                                                 term2end,
3210                                                 term3start,
3211                                                 term3end,
3212                                                 term4start,
3213                                                 term4end,
3214                                                 jointadmission,
3215                                                 openextra,
3216                                                 record_status,
3217                                                 error_code
3218                                                  )
3219                                      VALUES (   c_uvcrse_rec.course,
3220                                                 c_uvcrse_rec.campus,
3221                                                 c_uvcrse_rec.updater,
3222                                                 c_uvcrse_rec.faculty,
3223                                                 c_uvcrse_rec.shorttitle,
3224                                                 c_uvcrse_rec.longtitle,
3225                                                 c_uvcrse_rec.validcurr,
3226                                                 c_uvcrse_rec.validdefer,
3227                                                 c_uvcrse_rec.term1start,
3228                                                 c_uvcrse_rec.term1end,
3229                                                 c_uvcrse_rec.term2start,
3230                                                 c_uvcrse_rec.term2end,
3231                                                 c_uvcrse_rec.term3start,
3232                                                 c_uvcrse_rec.term3end,
3233                                                 c_uvcrse_rec.term4start,
3234                                                 c_uvcrse_rec.term4end,
3235                                                 c_uvcrse_rec.jointadmission,
3236                                                 c_uvcrse_rec.openextra,
3237                                                  'N',
3238                                                  NULL) ;
3239         -- increment count of records
3240         l_count := l_count + 1;
3241 
3242        END LOOP ;
3243 
3244       IF g_sync_reqd THEN
3245               -- get the max timestamp of this hercules view
3246               OPEN c_max_timestamp ;
3247               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3248               CLOSE c_max_timestamp ;
3249 
3250                -- update /insert the timestamp record with new max timestamp
3251                ins_upd_timestamp ('UVCOURSE', l_new_max_timestamp) ;
3252 
3253               -- log message that this view has been loaded
3254                log_complete('UVCOURSE', l_count) ;
3255       ELSE
3256                 -- log message that this view is already in sync and need not be loaded
3257                log_already_insync('UVCOURSE') ;
3258       END IF ;
3259       COMMIT;
3260 
3261   EXCEPTION
3262       WHEN OTHERS THEN
3263                ROLLBACK;
3264                write_to_log(SQLERRM);
3265                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3266                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCOURSE_2003');
3267                igs_ge_msg_stack.add;
3268                app_exception.raise_exception ;
3269   END   load_uvcourse_2003  ;
3270 
3271   PROCEDURE load_uvcoursekeyword_2003 IS
3272     /******************************************************************
3273      Created By      :  smaddali
3274      Date Created By :   11-Jun-03
3275      Purpose         :   loads each record in the hercules view uvcoursekeyword into the interface table
3276                            igs_uc_ucrskwd_ints with record status N
3277      Known limitations,enhancements,remarks:
3278      Change History
3279      Who       When         What
3280      rgangara  20-Apr-04    Bug 3496874. Modified UVKeyword processing to process Keyword records as a Set.
3281                             Existing records if any for the course,campus and optioncode would be obsoleted
3282                             before importing keyword records.
3283      jbaber    15-Sep-05    Load NULL for keyno for bug 4589994
3284     ***************************************************************** */
3285 
3286       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3287       -- or get all the records in hercules view if the timestamp passed is null
3288       CURSOR c_uvcrsekyw( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3289       SELECT DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
3290           ,DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)) campus
3291           ,DECODE(RTRIM(optioncode),NULL, RPAD('*',LENGTH(optioncode),'*'), RTRIM(optioncode)) optioncode
3292           ,NULL keyno
3293           ,DECODE(RTRIM(keyword),NULL, RPAD('*',LENGTH(keyword),'*'), RTRIM(keyword)) keyword
3294           ,timestamp
3295           ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
3296           ,RTRIM(active) active
3297       FROM igs_uc_u_uvcoursekeyword_2003
3298       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3299 
3300       -- get the max timestamp value of the hercules view
3301       CURSOR c_max_timestamp IS
3302       SELECT MAX(timestamp)
3303       FROM igs_uc_u_uvcoursekeyword_2003  ;
3304 
3305       -- Variables
3306       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3307       l_new_max_timestamp igs_uc_u_uvcoursekeyword_2003.timestamp%TYPE ;
3308       l_count NUMBER ;
3309 
3310   BEGIN
3311        -- set syncronization required to false
3312        g_sync_reqd := FALSE;
3313        l_count := 0 ;
3314 
3315       -- log message that this view is being loaded
3316        log_start('UVCOURSEKEYWORD ON ') ;
3317 
3318       -- Get the old timestamp for this view in the configured cycle
3319       Herc_timestamp_exists('UVCOURSEKEYWORD', p_old_timestamp) ;
3320 
3321 
3322       -- Obsoleting all the keyword records in INT table for all the DISTINCT combination of course,
3323       -- campus and optioncode having a higher timestamp. This is to ensure that all the Keyword records
3324       -- are processed as a set. If a combination record is imported, all the existing records in the INTS
3325       -- table are to be obsoleted and the new Set is to be imported. This is as part of Bug# 3496874.
3326       -- This approach of Update is adopted from performance reasons otherwise it would have needed another
3327       -- loop and an update which would be exectued as many times as that of the Distinct Course combination.
3328       UPDATE igs_uc_ucrskwd_ints
3329          SET record_status = 'O'
3330       WHERE  record_status = 'N'
3331       AND    (course, campus, optioncode) IN (
3332                     SELECT DISTINCT DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course,
3333                            DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)) campus,
3334                            DECODE(RTRIM(optioncode),NULL, RPAD('*',LENGTH(optioncode),'*'), RTRIM(optioncode)) optioncode
3335                     FROM   igs_uc_u_uvcoursekeyword_2003
3336                     WHERE  (timestamp > p_old_timestamp OR p_old_timestamp IS NULL));
3337 
3338        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3339        FOR c_uvcrsekyw_rec IN c_uvcrsekyw(p_old_timestamp) LOOP
3340               -- set x_sync_read to true if the loop is entered even once
3341               g_sync_reqd := TRUE;
3342 
3343               -- copy hercules record into interface table with record status N
3344               INSERT INTO igs_uc_ucrskwd_ints ( course,
3345                                                 campus,
3346                                                 optioncode,
3347                                                 keyno,
3348                                                 keyword,
3349                                                 updater,
3350                                                 active,
3351                                                 record_status,
3352                                                 error_code
3353                                                  )
3354                                      VALUES (   c_uvcrsekyw_rec.course,
3355                                                 c_uvcrsekyw_rec.campus,
3356                                                 c_uvcrsekyw_rec.optioncode,
3357                                                 c_uvcrsekyw_rec.keyno,
3358                                                 c_uvcrsekyw_rec.keyword,
3359                                                 c_uvcrsekyw_rec.updater,
3360                                                 c_uvcrsekyw_rec.active,
3361                                                  'N',
3362                                                  NULL) ;
3363         -- increment count of records
3364         l_count := l_count + 1;
3365 
3366        END LOOP ;
3367 
3368       IF g_sync_reqd THEN
3369               -- get the max timestamp of this hercules view
3370               OPEN c_max_timestamp ;
3371               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3372               CLOSE c_max_timestamp ;
3373 
3374                -- update /insert the timestamp record with new max timestamp
3375                ins_upd_timestamp ('UVCOURSEKEYWORD', l_new_max_timestamp) ;
3376 
3377               -- log message that this view has been loaded
3378                log_complete('UVCOURSEKEYWORD', l_count) ;
3379       ELSE
3380                 -- log message that this view is already in sync and need not be loaded
3381                log_already_insync('UVCOURSEKEYWORD') ;
3382       END IF ;
3383       COMMIT;
3384 
3385   EXCEPTION
3386       WHEN OTHERS THEN
3387                ROLLBACK;
3388                write_to_log(SQLERRM);
3389                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3390                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCOURSEKEYWORD_2003');
3391                igs_ge_msg_stack.add;
3392                app_exception.raise_exception ;
3393   END  load_uvcoursekeyword_2003   ;
3394 
3395 
3396   PROCEDURE load_uvcoursevacancies_2003 IS
3397     /******************************************************************
3398      Created By      :  smaddali
3399      Date Created By :   11-Jun-03
3400      Purpose         :     loads each record in the hercules view uvcoursevacancies into the interface table
3401                            igs_uc_ucrsvac_ints with record status N
3402      Known limitations,enhancements,remarks:
3403      Change History
3404      Who       When         What
3405     ***************************************************************** */
3406 
3407       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3408       -- or get all the records in hercules view if the timestamp passed is null
3409       CURSOR c_uvcrsevac( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3410       SELECT DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
3411           ,DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)) campus
3412           ,timestamp
3413           ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
3414           ,RTRIM(clupdated) clupdated
3415           ,cldate
3416           ,RTRIM(vacstatus) vacstatus
3417           ,RTRIM(novac) novac
3418           ,score
3419           ,RTRIM(rbfull) rbfull
3420           ,RTRIM(scotvac) scotvac
3421       FROM igs_uc_u_uvcoursevacs_2003
3422       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3423 
3424       -- get the max timestamp value of the hercules view
3425       CURSOR c_max_timestamp IS
3426       SELECT MAX(timestamp)
3427       FROM igs_uc_u_uvcoursevacs_2003  ;
3428 
3429       -- Variables
3430       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3431       l_new_max_timestamp IGS_UC_U_UVCOURSEVACS_2003.timestamp%TYPE ;
3432       l_count NUMBER ;
3433 
3434   BEGIN
3435        -- set syncronization required to false
3436        g_sync_reqd := FALSE;
3437        l_count := 0 ;
3438 
3439       -- log message that this view is being loaded
3440        log_start( 'UVCOURSEVACANCIES ON ' ) ;
3441 
3442       -- Get the old timestamp for this view in the configured cycle
3443       Herc_timestamp_exists('UVCOURSEVACANCIES', p_old_timestamp) ;
3444 
3445        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3446        FOR c_uvcrsevac_rec IN c_uvcrsevac(p_old_timestamp) LOOP
3447               -- set x_sync_read to true if the loop is entered even once
3448               g_sync_reqd := TRUE;
3449 
3450               -- Obsolete matching records in interface table with status N
3451               UPDATE igs_uc_ucrsvac_ints SET record_status = 'O'
3452               WHERE record_status = 'N' AND course = c_uvcrsevac_rec.course
3453               AND campus = c_uvcrsevac_rec.campus  ;
3454 
3455               -- copy hercules record into interface table with record status N
3456               INSERT INTO igs_uc_ucrsvac_ints ( course,
3457                                                 campus,
3458                                                 updater,
3459                                                 clupdated,
3460                                                 cldate,
3461                                                 vacstatus,
3462                                                 novac,
3463                                                 score,
3464                                                 rbfull,
3465                                                 scotvac,
3466                                                 record_status,
3467                                                 error_code
3468                                                  )
3469                                      VALUES (   c_uvcrsevac_rec.course,
3470                                                 c_uvcrsevac_rec.campus,
3471                                                 c_uvcrsevac_rec.updater,
3472                                                 c_uvcrsevac_rec.clupdated,
3473                                                 c_uvcrsevac_rec.cldate,
3474                                                 c_uvcrsevac_rec.vacstatus,
3475                                                 c_uvcrsevac_rec.novac,
3476                                                 c_uvcrsevac_rec.score,
3477                                                 c_uvcrsevac_rec.rbfull,
3478                                                 c_uvcrsevac_rec.scotvac,
3479                                                  'N',
3480                                                  NULL) ;
3481         -- increment count of records
3482         l_count := l_count + 1;
3483 
3484        END LOOP ;
3485 
3486       IF g_sync_reqd THEN
3487               -- get the max timestamp of this hercules view
3488               OPEN c_max_timestamp ;
3489               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3490               CLOSE c_max_timestamp ;
3491 
3492                -- update /insert the timestamp record with new max timestamp
3493                ins_upd_timestamp ('UVCOURSEVACANCIES',l_new_max_timestamp) ;
3494 
3495               -- log message that this view has been loaded
3496                log_complete( 'UVCOURSEVACANCIES', l_count ) ;
3497       ELSE
3498                 -- log message that this view is already in sync and need not be loaded
3499                log_already_insync('UVCOURSEVACANCIES') ;
3500       END IF ;
3501       COMMIT;
3502 
3503   EXCEPTION
3504       WHEN OTHERS THEN
3505                ROLLBACK;
3506                write_to_log(SQLERRM);
3507                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3508                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCOURSEVACANCIES_2003');
3509                igs_ge_msg_stack.add;
3510                app_exception.raise_exception ;
3511   END   load_uvcoursevacancies_2003  ;
3512 
3513   PROCEDURE load_uvcoursevacoptions_2003 IS
3514     /******************************************************************
3515      Created By      :  smaddali
3516      Date Created By :   11-Jun-03
3517      Purpose         :    loads each record in the hercules view uvcoursevacoptions into the interface table
3518                            igs_uc_ucrsvop_ints with record status N
3519      Known limitations,enhancements,remarks:
3520      Change History
3521      Who       When         What
3522     ***************************************************************** */
3523 
3524       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3525       -- or get all the records in hercules view if the timestamp passed is null
3526       CURSOR c_uvcrsevacop( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3527       SELECT  DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
3528           ,DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)) campus
3529           ,DECODE(RTRIM(optioncode),NULL, RPAD('*',LENGTH(optioncode),'*'), RTRIM(optioncode)) optioncode
3530           ,timestamp
3531           ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
3532           ,RTRIM(clupdated) clupdated
3533           ,cldate
3534           ,RTRIM(vacstatus) vacstatus
3535       FROM igs_uc_u_uvcoursevacops_2003
3536       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3537 
3538       -- get the max timestamp value of the hercules view
3539       CURSOR c_max_timestamp IS
3540       SELECT MAX(timestamp)
3541       FROM igs_uc_u_uvcoursevacops_2003  ;
3542 
3543       -- Variables
3544       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3545       l_new_max_timestamp IGS_UC_U_UVCOURSEVACOPS_2003.timestamp%TYPE ;
3546       l_count NUMBER ;
3547 
3548   BEGIN
3549        -- set syncronization required to false
3550        g_sync_reqd := FALSE;
3551        l_count := 0 ;
3552 
3553       -- log message that this view is being loaded
3554        log_start('UVCOURSEVACOPTIONS ON ' ) ;
3555 
3556       -- Get the old timestamp for this view in the configured cycle
3557       Herc_timestamp_exists('UVCOURSEVACOPTIONS', p_old_timestamp) ;
3558 
3559        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3560        FOR c_uvcrsevacop_rec IN c_uvcrsevacop(p_old_timestamp) LOOP
3561 
3562               -- set x_sync_read to true if the loop is entered even once
3563               g_sync_reqd := TRUE;
3564 
3565               -- Obsolete matching records in interface table with status N
3566               UPDATE igs_uc_ucrsvop_ints SET record_status = 'O'
3567               WHERE record_status = 'N' AND course = c_uvcrsevacop_rec.course
3568               AND campus = c_uvcrsevacop_rec.campus AND optioncode = c_uvcrsevacop_rec.optioncode ;
3569 
3570               -- copy hercules record into interface table with record status N
3571               INSERT INTO igs_uc_ucrsvop_ints (  course,
3572                                                  campus,
3573                                                  optioncode,
3574                                                  updater,
3575                                                  clupdated,
3576                                                  cldate,
3577                                                  vacstatus,
3578                                                  record_status,
3579                                                  error_code
3580                                                  )
3581                                      VALUES (    c_uvcrsevacop_rec.course,
3582                                                  c_uvcrsevacop_rec.campus,
3583                                                  c_uvcrsevacop_rec.optioncode,
3584                                                  c_uvcrsevacop_rec.updater,
3585                                                  c_uvcrsevacop_rec.clupdated,
3586                                                  c_uvcrsevacop_rec.cldate,
3587                                                  c_uvcrsevacop_rec.vacstatus,
3588                                                  'N',
3589                                                  NULL) ;
3590         -- increment count of records
3591         l_count := l_count + 1;
3592 
3593        END LOOP ;
3594 
3595       IF g_sync_reqd THEN
3596               -- get the max timestamp of this hercules view
3597               OPEN c_max_timestamp ;
3598               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3599               CLOSE c_max_timestamp ;
3600 
3601                -- update /insert the timestamp record with new max timestamp
3602                ins_upd_timestamp ('UVCOURSEVACOPTIONS', l_new_max_timestamp) ;
3603 
3604               -- log message that this view has been loaded
3605                log_complete('UVCOURSEVACOPTIONS', l_count ) ;
3606       ELSE
3607                 -- log message that this view is already in sync and need not be loaded
3608                log_already_insync('UVCOURSEVACOPTIONS') ;
3609       END IF ;
3610       COMMIT;
3611 
3612   EXCEPTION
3613       WHEN OTHERS THEN
3614                ROLLBACK;
3615                write_to_log(SQLERRM);
3616                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3617                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVCOURSEVACOPTIONS_2003');
3618                igs_ge_msg_stack.add;
3619                app_exception.raise_exception ;
3620   END   load_uvcoursevacoptions_2003  ;
3621 
3622   PROCEDURE load_uvinstitution_2003 IS
3623     /******************************************************************
3624      Created By      :  smaddali
3625      Date Created By :   11-Jun-03
3626      Purpose         :   loads each record in the hercules view uvinstitution into the interface table
3627                            igs_uc_uinst_ints with record status N
3628      Known limitations,enhancements,remarks:
3629      Change History
3630      Who       When         What
3631     ***************************************************************** */
3632 
3633      -- Get all the records from hercules  view whose timestamp is > passed timestamp
3634       -- or get all the records in hercules view if the timestamp passed is null
3635       CURSOR c_uinst ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3636       SELECT  timestamp
3637          ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
3638          ,DECODE(RTRIM(insttype),NULL, RPAD('*',LENGTH(insttype),'*'), RTRIM(insttype)) insttype
3639          ,RTRIM(instshortname) instshortname
3640          ,RTRIM(instname) instname
3641          ,RTRIM(instfullname) instfullname
3642          ,RTRIM(switchboardtelno) switchboardtelno
3643          ,RTRIM(decisioncards) decisioncards
3644          ,RTRIM(recordcards) recordcards
3645          ,RTRIM(labels) labels
3646          ,RTRIM(weeklymovlistseq) weeklymovlistseq
3647          ,RTRIM(weeklymovpaging) weeklymovpaging
3648          ,RTRIM(formseq) formseq
3649          ,RTRIM(eblrequired) eblrequired
3650          ,RTRIM(eblmedia1or2) eblmedia1or2
3651          ,RTRIM(eblmedia3) eblmedia3
3652          ,RTRIM(ebl1or2merged) ebl1or2merged
3653          ,RTRIM(ebl1or2boardgroup) ebl1or2boardgroup
3654          ,RTRIM(ebl3boardgroup) ebl3boardgroup
3655          ,RTRIM(eblncapp) eblncapp
3656          ,RTRIM(eblmajorkey1) eblmajorkey1
3657          ,RTRIM(eblmajorkey2) eblmajorkey2
3658          ,RTRIM(eblmajorkey3) eblmajorkey3
3659          ,RTRIM(eblminorkey1) eblminorkey1
3660          ,RTRIM(eblminorkey2) eblminorkey2
3661          ,RTRIM(eblminorkey3) eblminorkey3
3662          ,RTRIM(eblfinalkey) eblfinalkey
3663          ,RTRIM(odl1) odl1
3664          ,RTRIM(odl1a) odl1a
3665          ,RTRIM(odl2) odl2
3666          ,RTRIM(odl3) odl3
3667          ,RTRIM(odlsummer) odlsummer
3668          ,RTRIM(odlrouteb) odlrouteb
3669          ,RTRIM(monthlyseq) monthlyseq
3670          ,RTRIM(monthlypaper) monthlypaper
3671          ,RTRIM(monthlypage) monthlypage
3672          ,RTRIM(monthlytype) monthlytype
3673          ,RTRIM(junelistseq) junelistseq
3674          ,RTRIM(junelabels) junelabels
3675          ,RTRIM(junenumlabels) junenumlabels
3676          ,RTRIM(courseanalysis) courseanalysis
3677          ,RTRIM(campusused) campusused
3678          ,RTRIM(d3docsrequired) d3docsrequired
3679          ,RTRIM(clearingacceptcopyform) clearingacceptcopyform
3680          ,RTRIM(onlinemessage) onlinemessage
3681          ,RTRIM(ethniclistseq) ethniclistseq
3682       FROM igs_uc_u_uvinstitution_2003
3683       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3684 
3685       -- get the max timestamp value of the hercules view
3686       CURSOR c_max_timestamp IS
3687       SELECT MAX(timestamp)
3688       FROM igs_uc_u_uvinstitution_2003  ;
3689 
3690       -- Variables
3691       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3692       l_new_max_timestamp igs_uc_u_uvinstitution_2003.timestamp%TYPE ;
3693       l_count NUMBER ;
3694 
3695   BEGIN
3696        -- set syncronization required to false
3697        g_sync_reqd := FALSE;
3698        l_count := 0 ;
3699 
3700       -- log message that this view is being loaded
3701        log_start('UVINSTITUTION ON ' ) ;
3702 
3703       -- Get the old timestamp for this view in the configured cycle
3704       Herc_timestamp_exists('UVINSTITUTION', p_old_timestamp) ;
3705 
3706        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3707        FOR c_uinst_rec IN c_uinst(p_old_timestamp) LOOP
3708               -- set x_sync_read to true if the loop is entered even once
3709               g_sync_reqd := TRUE;
3710 
3711               -- Obsolete all records in interface table with status N
3712               UPDATE igs_uc_uinst_ints SET record_status = 'O' WHERE record_status = 'N' ;
3713 
3714               -- copy hercules record into interface table with record status N
3715               INSERT INTO igs_uc_uinst_ints (   updater,
3716                                                 insttype,
3717                                                 instshortname,
3718                                                 instname,
3719                                                 instfullname,
3720                                                 switchboardtelno,
3721                                                 decisioncards,
3722                                                 recordcards,
3723                                                 labels,
3724                                                 weeklymovlistseq,
3725                                                 weeklymovpaging,
3726                                                 formseq,
3727                                                 eblrequired,
3728                                                 eblmedia1or2,
3729                                                 eblmedia3,
3730                                                 ebl1or2merged,
3731                                                 ebl1or2boardgroup,
3732                                                 ebl3boardgroup,
3733                                                 eblncapp,
3734                                                 eblmajorkey1,
3735                                                 eblmajorkey2,
3736                                                 eblmajorkey3,
3737                                                 eblminorkey1,
3738                                                 eblminorkey2,
3739                                                 eblminorkey3,
3740                                                 eblfinalkey,
3741                                                 odl1,
3742                                                 odl1a,
3743                                                 odl2,
3744                                                 odl3,
3745                                                 odlsummer,
3746                                                 odlrouteb,
3747                                                 monthlyseq,
3748                                                 monthlypaper,
3749                                                 monthlypage,
3750                                                 monthlytype,
3751                                                 junelistseq,
3752                                                 junelabels,
3753                                                 junenumlabels,
3754                                                 courseanalysis,
3755                                                 campusused,
3756                                                 d3docsrequired,
3757                                                 clearingacceptcopyform,
3758                                                 onlinemessage,
3759                                                 ethniclistseq,
3760                                                 starx,
3761                                                 record_status,
3762                                                 error_code
3763                                                  )
3764                                      VALUES (   c_uinst_rec.updater,
3765                                                 c_uinst_rec.insttype,
3766                                                 c_uinst_rec.instshortname,
3767                                                 c_uinst_rec.instname,
3768                                                 c_uinst_rec.instfullname,
3769                                                 c_uinst_rec.switchboardtelno,
3770                                                 c_uinst_rec.decisioncards,
3771                                                 c_uinst_rec.recordcards,
3772                                                 c_uinst_rec.labels,
3773                                                 c_uinst_rec.weeklymovlistseq,
3774                                                 c_uinst_rec.weeklymovpaging,
3775                                                 c_uinst_rec.formseq,
3776                                                 c_uinst_rec.eblrequired,
3777                                                 c_uinst_rec.eblmedia1or2,
3778                                                 c_uinst_rec.eblmedia3,
3779                                                 c_uinst_rec.ebl1or2merged,
3780                                                 c_uinst_rec.ebl1or2boardgroup,
3781                                                 c_uinst_rec.ebl3boardgroup,
3782                                                 c_uinst_rec.eblncapp,
3783                                                 c_uinst_rec.eblmajorkey1,
3784                                                 c_uinst_rec.eblmajorkey2,
3785                                                 c_uinst_rec.eblmajorkey3,
3786                                                 c_uinst_rec.eblminorkey1,
3787                                                 c_uinst_rec.eblminorkey2,
3788                                                 c_uinst_rec.eblminorkey3,
3789                                                 c_uinst_rec.eblfinalkey,
3790                                                 c_uinst_rec.odl1,
3791                                                 c_uinst_rec.odl1a,
3792                                                 c_uinst_rec.odl2,
3793                                                 c_uinst_rec.odl3,
3794                                                 c_uinst_rec.odlsummer,
3795                                                 c_uinst_rec.odlrouteb,
3796                                                 c_uinst_rec.monthlyseq,
3797                                                 c_uinst_rec.monthlypaper,
3798                                                 c_uinst_rec.monthlypage,
3799                                                 c_uinst_rec.monthlytype,
3800                                                 c_uinst_rec.junelistseq,
3801                                                 c_uinst_rec.junelabels,
3802                                                 c_uinst_rec.junenumlabels,
3803                                                 c_uinst_rec.courseanalysis,
3804                                                 c_uinst_rec.campusused,
3805                                                 c_uinst_rec.d3docsrequired,
3806                                                 c_uinst_rec.clearingacceptcopyform,
3807                                                 c_uinst_rec.onlinemessage,
3808                                                 c_uinst_rec.ethniclistseq,
3809                                                 'N',
3810                                                  'N',
3811                                                  NULL) ;
3812         -- increment count of records
3813         l_count := l_count + 1;
3814 
3815        END LOOP ;
3816 
3817       IF g_sync_reqd THEN
3818               -- get the max timestamp of this hercules view
3819               OPEN c_max_timestamp ;
3820               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3821               CLOSE c_max_timestamp ;
3822 
3823                -- update /insert the timestamp record with new max timestamp
3824                ins_upd_timestamp ('UVINSTITUTION', l_new_max_timestamp) ;
3825 
3826               -- log message that this view has been loaded
3827                log_complete('UVINSTITUTION', l_count ) ;
3828       ELSE
3829                 -- log message that this view is already in sync and need not be loaded
3830                log_already_insync('UVINSTITUTION') ;
3831       END IF ;
3832       COMMIT;
3833 
3834   EXCEPTION
3835       WHEN OTHERS THEN
3836                ROLLBACK;
3837                write_to_log(SQLERRM);
3838                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3839                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVINSTITUTION_2003');
3840                igs_ge_msg_stack.add;
3841                app_exception.raise_exception ;
3842   END   load_uvinstitution_2003  ;
3843 
3844   PROCEDURE load_uvofferabbrev_2003 IS
3845     /******************************************************************
3846      Created By      :  smaddali
3847      Date Created By :   11-Jun-03
3848      Purpose         :   loads each record in the hercules view uvofferabbrev into the interface table
3849                            igs_uc_uofabrv_ints with record status N
3850      Known limitations,enhancements,remarks:
3851      Change History
3852      Who       When         What
3853     ***************************************************************** */
3854 
3855       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3856       -- or get all the records in hercules view if the timestamp passed is null
3857       CURSOR c_uvoffabrv( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
3858       SELECT  abbrevid
3859         ,timestamp
3860         ,RTRIM(updater) updater
3861         ,RTRIM(abbrevtext) abbrevtext
3862         ,DECODE(RTRIM(letterformat),NULL, RPAD('*',LENGTH(letterformat),'*'), RTRIM(letterformat)) letterformat
3863         ,RTRIM(summarychar) summarychar
3864         ,abbrevuse
3865       FROM igs_uc_u_uvofferabbrev_2003
3866       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
3867 
3868       -- get the max timestamp value of the hercules view
3869       CURSOR c_max_timestamp IS
3870       SELECT MAX(timestamp)
3871       FROM igs_uc_u_uvofferabbrev_2003  ;
3872 
3873       -- Variables
3874       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
3875       l_new_max_timestamp igs_uc_u_uvofferabbrev_2003.timestamp%TYPE ;
3876       l_count NUMBER ;
3877 
3878   BEGIN
3879        -- set syncronization required to false
3880        g_sync_reqd := FALSE;
3881        l_count := 0 ;
3882 
3883       -- log message that this view is being loaded
3884        log_start('UVOFFERABBREV ON ') ;
3885 
3886       -- Get the old timestamp for this view in the configured cycle
3887       Herc_timestamp_exists('UVOFFERABBREV', p_old_timestamp) ;
3888 
3889        -- create interface records for each record in the hercules view whose timestamp > old timestamp
3890        FOR c_uvoffabrv_rec IN c_uvoffabrv(p_old_timestamp) LOOP
3891               -- set x_sync_read to true if the loop is entered even once
3892               g_sync_reqd := TRUE;
3893 
3894               --Validate varchar to number conversion
3895               IF  is_valid(c_uvoffabrv_rec.abbrevid,'UVOFFERABBREV','ABBREVID','NUMBER') THEN
3896 
3897                   -- Obsolete matching records in interface table with status N
3898                   UPDATE igs_uc_uofabrv_ints SET record_status = 'O'
3899                   WHERE record_status = 'N' AND  abbrevid = c_uvoffabrv_rec.abbrevid ;
3900 
3901                   -- copy hercules record into interface table with record status N
3902                   INSERT INTO igs_uc_uofabrv_ints ( abbrevid,
3903                                                     updater,
3904                                                     abbrevtext,
3905                                                     letterformat,
3906                                                     summarychar,
3907                                                     abbrevuse,
3908                                                     record_status,
3909                                                     error_code
3910                                                      )
3911                                          VALUES (   c_uvoffabrv_rec.abbrevid,
3912                                                     c_uvoffabrv_rec.updater,
3913                                                     c_uvoffabrv_rec.abbrevtext,
3914                                                     c_uvoffabrv_rec.letterformat,
3915                                                     c_uvoffabrv_rec.summarychar,
3916                                                     c_uvoffabrv_rec.abbrevuse,
3917                                                     'N',
3918                                                     NULL) ;
3919                   -- increment count of records
3920                   l_count := l_count + 1;
3921 
3922               END IF;
3923 
3924        END LOOP ;
3925 
3926       IF g_sync_reqd THEN
3927               -- get the max timestamp of this hercules view
3928               OPEN c_max_timestamp ;
3929               FETCH c_max_timestamp INTO l_new_max_timestamp ;
3930               CLOSE c_max_timestamp ;
3931 
3932                -- update /insert the timestamp record with new max timestamp
3933                ins_upd_timestamp ('UVOFFERABBREV',  l_new_max_timestamp) ;
3934 
3935               -- log message that this view has been loaded
3936                log_complete('UVOFFERABBREV', l_count) ;
3937       ELSE
3938                 -- log message that this view is already in sync and need not be loaded
3939                log_already_insync('UVOFFERABBREV') ;
3940       END IF ;
3941       COMMIT;
3942 
3943   EXCEPTION
3944       WHEN OTHERS THEN
3945                ROLLBACK;
3946                write_to_log(SQLERRM);
3947                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
3948                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVOFFERABBREV_2003');
3949                igs_ge_msg_stack.add;
3950                app_exception.raise_exception ;
3951   END  load_uvofferabbrev_2003   ;
3952 
3953 
3954   PROCEDURE load_cvrefpre2000pocc_2003 IS
3955     /******************************************************************
3956      Created By      :  smaddali
3957      Date Created By :   11-Jun-03
3958      Purpose         :   loads each record in the hercules view cvrefpre2000pocc into the interface table
3959                            igs_uc_crprepo_ints with record status N
3960      Known limitations,enhancements,remarks:
3961      Change History
3962      Who       When         What
3963     ***************************************************************** */
3964 
3965       -- Get all the records from hercules  view whose timestamp is > passed timestamp
3966       -- or get all the records in hercules view if the timestamp passed is null
3967       CURSOR c_cvprepocc IS
3968       SELECT  pocc
3969           ,socialclass
3970           ,RTRIM(occupationtext) occupationtext
3971           ,RTRIM(alternativetext) alternativetext
3972           ,alternateclass1
3973           ,alternateclass2
3974       FROM igs_uc_u_cvrefpre2000pocc_2003     ;
3975       l_count NUMBER ;
3976 
3977   BEGIN
3978        -- set syncronization required to false
3979        g_sync_reqd := FALSE;
3980        l_count := 0 ;
3981 
3982       -- log message that this view is being loaded
3983         log_start('CVREFPRE2000POCC ON ' ) ;
3984 
3985       -- Obsolete records in interface table with status N
3986       UPDATE igs_uc_crprepo_ints SET record_status = 'O' WHERE record_status = 'N' ;
3987 
3988        -- create interface records for each record in the hercules view
3989        FOR c_cvprepocc_rec IN c_cvprepocc LOOP
3990               -- set x_sync_read to true if the loop is entered even once
3991               g_sync_reqd := TRUE;
3992 
3993               -- copy hercules record into interface table with record status N
3994               INSERT INTO igs_uc_crprepo_ints(  pocc,
3995                                                 socialclass,
3996                                                 occupationtext,
3997                                                 alternativetext,
3998                                                 alternateclass1,
3999                                                 alternateclass2,
4000                                                 record_status,
4001                                                 error_code
4002                                                  )
4003                                      VALUES (   c_cvprepocc_rec.pocc,
4004                                                 c_cvprepocc_rec.socialclass,
4005                                                 c_cvprepocc_rec.occupationtext,
4006                                                 c_cvprepocc_rec.alternativetext,
4007                                                 c_cvprepocc_rec.alternateclass1,
4008                                                 c_cvprepocc_rec.alternateclass2,
4009                                                  'N',
4010                                                  NULL) ;
4011         -- increment count of records
4012         l_count := l_count + 1;
4013 
4014        END LOOP ;
4015 
4016       IF g_sync_reqd THEN
4017               -- log message that this view has been loaded
4018                log_complete('CVREFPRE2000POCC', l_count ) ;
4019       ELSE
4020                 -- log message that this view is already in sync and need not be loaded
4021                log_already_insync('CVREFPRE2000POCC') ;
4022       END IF ;
4023       COMMIT;
4024 
4025   EXCEPTION
4026       WHEN OTHERS THEN
4027                ROLLBACK;
4028                write_to_log(SQLERRM);
4029                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4030                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFPRE2000POCC_2003');
4031                igs_ge_msg_stack.add;
4032                app_exception.raise_exception ;
4033   END    load_cvrefpre2000pocc_2003 ;
4034 
4035   PROCEDURE load_cvrefsocialclass_2003 IS
4036     /******************************************************************
4037      Created By      :  smaddali
4038      Date Created By :   11-Jun-03
4039      Purpose         :  loads each record in the hercules view cvrefsocialclass into the interface table
4040                            igs_uc_crfcode_ints with record status N and code_type = PC
4041      Known limitations,enhancements,remarks:
4042      Change History
4043      Who       When         What
4044     ***************************************************************** */
4045 
4046       -- Get all the records from hercules  view whose timestamp is > passed timestamp
4047       -- or get all the records in hercules view if the timestamp passed is null
4048       CURSOR c_cvsocclas IS
4049       SELECT  socialclass
4050            ,RTRIM(socialclasstext) socialclasstext
4051       FROM igs_uc_u_cvrefsocialclass_2003      ;
4052       l_count NUMBER ;
4053 
4054   BEGIN
4055        -- set syncronization required to false
4056        g_sync_reqd := FALSE;
4057        l_count := 0 ;
4058 
4059       -- log message that this view is being loaded
4060        log_start('CVREFSOCIALCLASS ON ') ;
4061 
4062      -- Obsolete records in interface table with status N
4063       UPDATE igs_uc_crfcode_ints SET record_status = 'O' WHERE record_status = 'N' AND code_type = 'PC';
4064 
4065        -- create interface records for each record in the hercules view
4066        FOR c_cvsocclas_rec IN c_cvsocclas LOOP
4067               -- set x_sync_read to true if the loop is entered even once
4068               g_sync_reqd := TRUE;
4069 
4070               -- copy hercules record into interface table with record status N
4071               INSERT INTO igs_uc_crfcode_ints(   code_type,
4072                                                  code,
4073                                                  code_text,
4074                                                  record_status,
4075                                                  error_code
4076                                                  )
4077                                      VALUES (    'PC',
4078                                                  c_cvsocclas_rec.socialclass,
4079                                                  c_cvsocclas_rec.socialclasstext,
4080                                                  'N',
4081                                                  NULL) ;
4082         -- increment count of records
4083         l_count := l_count + 1;
4084 
4085        END LOOP ;
4086 
4087       IF g_sync_reqd THEN
4088               -- log message that this view has been loaded
4089                log_complete('CVREFSOCIALCLASS', l_count) ;
4090       ELSE
4091                 -- log message that this view is already in sync and need not be loaded
4092                log_already_insync('CVREFSOCIALCLASS') ;
4093       END IF ;
4094       COMMIT;
4095 
4096   EXCEPTION
4097       WHEN OTHERS THEN
4098                ROLLBACK;
4099                write_to_log(SQLERRM);
4100                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4101                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFSOCIALCLASS_2003');
4102                igs_ge_msg_stack.add;
4103                app_exception.raise_exception ;
4104   END   load_cvrefsocialclass_2003  ;
4105 
4106   PROCEDURE load_cvrefsocioeconomic_2003 IS
4107     /******************************************************************
4108      Created By      :  smaddali
4109      Date Created By :   11-Jun-03
4110      Purpose         :    loads each record in the hercules view cvrefsocioeconomic into the interface table
4111                            igs_uc_crfcode_ints with record status N and code_type = PE
4112      Known limitations,enhancements,remarks:
4113      Change History
4114      Who       When         What
4115     ***************************************************************** */
4116 
4117       -- Get all the records from hercules  view whose timestamp is > passed timestamp
4118       -- or get all the records in hercules view if the timestamp passed is null
4119       CURSOR c_cvsocioecon IS
4120       SELECT  socioecon
4121            ,RTRIM(socioecontext) socioecontext
4122       FROM igs_uc_u_cvrefsocioecon_2003  ;
4123       l_count NUMBER ;
4124 
4125   BEGIN
4126        -- set syncronization required to false
4127        g_sync_reqd := FALSE;
4128        l_count := 0 ;
4129 
4130       -- log message that this view is being loaded
4131        log_start('CVREFSOCIOECONOMIC ON ') ;
4132 
4133      -- Obsolete records in interface table with status N
4134       UPDATE igs_uc_crfcode_ints SET record_status = 'O' WHERE record_status = 'N' AND code_type = 'PE';
4135 
4136        -- create interface records for each record in the hercules view
4137        FOR c_cvsocioecon_rec IN c_cvsocioecon LOOP
4138               -- set x_sync_read to true if the loop is entered even once
4139               g_sync_reqd := TRUE;
4140 
4141               -- copy hercules record into interface table with record status N
4142               INSERT INTO igs_uc_crfcode_ints(   code_type,
4143                                                  code,
4144                                                  code_text,
4145                                                  record_status,
4146                                                  error_code
4147                                                  )
4148                                      VALUES (    'PE',
4149                                                  c_cvsocioecon_rec.socioecon,
4150                                                  c_cvsocioecon_rec.socioecontext,
4151                                                  'N',
4152                                                  NULL) ;
4153         -- increment count of records
4154         l_count := l_count + 1;
4155 
4156        END LOOP ;
4157 
4158       IF g_sync_reqd THEN
4159                -- log message that this view has been loaded
4160                log_complete('CVREFSOCIOECONOMIC', l_count) ;
4161       ELSE
4162                -- log message that this view is already in sync and need not be loaded
4163                log_already_insync('CVREFSOCIOECONOMIC') ;
4164       END IF ;
4165       COMMIT;
4166 
4167   EXCEPTION
4168       WHEN OTHERS THEN
4169                ROLLBACK;
4170                write_to_log(SQLERRM);
4171                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4172                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFSOCIOECONOMIC_2003');
4173                igs_ge_msg_stack.add;
4174                app_exception.raise_exception ;
4175   END   load_cvrefsocioeconomic_2003  ;
4176 
4177   PROCEDURE load_cvrefsubj_2003 IS
4178     /******************************************************************
4179      Created By      :  smaddali
4180      Date Created By :   11-Jun-03
4181      Purpose         :     loads each record in the hercules view cvrefsubj into the interface table
4182                            igs_uc_crsubj_ints with record status N
4183      Known limitations,enhancements,remarks:
4184      Change History
4185      Who       When         What
4186      jbaber    15-Sep-05    Replace subjtext value with '*' if NULL for bug 4589994
4187     ***************************************************************** */
4188 
4189       -- Get all the records from hercules  view whose timestamp is > passed timestamp
4190       -- or get all the records in hercules view if the timestamp passed is null
4191       CURSOR c_cvsubj IS
4192       SELECT  DECODE(RTRIM(subjcode),NULL, RPAD('*',LENGTH(subjcode),'*'), RTRIM(subjcode)) subjcode
4193                  ,NVL(DECODE(RTRIM(subjtext),NULL, RPAD('*',LENGTH(subjtext),'*'), RTRIM(subjtext)),'*') subjtext
4194                  ,RTRIM(subjabbrev) subjabbrev
4195                  ,RTRIM(ebl_subj) ebl_subj
4196       FROM igs_uc_u_cvrefsubj_2003 ;
4197       l_count NUMBER ;
4198 
4199   BEGIN
4200        -- set syncronization required to false
4201        g_sync_reqd := FALSE;
4202        l_count := 0 ;
4203 
4204       -- log message that this view is being loaded
4205        log_start( 'CVREFSUBJ ON ') ;
4206 
4207      -- Obsolete records in interface table with status N
4208       UPDATE igs_uc_crsubj_ints SET record_status = 'O' WHERE record_status = 'N' ;
4209 
4210        -- create interface records for each record in the hercules view
4211        FOR c_cvsubj_rec IN c_cvsubj LOOP
4212               -- set x_sync_read to true if the loop is entered even once
4213               g_sync_reqd := TRUE;
4214 
4215               -- copy hercules record into interface table with record status N
4216               INSERT INTO igs_uc_crsubj_ints(   subjcode,
4217                                                 subjtext,
4218                                                 subjabbrev,
4219                                                 ebl_subj,
4220                                                 record_status,
4221                                                 error_code
4222                                                  )
4223                                      VALUES (   c_cvsubj_rec.subjcode,
4224                                                 c_cvsubj_rec.subjtext,
4225                                                 c_cvsubj_rec.subjabbrev,
4226                                                 c_cvsubj_rec.ebl_subj,
4227                                                  'N',
4228                                                  NULL) ;
4229         -- increment count of records
4230         l_count := l_count + 1;
4231 
4232        END LOOP ;
4233 
4234        IF g_sync_reqd THEN
4235               -- log message that this view has been loaded
4236                log_complete( 'CVREFSUBJ', l_count) ;
4237        ELSE
4238                 -- log message that this view is already in sync and need not be loaded
4239                log_already_insync('CVREFSUBJ') ;
4240        END IF ;
4241       COMMIT;
4242 
4243   EXCEPTION
4244       WHEN OTHERS THEN
4245                ROLLBACK;
4246                write_to_log(SQLERRM);
4247                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4248                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFSUBJ_2003');
4249                igs_ge_msg_stack.add;
4250                app_exception.raise_exception ;
4251   END   load_cvrefsubj_2003  ;
4252 
4253 
4254   PROCEDURE load_cvrefcountry_2007 IS
4255     /******************************************************************
4256      Created By      :  jbaber
4257      Date Created By :   11-Jul-06
4258      Purpose         :   loads each record in the hercules view cvrefcountry into the interface table
4259                          igs_uc_country_ints  with record status N
4260      Known limitations,enhancements,remarks:
4261      Change History
4262      Who       When         What
4263     ***************************************************************** */
4264 
4265       -- Get all the records from hercules view whose timestamp is > passed timestamp
4266       -- or get all the records in hercules view if the timestamp passed is null
4267       CURSOR c_cvrefcountry IS
4268       SELECT DECODE(RTRIM(countrycode),NULL, RPAD('*',LENGTH(countrycode),'*'), RTRIM(countrycode)) countrycode
4269           ,RTRIM(description) description
4270           ,RTRIM(type) type
4271       FROM igs_uc_u_cvrefcountry_2007 ;
4272 
4273       -- Variables
4274       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
4275       l_new_max_timestamp igs_uc_u_cvrefamendments_2007.country%TYPE ;
4276       l_count NUMBER ;
4277 
4278   BEGIN
4279        -- set syncronization required to false
4280        g_sync_reqd := FALSE;
4281        l_count := 0 ;
4282 
4283       -- log message that this view is being loaded
4284        log_start('CVREFCOUNTRY ON ') ;
4285 
4286       -- get the max timestamp of this hercules view
4287       l_new_max_timestamp := g_refamend_timestamp.country ;
4288 
4289       -- Get the old timestamp for this view in the configured cycle
4290       Herc_timestamp_exists('CVREFCOUNTRY', p_old_timestamp) ;
4291       -- if there is a difference in the timestamps then load all records from hercules view
4292       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
4293 
4294                -- Obsolete all records in interface table with status N
4295                UPDATE igs_uc_country_ints   SET record_status = 'O' WHERE record_status = 'N' ;
4296 
4297                -- create interface records for each record in the hercules view
4298                FOR c_cvrefcountry_rec IN c_cvrefcountry LOOP
4299                       -- set x_sync_read to true if the loop is entered even once
4300                       g_sync_reqd := TRUE;
4301 
4302                       -- copy hercules record into interface table with record status N
4303                       INSERT INTO igs_uc_country_ints (  countrycode,
4304                                                          description,
4305                                                          type,
4306                                                          record_status,
4307                                                          error_code )
4308                                              VALUES (    c_cvrefcountry_rec.countrycode,
4309                                                          c_cvrefcountry_rec.description,
4310                                                          c_cvrefcountry_rec.type,
4311                                                          'N',
4312                                                          NULL) ;
4313             -- increment count of records
4314             l_count := l_count + 1;
4315 
4316                END LOOP ;
4317       END IF ;  -- old and new timestamps differ
4318 
4319       IF g_sync_reqd THEN
4320                -- update /insert the timestamp record with new max timestamp
4321                ins_upd_timestamp ('CVREFCOUNTRY',l_new_max_timestamp) ;
4322 
4323                   -- log message that this view has been loaded
4324                  log_complete('CVREFCOUNTRY', l_count) ;
4325       ELSE
4326                 -- log message that this view is already in sync and need not be loaded
4327                log_already_insync('CVREFCOUNTRY') ;
4328       END IF ;
4329       COMMIT;
4330 
4331   EXCEPTION
4332       WHEN OTHERS THEN
4333                ROLLBACK;
4334                write_to_log(SQLERRM);
4335                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4336                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFCOUNTRY_2007');
4337                igs_ge_msg_stack.add;
4338                app_exception.raise_exception ;
4339   END   load_cvrefcountry_2007  ;
4340 
4341 
4342   PROCEDURE load_cvrefnationality_2007 IS
4343     /******************************************************************
4344      Created By      :  jbaber
4345      Date Created By :   11-Jul-06
4346      Purpose         :   loads each record in the hercules view cvrefnationality into the interface table
4347                          igs_uc_crfcode_ints with record status N and code_type = NC
4348      Known limitations,enhancements,remarks:
4349      Change History
4350      Who       When         What
4351     ***************************************************************** */
4352 
4353       -- Get all the records from hercules view whose timestamp is > passed timestamp
4354       -- or get all the records in hercules view if the timestamp passed is null
4355       CURSOR c_cvrefnationality IS
4356       SELECT DECODE(RTRIM(nationality),NULL, RPAD('*',LENGTH(nationality),'*'), RTRIM(nationality)) nationality
4357            ,RTRIM(description) description
4358       FROM igs_uc_u_cvrefnationality_2007  ;
4359 
4360       -- Variables
4361       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
4362       l_new_max_timestamp igs_uc_u_cvrefamendments_2007.nationality%TYPE ;
4363       l_count NUMBER ;
4364 
4365   BEGIN
4366        -- set syncronization required to false
4367        g_sync_reqd := FALSE;
4368        l_count := 0 ;
4369 
4370       -- log message that this view is being loaded
4371       log_start('CVREFNATIONALITY ON ' ) ;
4372 
4373       -- get the max timestamp of this hercules view
4374       l_new_max_timestamp := g_refamend_timestamp.nationality ;
4375 
4376       -- Get the old timestamp for this view in the configured cycle
4377       Herc_timestamp_exists('CVREFNATIONALITY', p_old_timestamp) ;
4378       -- if there is a difference in the timestamps then load all records from hercules view
4379       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
4380 
4381                -- Obsolete all records in interface table with status N
4382                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'NC' ;
4383 
4384                -- create interface records for each record in the hercules view
4385                FOR c_cvrefnationality_rec IN c_cvrefnationality LOOP
4386                       -- set x_sync_read to true if the loop is entered even once
4387                       g_sync_reqd := TRUE;
4388 
4389                       -- copy hercules record into interface table with record status N
4390                       INSERT INTO igs_uc_crfcode_ints (  code_type,
4391                                                          code,
4392                                                          code_text,
4393                                                          record_status,
4394                                                          error_code )
4395                                              VALUES (    'NC',
4396                                                          c_cvrefnationality_rec.nationality,
4397                                                          c_cvrefnationality_rec.description,
4398                                                          'N',
4399                                                          NULL) ;
4400             -- increment count of records
4401             l_count := l_count + 1;
4402 
4403                END LOOP ;
4404       END IF ;  -- old and new timetamps differ
4405 
4406       IF g_sync_reqd THEN
4407                -- update /insert the timestamp record with new max timestamp
4408                ins_upd_timestamp ('CVREFNATIONALITY',  l_new_max_timestamp) ;
4409 
4410             -- log message that this view has been loaded
4411             log_complete('CVREFNATIONALITY', l_count ) ;
4412       ELSE
4413                 -- log message that this view is already in sync and need not be loaded
4414                log_already_insync('CVREFNATIONALITY') ;
4415       END IF ;
4416       COMMIT;
4417 
4418   EXCEPTION
4419       WHEN OTHERS THEN
4420                ROLLBACK;
4421                write_to_log(SQLERRM);
4422                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4423                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVREFNATIONALITY_2007');
4424                igs_ge_msg_stack.add;
4425                app_exception.raise_exception ;
4426   END   load_cvrefnationality_2007  ;
4427 
4428 
4429   PROCEDURE load_cvgrefdegreesubj_2006  IS
4430     /******************************************************************
4431      Created By      :   jbaber
4432      Date Created By :   02-Oct-05
4433      Purpose         :   loads each record in the hercules view cvgrefdegreesubject into the interface table
4434                          igs_uc_crfcode_ints with record status N and code_type = DS
4435      Known limitations,enhancements,remarks:
4436      Change History
4437      Who       When         What
4438     ***************************************************************** */
4439 
4440       -- Get all the records from hercules view whose timestamp is > passed timestamp
4441       -- or get all the records in hercules view if the timestamp passed is null
4442       CURSOR c_cvgrefdegsubj IS
4443       SELECT degreesubject
4444             ,RTRIM(description) description
4445       FROM igs_uc_g_cvgrefdegreesubj_2006;
4446 
4447       -- Variables
4448       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ;
4449       l_new_max_timestamp igs_uc_g_cvgrefamendments_2006.degreesubject%TYPE ;
4450       l_count NUMBER ;
4451 
4452   BEGIN
4453       -- set syncronization required to false
4454       g_sync_reqd := FALSE;
4455       l_count := 0 ;
4456 
4457       -- log message that this view is being loaded
4458       log_start('CVGREFDEGREESUBJECT ON ') ;
4459 
4460       -- get the max timestamp of this hercules view
4461       l_new_max_timestamp := g_grefamend_timestamp.degreesubject ;
4462 
4463       -- Get the old timestamp for this view in the configured cycle
4464       Herc_timestamp_exists('CVGREFDEGREESUBJECT',p_old_timestamp) ;
4465 
4466       -- if there is a difference in the timestamps then load all records from hercules view
4467       IF ( l_new_max_timestamp > p_old_timestamp OR p_old_timestamp IS NULL  ) THEN
4468 
4469                -- Obsolete all records in interface table with status N
4470                UPDATE igs_uc_crfcode_ints  SET record_status = 'O' WHERE record_status = 'N' AND code_type= 'DS' ;
4471 
4472                -- create interface records for each record in the hercules view
4473                FOR c_cvgrefdegsubj_rec IN c_cvgrefdegsubj LOOP
4474                       -- set x_sync_read to true if the loop is entered even once
4475                       g_sync_reqd := TRUE;
4476 
4477                       -- copy hercules record into interface table with record status N
4478                       INSERT INTO igs_uc_crfcode_ints (  code_type,
4479                                                          code,
4480                                                          code_text,
4481                                                          record_status,
4482                                                          error_code )
4483                                                VALUES (  'DS',
4484                                                          c_cvgrefdegsubj_rec.degreesubject,
4485                                                          c_cvgrefdegsubj_rec.description,
4486                                                          'N',
4487                                                          NULL );
4488                       -- increment count of records
4489                       l_count := l_count + 1;
4490 
4491                END LOOP ;
4492 
4493       END IF ;  -- old and new timetamps differ
4494 
4495       IF g_sync_reqd THEN
4496                -- update /insert the timestamp record with new max timestamp
4497                ins_upd_timestamp ('CVGREFDEGREESUBJECT', l_new_max_timestamp) ;
4498 
4499                -- log message that this view has been loaded
4500                log_complete('CVGREFDEGREESUBJECT', l_count) ;
4501       ELSE
4502                 -- log message that this view is already in sync and need not be loaded
4503                log_already_insync('CVGREFDEGREESUBJECT') ;
4504       END IF ;
4505 
4506       COMMIT;
4507 
4508   EXCEPTION
4509       WHEN OTHERS THEN
4510                ROLLBACK;
4511                write_to_log(SQLERRM);
4512                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4513                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_CVGREFDEGREESUBJ_2006');
4514                igs_ge_msg_stack.add;
4515                app_exception.raise_exception ;
4516   END    load_cvgrefdegreesubj_2006 ;
4517 
4518 
4519   PROCEDURE load_ivoffer_2003 IS
4520     /******************************************************************
4521      Created By      :  smaddali
4522      Date Created By :   11-Jun-03
4523      Purpose         :   loads each record in the hercules view ivoffer into the interface table
4524                            igs_uc_ioffer_ints with record status N
4525      Known limitations,enhancements,remarks:
4526      Change History
4527      Who       When         What
4528     ***************************************************************** */
4529 
4530       -- Get all the records from hercules  view whose timestamp is > passed timestamp
4531       -- or get all the records in hercules view if the timestamp passed is null
4532       CURSOR c_ivoffer( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
4533       SELECT appno
4534            ,choiceno
4535            ,timestamp
4536            ,DECODE(RTRIM(offercourse),NULL, RPAD('*',LENGTH(offercourse),'*'), RTRIM(offercourse)) offercourse
4537            ,DECODE(RTRIM(offercampus),NULL, RPAD('*',LENGTH(offercampus),'*'), RTRIM(offercampus)) offercampus
4538            ,offercourselength
4539            ,RTRIM(offerentrymonth) offerentrymonth
4540            ,RTRIM(offerentryyear) offerentryyear
4541            ,RTRIM(offerentrypoint) offerentrypoint
4542            ,RTRIM(offertext) offertext
4543       FROM igs_uc_ivoffer_2003_v
4544       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
4545 
4546       -- get the max timestamp value of the hercules view
4547       CURSOR c_max_timestamp IS
4548       SELECT MAX(timestamp)
4549       FROM igs_uc_ivoffer_2003_v  ;
4550 
4551       -- Variables
4552       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
4553       l_new_max_timestamp igs_uc_ivoffer_2003_v.timestamp%TYPE ;
4554       l_count NUMBER ;
4555 
4556       l_appno      igs_uc_ioffer_ints.appno%TYPE;
4557       l_checkdigit NUMBER;
4558 
4559   BEGIN
4560        -- set syncronization required to false
4561        g_sync_reqd := FALSE;
4562        l_count := 0 ;
4563 
4564       -- log message that this view is being loaded
4565        log_start('IVOFFER ON ') ;
4566 
4567       -- Get the old timestamp for this view in the configured cycle
4568       Herc_timestamp_exists('IVOFFER', p_old_timestamp) ;
4569 
4570        -- create interface records for each record in the hercules view whose timestamp > old timestamp
4571        FOR c_ivoffer_rec IN c_ivoffer(p_old_timestamp) LOOP
4572               -- set x_sync_read to true if the loop is entered even once
4573               g_sync_reqd := TRUE;
4574 
4575               IF  is_valid(c_ivoffer_rec.appno,'IVOFFER','APPNO','NUMBER') THEN
4576 
4577                   -- Determine actual appno
4578                   get_appno(c_ivoffer_rec.appno, NULL, l_appno, l_checkdigit);
4579 
4580                   -- Obsolete matching records in interface table with status N
4581                   UPDATE igs_uc_ioffer_ints SET record_status = 'O'
4582                   WHERE record_status = 'N' AND  appno = l_appno
4583                   AND choiceno = c_ivoffer_rec.choiceno ;
4584 
4585 
4586                   -- copy hercules record into interface table with record status N
4587                   INSERT INTO igs_uc_ioffer_ints (  appno,
4588                                                     choiceno,
4589                                                     offercourse,
4590                                                     offercampus,
4591                                                     offercourselength,
4592                                                     offerentrymonth,
4593                                                     offerentryyear,
4594                                                     offerentrypoint,
4595                                                     offertext,
4596                                                     record_status,
4597                                                     error_code,
4598                                                     ucas_cycle
4599                                                      )
4600                                          VALUES (   l_appno,
4601                                                     c_ivoffer_rec.choiceno,
4602                                                     c_ivoffer_rec.offercourse,
4603                                                     c_ivoffer_rec.offercampus,
4604                                                     c_ivoffer_rec.offercourselength,
4605                                                     c_ivoffer_rec.offerentrymonth,
4606                                                     c_ivoffer_rec.offerentryyear,
4607                                                     c_ivoffer_rec.offerentrypoint,
4608                                                     c_ivoffer_rec.offertext,
4609                                                      'N',
4610                                                      NULL,
4611                                                     g_cyc_info_rec.configured_cycle ) ;
4612                   -- increment count of records
4613                   l_count := l_count + 1;
4614 
4615               END IF;
4616 
4617        END LOOP ;
4618 
4619       IF g_sync_reqd THEN
4620               -- get the max timestamp of this hercules view
4621               OPEN c_max_timestamp ;
4622               FETCH c_max_timestamp INTO l_new_max_timestamp ;
4623               CLOSE c_max_timestamp ;
4624 
4625                -- update /insert the timestamp record with new max timestamp
4626                ins_upd_timestamp ('IVOFFER',   l_new_max_timestamp) ;
4627 
4628               -- log message that this view has been loaded
4629                log_complete('IVOFFER', l_count) ;
4630       ELSE
4631                 -- log message that this view is already in sync and need not be loaded
4632                log_already_insync('IVOFFER') ;
4633       END IF ;
4634       COMMIT;
4635 
4636   EXCEPTION
4637       WHEN OTHERS THEN
4638                ROLLBACK;
4639                write_to_log(SQLERRM);
4640                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4641                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVOFFER_2003');
4642                igs_ge_msg_stack.add;
4643                app_exception.raise_exception ;
4644   END  load_ivoffer_2003   ;
4645 
4646 
4647   PROCEDURE load_ivgoffer_2006 IS
4648     /******************************************************************
4649      Created By      :   jtmathew
4650      Date Created By :   08-Jul-05
4651      Purpose         :   loads each record in the odbc-link view ivgoffer into the interface table
4652                          igs_uc_ioffer_ints with record status N
4653      Known limitations,enhancements,remarks:
4654      Change History
4655      Who       When         What
4656     ***************************************************************** */
4657 
4658       -- Get all the records from odbc-link view whose timestamp is > passed timestamp
4659       -- or get all the records in odbc-link view if the timestamp passed is null
4660       CURSOR c_ivgoffer( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
4661       SELECT appno
4662            ,roundno
4663            ,timestamp
4664            ,RTRIM(offertext) offertext
4665       FROM igs_uc_ivgoffer_2006_v
4666       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
4667 
4668       -- get the max timestamp value of the odbc-link view
4669       CURSOR c_max_timestamp IS
4670       SELECT MAX(timestamp)
4671       FROM igs_uc_ivgoffer_2006_v  ;
4672 
4673       -- Variables
4674       p_old_timestamp     igs_uc_hrc_timstmps.timestamp%TYPE  ;
4675       l_new_max_timestamp igs_uc_ivgoffer_2006_v.timestamp%TYPE ;
4676       l_appno             igs_uc_ioffer_ints.appno%TYPE;
4677       l_checkdigit        NUMBER;
4678       l_count             NUMBER ;
4679 
4680 
4681   BEGIN
4682        -- set syncronization required to false
4683        g_sync_reqd := FALSE;
4684        l_count := 0 ;
4685 
4686       -- log message that this view is being loaded
4687        log_start('IVGOFFER ON ') ;
4688 
4689       -- Get the old timestamp for this view in the configured cycle
4690       Herc_timestamp_exists('IVGOFFER', p_old_timestamp) ;
4691 
4692        -- create interface records for each record in the hercules view whose timestamp > old timestamp
4693        FOR c_ivgoffer_rec IN c_ivgoffer(p_old_timestamp) LOOP
4694               -- set x_sync_read to true if the loop is entered even once
4695               g_sync_reqd := TRUE;
4696 
4697               IF  is_valid(c_ivgoffer_rec.appno,'IVGOFFER','APPNO','NUMBER') THEN
4698 
4699                   -- Determine actual appno
4700                   get_appno(c_ivgoffer_rec.appno, NULL, l_appno, l_checkdigit);
4701 
4702                   -- Obsolete matching records in interface table with status N
4703                   UPDATE igs_uc_ioffer_ints SET record_status = 'O'
4704                   WHERE record_status = 'N' AND  appno = c_ivgoffer_rec.appno
4705                   AND choiceno = c_ivgoffer_rec.roundno ;
4706 
4707                   -- copy hercules record into interface table with record status N
4708                   INSERT INTO igs_uc_ioffer_ints (  appno,
4709                                                     choiceno,
4710                                                     offertext,
4711                                                     record_status,
4712                                                     error_code,
4713                                                     ucas_cycle
4714                                                      )
4715                                          VALUES (   l_appno,
4716                                                     c_ivgoffer_rec.roundno,
4717                                                     c_ivgoffer_rec.offertext,
4718                                                     'N',
4719                                                     NULL,
4720                                                     g_cyc_info_rec.configured_cycle ) ;
4721                   -- increment count of records
4722                   l_count := l_count + 1;
4723 
4724               END IF;
4725 
4726        END LOOP ;
4727 
4728       IF g_sync_reqd THEN
4729               -- get the max timestamp of this hercules view
4730               OPEN c_max_timestamp ;
4731               FETCH c_max_timestamp INTO l_new_max_timestamp ;
4732               CLOSE c_max_timestamp ;
4733 
4734                -- update /insert the timestamp record with new max timestamp
4735                ins_upd_timestamp ('IVGOFFER',   l_new_max_timestamp) ;
4736 
4737               -- log message that this view has been loaded
4738                log_complete('IVGOFFER', l_count) ;
4739       ELSE
4740                 -- log message that this view is already in sync and need not be loaded
4741                log_already_insync('IVGOFFER') ;
4742       END IF ;
4743       COMMIT;
4744 
4745   EXCEPTION
4746       WHEN OTHERS THEN
4747                ROLLBACK;
4748                write_to_log(SQLERRM);
4749                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4750                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGOFFER_2006');
4751                igs_ge_msg_stack.add;
4752                app_exception.raise_exception ;
4753   END  load_ivgoffer_2006   ;
4754 
4755 
4756   PROCEDURE load_ivnoffer_2006 IS
4757     /******************************************************************
4758      Created By      :   jtmathew
4759      Date Created By :   08-Jul-05
4760      Purpose         :   loads each record in the odbc-link view ivnoffer into the interface table
4761                          igs_uc_ioffer_ints with record status N
4762      Known limitations,enhancements,remarks:
4763      Change History
4764      Who       When         What
4765     ***************************************************************** */
4766 
4767       -- Get all the records from odbc-link view whose timestamp is > passed timestamp
4768       -- or get all the records in odbc-link view if the timestamp passed is null
4769       CURSOR c_ivnoffer( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
4770       SELECT appno
4771            ,choiceno
4772            ,timestamp
4773            ,RTRIM(offertext) offertext
4774       FROM igs_uc_ivnoffer_2006_v
4775       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
4776 
4777       -- get the max timestamp value of the odbc-link view
4778       CURSOR c_max_timestamp IS
4779       SELECT MAX(timestamp)
4780       FROM igs_uc_ivnoffer_2006_v  ;
4781 
4782       -- Variables
4783       p_old_timestamp     igs_uc_hrc_timstmps.timestamp%TYPE  ;
4784       l_new_max_timestamp igs_uc_ivnoffer_2006_v.timestamp%TYPE ;
4785       l_appno             igs_uc_ioffer_ints.appno%TYPE;
4786       l_checkdigit        NUMBER;
4787       l_count             NUMBER ;
4788 
4789 
4790   BEGIN
4791        -- set syncronization required to false
4792        g_sync_reqd := FALSE;
4793        l_count := 0 ;
4794 
4795       -- log message that this view is being loaded
4796        log_start('IVNOFFER ON ') ;
4797 
4798       -- Get the old timestamp for this view in the configured cycle
4799       Herc_timestamp_exists('IVNOFFER', p_old_timestamp) ;
4800 
4801        -- create interface records for each record in the hercules view whose timestamp > old timestamp
4802        FOR c_ivnoffer_rec IN c_ivnoffer(p_old_timestamp) LOOP
4803               -- set x_sync_read to true if the loop is entered even once
4804               g_sync_reqd := TRUE;
4805 
4806               IF  is_valid(c_ivnoffer_rec.appno,'IVNOFFER','APPNO','NUMBER') THEN
4807 
4808                   -- Determine actual appno
4809                   get_appno(c_ivnoffer_rec.appno, NULL, l_appno, l_checkdigit);
4810 
4811                   -- Obsolete matching records in interface table with status N
4812                   UPDATE igs_uc_ioffer_ints SET record_status = 'O'
4813                   WHERE record_status = 'N' AND  appno = c_ivnoffer_rec.appno
4814                   AND choiceno = c_ivnoffer_rec.choiceno ;
4815 
4816                   -- copy hercules record into interface table with record status N
4817                   INSERT INTO igs_uc_ioffer_ints (  appno,
4818                                                     choiceno,
4819                                                     offertext,
4820                                                     record_status,
4821                                                     error_code,
4822                                                     ucas_cycle
4823                                                      )
4824                                          VALUES (   l_appno,
4825                                                     c_ivnoffer_rec.choiceno,
4826                                                     c_ivnoffer_rec.offertext,
4827                                                     'N',
4828                                                     NULL,
4829                                                     g_cyc_info_rec.configured_cycle ) ;
4830                   -- increment count of records
4831                   l_count := l_count + 1;
4832 
4833               END IF;
4834 
4835        END LOOP ;
4836 
4837       IF g_sync_reqd THEN
4838               -- get the max timestamp of this hercules view
4839               OPEN c_max_timestamp ;
4840               FETCH c_max_timestamp INTO l_new_max_timestamp ;
4841               CLOSE c_max_timestamp ;
4842 
4843                -- update /insert the timestamp record with new max timestamp
4844                ins_upd_timestamp ('IVNOFFER',   l_new_max_timestamp) ;
4845 
4846               -- log message that this view has been loaded
4847                log_complete('IVNOFFER', l_count) ;
4848       ELSE
4849                 -- log message that this view is already in sync and need not be loaded
4850                log_already_insync('IVNOFFER') ;
4851       END IF ;
4852       COMMIT;
4853 
4854   EXCEPTION
4855       WHEN OTHERS THEN
4856                ROLLBACK;
4857                write_to_log(SQLERRM);
4858                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4859                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNOFFER_2006');
4860                igs_ge_msg_stack.add;
4861                app_exception.raise_exception ;
4862   END  load_ivnoffer_2006   ;
4863 
4864 
4865   PROCEDURE load_ivqualification_2003 IS
4866     /******************************************************************
4867      Created By      :  smaddali
4868      Date Created By :   11-Jun-03
4869      Purpose         :    loads each record in the hercules view ivqualification into the interface table
4870                            igs_uc_iqual_ints with record status N
4871      Known limitations,enhancements,remarks:
4872      Change History
4873      Who       When         What
4874     ***************************************************************** */
4875 
4876      -- Get all the records from hercules  view whose timestamp is > passed timestamp
4877       -- or get all the records in hercules view if the timestamp passed is null
4878       CURSOR c_ivqual ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
4879       SELECT appno
4880             ,timestamp
4881             ,RTRIM(matchprevious) matchprevious
4882             ,matchpreviousdate
4883             ,RTRIM(matchwinter) matchwinter
4884             ,RTRIM(matchsummer) matchsummer
4885             ,gnvqdate    -- not used in hercules
4886             ,ibdate
4887             ,ilcdate
4888             ,aicedate
4889             ,gcesqadate
4890       FROM igs_uc_ivqualification_2003_v
4891       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
4892 
4893       -- get the max timestamp value of the hercules view
4894       CURSOR c_max_timestamp IS
4895       SELECT MAX(timestamp)
4896       FROM igs_uc_ivqualification_2003_v  ;
4897 
4898       -- Variables
4899       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
4900       l_new_max_timestamp igs_uc_ivqualification_2003_v.timestamp%TYPE ;
4901       l_count NUMBER ;
4902 
4903       l_appno      igs_uc_iqual_ints.appno%TYPE;
4904       l_checkdigit NUMBER;
4905 
4906   BEGIN
4907        -- set syncronization required to false
4908        g_sync_reqd := FALSE;
4909        l_count := 0 ;
4910 
4911       -- log message that this view is being loaded
4912        log_start('IVQUALIFICATION ON ') ;
4913 
4914       -- Get the old timestamp for this view in the configured cycle
4915       Herc_timestamp_exists('IVQUALIFICATION', p_old_timestamp) ;
4916 
4917        -- create interface records for each record in the hercules view whose timestamp > old timestamp
4918        FOR c_ivqual_rec IN c_ivqual(p_old_timestamp) LOOP
4919               -- set x_sync_read to true if the loop is entered even once
4920               g_sync_reqd := TRUE;
4921 
4922               IF  is_valid(c_ivqual_rec.appno,'IVQUALIFICATION','APPNO','NUMBER') THEN
4923 
4924                   -- Determine actual appno
4925                   get_appno(c_ivqual_rec.appno, NULL, l_appno, l_checkdigit);
4926 
4927                   -- Obsolete matching records in interface table with status N
4928                   UPDATE igs_uc_iqual_ints SET record_status = 'O'
4929                   WHERE record_status = 'N' AND  appno = l_appno;
4930 
4931                   -- copy hercules record into interface table with record status N
4932                   INSERT INTO igs_uc_iqual_ints (   appno,
4933                                                     matchprevious,
4934                                                     matchpreviousdate,
4935                                                     matchwinter,
4936                                                     matchsummer,
4937                                                     gnvqdate,
4938                                                     ibdate,
4939                                                     ilcdate,
4940                                                     aicedate,
4941                                                     gcesqadate,
4942                                                     record_status,
4943                                                     error_code
4944                                                      )
4945                                          VALUES (   l_appno,
4946                                                     c_ivqual_rec.matchprevious,
4947                                                     c_ivqual_rec.matchpreviousdate,
4948                                                     c_ivqual_rec.matchwinter,
4949                                                     c_ivqual_rec.matchsummer,
4950                                                     c_ivqual_rec.gnvqdate,
4951                                                     c_ivqual_rec.ibdate,
4952                                                     c_ivqual_rec.ilcdate,
4953                                                     c_ivqual_rec.aicedate,
4954                                                     c_ivqual_rec.gcesqadate,
4955                                                      'N',
4956                                                      NULL ) ;
4957                   -- increment count of records
4958                   l_count := l_count + 1;
4959 
4960               END IF;
4961 
4962        END LOOP ;
4963 
4964        IF g_sync_reqd THEN
4965               -- get the max timestamp of this hercules view
4966               OPEN c_max_timestamp ;
4967               FETCH c_max_timestamp INTO l_new_max_timestamp ;
4968               CLOSE c_max_timestamp ;
4969 
4970                -- update /insert the timestamp record with new max timestamp
4971                ins_upd_timestamp ('IVQUALIFICATION', l_new_max_timestamp) ;
4972 
4973               -- log message that this view has been loaded
4974                log_complete('IVQUALIFICATION', l_count) ;
4975        ELSE
4976                 -- log message that this view is already in sync and need not be loaded
4977                log_already_insync('IVQUALIFICATION') ;
4978        END IF;
4979       COMMIT;
4980 
4981   EXCEPTION
4982       WHEN OTHERS THEN
4983                ROLLBACK;
4984                write_to_log(SQLERRM);
4985                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
4986                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVQUALIFICATION_2003');
4987                igs_ge_msg_stack.add;
4988                app_exception.raise_exception ;
4989   END   load_ivqualification_2003  ;
4990 
4991 
4992   PROCEDURE load_ivstara_2003 IS
4993     /******************************************************************
4994      Created By      :  smaddali
4995      Date Created By :   11-Jun-03
4996      Purpose         :   loads each record in the hercules view ivstara into the interface table
4997                            igs_uc_istara_ints with record status N
4998      Known limitations,enhancements,remarks:
4999      Change History
5000      Who       When         What
5001     ***************************************************************** */
5002 
5003      -- Get all the records from hercules  view whose timestamp is > passed timestamp
5004       -- or get all the records in hercules view if the timestamp passed is null
5005       CURSOR c_ivstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5006       SELECT appno
5007       ,timestamp
5008       ,addressarea
5009       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5010       ,RTRIM(address2) address2
5011       ,RTRIM(address3) address3
5012       ,RTRIM(address4) address4
5013       ,RTRIM(postcode) postcode
5014       ,mailsort
5015       ,RTRIM(telephone) telephone
5016       ,NULL fax   -- not used in hercules
5017       ,RTRIM(email) email
5018       ,DECODE(RTRIM(homeaddress1),NULL, RPAD('*',LENGTH(homeaddress1),'*'), RTRIM(homeaddress1)) homeaddress1
5019       ,RTRIM(homeaddress2) homeaddress2
5020       ,RTRIM(homeaddress3) homeaddress3
5021       ,RTRIM(homeaddress4) homeaddress4
5022       ,RTRIM(homepostcode) homepostcode
5023       ,RTRIM(homephone) homephone
5024       ,NULL homefax    -- not used in hercules
5025       ,NULL homeemail  -- not used in hercules
5026       FROM  igs_uc_ivstara_2003_v
5027       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5028 
5029       -- get the max timestamp value of the hercules view
5030       CURSOR c_max_timestamp IS
5031       SELECT MAX(timestamp)
5032       FROM igs_uc_ivstara_2003_v  ;
5033 
5034       -- Variables
5035       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5036       l_new_max_timestamp igs_uc_ivstara_2003_v.timestamp%TYPE ;
5037       l_count NUMBER ;
5038 
5039   BEGIN
5040        -- set syncronization required to false
5041        g_sync_reqd := FALSE;
5042        l_count := 0 ;
5043 
5044       -- log message that this view is being loaded
5045       log_start( 'IVSTARA ON ') ;
5046 
5047       -- Get the old timestamp for this view in the configured cycle
5048       Herc_timestamp_exists('IVSTARA', p_old_timestamp) ;
5049 
5050        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5051        FOR c_ivstara_rec IN c_ivstara(p_old_timestamp) LOOP
5052               -- set x_sync_read to true if the loop is entered even once
5053               g_sync_reqd := TRUE;
5054 
5055               -- Obsolete matching records in interface table with status N
5056               UPDATE igs_uc_istara_ints SET record_status = 'O'
5057               WHERE record_status = 'N' AND  appno = c_ivstara_rec.appno;
5058 
5059               -- copy hercules record into interface table with record status N
5060               INSERT INTO igs_uc_istara_ints (  appno,
5061                                                 addressarea,
5062                                                 address1,
5063                                                 address2,
5064                                                 address3,
5065                                                 address4,
5066                                                 postcode,
5067                                                 mailsort,
5068                                                 telephone,
5069                                                 fax,
5070                                                 email,
5071                                                 homeaddress1,
5072                                                 homeaddress2,
5073                                                 homeaddress3,
5074                                                 homeaddress4,
5075                                                 homepostcode,
5076                                                 homephone,
5077                                                 homefax,
5078                                                 homeemail,
5079                                                 record_status,
5080                                                 error_code
5081                                                  )
5082                                      VALUES (   c_ivstara_rec.appno,
5083                                                 c_ivstara_rec.addressarea,
5084                                                 c_ivstara_rec.address1,
5085                                                 c_ivstara_rec.address2,
5086                                                 c_ivstara_rec.address3,
5087                                                 c_ivstara_rec.address4,
5088                                                 c_ivstara_rec.postcode,
5089                                                 c_ivstara_rec.mailsort,
5090                                                 c_ivstara_rec.telephone,
5091                                                 c_ivstara_rec.fax,
5092                                                 c_ivstara_rec.email,
5093                                                 c_ivstara_rec.homeaddress1,
5094                                                 c_ivstara_rec.homeaddress2,
5095                                                 c_ivstara_rec.homeaddress3,
5096                                                 c_ivstara_rec.homeaddress4,
5097                                                 c_ivstara_rec.homepostcode,
5098                                                 c_ivstara_rec.homephone,
5099                                                 c_ivstara_rec.homefax,
5100                                                 c_ivstara_rec.homeemail,
5101                                                  'N',
5102                                                  NULL ) ;
5103         -- increment count of records
5104         l_count := l_count + 1;
5105 
5106        END LOOP ;
5107 
5108       IF g_sync_reqd THEN
5109               -- get the max timestamp of this hercules view
5110               OPEN c_max_timestamp ;
5111               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5112               CLOSE c_max_timestamp ;
5113 
5114                -- update /insert the timestamp record with new max timestamp
5115                ins_upd_timestamp ('IVSTARA', l_new_max_timestamp) ;
5116 
5117               -- log message that this view has been loaded
5118                log_complete( 'IVSTARA', l_count) ;
5119       ELSE
5120                 -- log message that this view is already in sync and need not be loaded
5121                log_already_insync('IVSTARA') ;
5122       END IF ;
5123       COMMIT;
5124 
5125   EXCEPTION
5126       WHEN OTHERS THEN
5127                ROLLBACK;
5128                write_to_log(SQLERRM);
5129                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5130                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARA_2003');
5131                igs_ge_msg_stack.add;
5132                app_exception.raise_exception ;
5133   END   load_ivstara_2003  ;
5134 
5135 
5136   PROCEDURE load_ivstara_2006 IS
5137     /******************************************************************
5138      Created By      :  jbaber
5139      Date Created By :   11-Jun-03
5140      Purpose         :   loads each record in the hercules view ivstara into the interface table
5141                          igs_uc_istara_ints with record status N
5142      Known limitations,enhancements,remarks:
5143      Change History
5144      Who       When         What
5145     ***************************************************************** */
5146 
5147      -- Get all the records from hercules  view whose timestamp is > passed timestamp
5148       -- or get all the records in hercules view if the timestamp passed is null
5149       CURSOR c_ivstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5150       SELECT appno
5151       ,timestamp
5152       ,addressarea
5153       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5154       ,RTRIM(address2) address2
5155       ,RTRIM(address3) address3
5156       ,RTRIM(address4) address4
5157       ,RTRIM(postcode) postcode
5158       ,mailsort
5159       ,RTRIM(telephone) telephone
5160       ,RTRIM(email) email
5161       ,DECODE(RTRIM(homeaddress1),NULL, RPAD('*',LENGTH(homeaddress1),'*'), RTRIM(homeaddress1)) homeaddress1
5162       ,RTRIM(homeaddress2) homeaddress2
5163       ,RTRIM(homeaddress3) homeaddress3
5164       ,RTRIM(homeaddress4) homeaddress4
5165       ,RTRIM(homepostcode) homepostcode
5166       FROM  igs_uc_ivstara_2006_v
5167       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5168 
5169       -- get the max timestamp value of the hercules view
5170       CURSOR c_max_timestamp IS
5171       SELECT MAX(timestamp)
5172       FROM igs_uc_ivstara_2006_v  ;
5173 
5174       -- Variables
5175       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5176       l_new_max_timestamp igs_uc_ivstara_2006_v.timestamp%TYPE ;
5177       l_count NUMBER ;
5178 
5179       l_appno      igs_uc_istara_ints.appno%TYPE;
5180       l_checkdigit NUMBER;
5181 
5182   BEGIN
5183        -- set syncronization required to false
5184        g_sync_reqd := FALSE;
5185        l_count := 0 ;
5186 
5187       -- log message that this view is being loaded
5188       log_start( 'IVSTARA ON ') ;
5189 
5190       -- Get the old timestamp for this view in the configured cycle
5191       Herc_timestamp_exists('IVSTARA', p_old_timestamp) ;
5192 
5193        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5194        FOR c_ivstara_rec IN c_ivstara(p_old_timestamp) LOOP
5195               -- set x_sync_read to true if the loop is entered even once
5196               g_sync_reqd := TRUE;
5197 
5198               IF  is_valid(c_ivstara_rec.appno,'IVSTARA','APPNO','NUMBER') THEN
5199 
5200                   -- Determine actual appno
5201                   get_appno(c_ivstara_rec.appno, NULL, l_appno, l_checkdigit);
5202 
5203                   -- Obsolete matching records in interface table with status N
5204                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5205                   WHERE record_status = 'N' AND  appno = l_appno;
5206 
5207                   -- copy hercules record into interface table with record status N
5208                   INSERT INTO igs_uc_istara_ints (  appno,
5209                                                     addressarea,
5210                                                     address1,
5211                                                     address2,
5212                                                     address3,
5213                                                     address4,
5214                                                     postcode,
5215                                                     mailsort,
5216                                                     telephone,
5217                                                     email,
5218                                                     homeaddress1,
5219                                                     homeaddress2,
5220                                                     homeaddress3,
5221                                                     homeaddress4,
5222                                                     homepostcode,
5223                                                     record_status,
5224                                                     error_code
5225                                                      )
5226                                          VALUES (   l_appno,
5227                                                     c_ivstara_rec.addressarea,
5228                                                     c_ivstara_rec.address1,
5229                                                     c_ivstara_rec.address2,
5230                                                     c_ivstara_rec.address3,
5231                                                     c_ivstara_rec.address4,
5232                                                     c_ivstara_rec.postcode,
5233                                                     c_ivstara_rec.mailsort,
5234                                                     c_ivstara_rec.telephone,
5235                                                     c_ivstara_rec.email,
5236                                                     c_ivstara_rec.homeaddress1,
5237                                                     c_ivstara_rec.homeaddress2,
5238                                                     c_ivstara_rec.homeaddress3,
5239                                                     c_ivstara_rec.homeaddress4,
5240                                                     c_ivstara_rec.homepostcode,
5241                                                      'N',
5242                                                      NULL ) ;
5243                   -- increment count of records
5244                   l_count := l_count + 1;
5245 
5246               END IF;
5247 
5248        END LOOP ;
5249 
5250       IF g_sync_reqd THEN
5251               -- get the max timestamp of this hercules view
5252               OPEN c_max_timestamp ;
5253               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5254               CLOSE c_max_timestamp ;
5255 
5256                -- update /insert the timestamp record with new max timestamp
5257                ins_upd_timestamp ('IVSTARA', l_new_max_timestamp) ;
5258 
5259               -- log message that this view has been loaded
5260                log_complete( 'IVSTARA', l_count) ;
5261       ELSE
5262                 -- log message that this view is already in sync and need not be loaded
5263                log_already_insync('IVSTARA') ;
5264       END IF ;
5265       COMMIT;
5266 
5267   EXCEPTION
5268       WHEN OTHERS THEN
5269                ROLLBACK;
5270                write_to_log(SQLERRM);
5271                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5272                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARA_2006');
5273                igs_ge_msg_stack.add;
5274                app_exception.raise_exception ;
5275   END   load_ivstara_2006  ;
5276 
5277   PROCEDURE load_ivstara_2007 IS
5278     /******************************************************************
5279      Created By      :  jbaber
5280      Date Created By :   11-Jul-06
5281      Purpose         :   loads each record in the hercules view ivstara into the interface table
5282                          igs_uc_istara_ints with record status N
5283      Known limitations,enhancements,remarks:
5284      Change History
5285      Who       When         What
5286     ***************************************************************** */
5287 
5288      -- Get all the records from hercules  view whose timestamp is > passed timestamp
5289       -- or get all the records in hercules view if the timestamp passed is null
5290       CURSOR c_ivstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5291       SELECT appno
5292       ,timestamp
5293       ,addressarea
5294       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5295       ,RTRIM(address2) address2
5296       ,RTRIM(address3) address3
5297       ,RTRIM(address4) address4
5298       ,RTRIM(postcode) postcode
5299       ,mailsort
5300       ,RTRIM(telephone) telephone
5301       ,RTRIM(email) email
5302       ,DECODE(RTRIM(homeaddress1),NULL, RPAD('*',LENGTH(homeaddress1),'*'), RTRIM(homeaddress1)) homeaddress1
5303       ,RTRIM(homeaddress2) homeaddress2
5304       ,RTRIM(homeaddress3) homeaddress3
5305       ,RTRIM(homeaddress4) homeaddress4
5306       ,RTRIM(homepostcode) homepostcode
5307       ,RTRIM(mobile) mobile
5308       ,RTRIM(countrycode) countrycode
5309       ,RTRIM(homecountrycode) homecountrycode
5310       FROM  igs_uc_ivstara_2007_v
5311       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5312 
5313       -- get the max timestamp value of the hercules view
5314       CURSOR c_max_timestamp IS
5315       SELECT MAX(timestamp)
5316       FROM igs_uc_ivstara_2007_v  ;
5317 
5318       -- Variables
5319       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5320       l_new_max_timestamp igs_uc_ivstara_2007_v.timestamp%TYPE ;
5321       l_count NUMBER ;
5322 
5323       l_appno      igs_uc_istara_ints.appno%TYPE;
5324       l_checkdigit NUMBER;
5325 
5326   BEGIN
5327        -- set syncronization required to false
5328        g_sync_reqd := FALSE;
5329        l_count := 0 ;
5330 
5331       -- log message that this view is being loaded
5332       log_start( 'IVSTARA ON ') ;
5333 
5334       -- Get the old timestamp for this view in the configured cycle
5335       Herc_timestamp_exists('IVSTARA', p_old_timestamp) ;
5336 
5337        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5338        FOR c_ivstara_rec IN c_ivstara(p_old_timestamp) LOOP
5339               -- set x_sync_read to true if the loop is entered even once
5340               g_sync_reqd := TRUE;
5341 
5342               IF  is_valid(c_ivstara_rec.appno,'IVSTARA','APPNO','NUMBER') THEN
5343 
5344                   -- Determine actual appno
5345                   get_appno(c_ivstara_rec.appno, NULL, l_appno, l_checkdigit);
5346 
5347                   -- Obsolete matching records in interface table with status N
5348                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5349                   WHERE record_status = 'N' AND  appno = l_appno;
5350 
5351                   -- copy hercules record into interface table with record status N
5352                   INSERT INTO igs_uc_istara_ints (  appno,
5353                                                     addressarea,
5354                                                     address1,
5355                                                     address2,
5356                                                     address3,
5357                                                     address4,
5358                                                     postcode,
5359                                                     mailsort,
5360                                                     telephone,
5361                                                     email,
5362                                                     homeaddress1,
5363                                                     homeaddress2,
5364                                                     homeaddress3,
5365                                                     homeaddress4,
5366                                                     homepostcode,
5367                                                     mobile,
5368                                                     countrycode,
5369                                                     homecountrycode,
5370                                                     record_status,
5371                                                     error_code
5372                                                      )
5373                                          VALUES (   l_appno,
5374                                                     c_ivstara_rec.addressarea,
5375                                                     c_ivstara_rec.address1,
5376                                                     c_ivstara_rec.address2,
5377                                                     c_ivstara_rec.address3,
5378                                                     c_ivstara_rec.address4,
5379                                                     c_ivstara_rec.postcode,
5380                                                     c_ivstara_rec.mailsort,
5381                                                     c_ivstara_rec.telephone,
5382                                                     c_ivstara_rec.email,
5383                                                     c_ivstara_rec.homeaddress1,
5384                                                     c_ivstara_rec.homeaddress2,
5385                                                     c_ivstara_rec.homeaddress3,
5386                                                     c_ivstara_rec.homeaddress4,
5387                                                     c_ivstara_rec.homepostcode,
5388                                                     c_ivstara_rec.mobile,
5389                                                     c_ivstara_rec.countrycode,
5390                                                     c_ivstara_rec.homecountrycode,
5391                                                      'N',
5392                                                      NULL ) ;
5393                   -- increment count of records
5394                   l_count := l_count + 1;
5395 
5396               END IF;
5397 
5398        END LOOP ;
5399 
5400       IF g_sync_reqd THEN
5401               -- get the max timestamp of this hercules view
5402               OPEN c_max_timestamp ;
5403               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5404               CLOSE c_max_timestamp ;
5405 
5406                -- update /insert the timestamp record with new max timestamp
5407                ins_upd_timestamp ('IVSTARA', l_new_max_timestamp) ;
5408 
5409               -- log message that this view has been loaded
5410                log_complete( 'IVSTARA', l_count) ;
5411       ELSE
5412                 -- log message that this view is already in sync and need not be loaded
5413                log_already_insync('IVSTARA') ;
5414       END IF ;
5415       COMMIT;
5416 
5417   EXCEPTION
5418       WHEN OTHERS THEN
5419                ROLLBACK;
5420                write_to_log(SQLERRM);
5421                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5422                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARA_2007');
5423                igs_ge_msg_stack.add;
5424                app_exception.raise_exception ;
5425   END   load_ivstara_2007  ;
5426 
5427 
5428   PROCEDURE load_ivgstara_2006 IS
5429     /******************************************************************
5430      Created By      :   jbaber
5431      Date Created By :   12-Aug-03
5432      Purpose         :   loads each record in the hercules view ivgstara into the interface table
5433                          igs_uc_istara_ints with record status N
5434      Known limitations,enhancements,remarks:
5435      Change History
5436      Who       When         What
5437     ***************************************************************** */
5438 
5439      -- Get all the records from odbc-link view whose timestamp is > passed timestamp
5440       -- or get all the records in odbc-link view if the timestamp passed is null
5441       CURSOR c_ivgstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5442       SELECT appno
5443       ,timestamp
5444       ,RTRIM(addressarea) addressarea
5445       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5446       ,RTRIM(address2) address2
5447       ,RTRIM(address3) address3
5448       ,RTRIM(address4) address4
5449       ,RTRIM(postcode) postcode
5450       ,mailsort
5451       ,RTRIM(telephone) telephone
5452       ,RTRIM(email) email
5453       ,RTRIM(homepostcode) homepostcode
5454       FROM  igs_uc_ivgstara_2006_v
5455       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5456 
5457       -- get the max timestamp value of the hercules view
5458       CURSOR c_max_timestamp IS
5459       SELECT MAX(timestamp)
5460       FROM igs_uc_ivgstara_2006_v  ;
5461 
5462       -- Variables
5463       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5464       l_new_max_timestamp igs_uc_ivgstara_2006_v.timestamp%TYPE ;
5465       l_count NUMBER ;
5466 
5467       l_appno      igs_uc_istara_ints.appno%TYPE;
5468       l_checkdigit NUMBER;
5469 
5470   BEGIN
5471        -- set syncronization required to false
5472        g_sync_reqd := FALSE;
5473        l_count := 0 ;
5474 
5475       -- log message that this view is being loaded
5476       log_start( 'IVGSTARA ON ') ;
5477 
5478       -- Get the old timestamp for this view in the configured cycle
5479       Herc_timestamp_exists('IVGSTARA', p_old_timestamp) ;
5480 
5481        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5482        FOR c_ivgstara_rec IN c_ivgstara(p_old_timestamp) LOOP
5483               -- set x_sync_read to true if the loop is entered even once
5484               g_sync_reqd := TRUE;
5485 
5486               IF  is_valid(c_ivgstara_rec.appno,'IVGSTARA','APPNO','NUMBER') THEN
5487 
5488                   -- Determine actual appno
5489                   get_appno(c_ivgstara_rec.appno, NULL, l_appno, l_checkdigit);
5490 
5491                   -- Obsolete matching records in interface table with status N
5492                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5493                   WHERE record_status = 'N' AND  appno = l_appno;
5494 
5495                   -- copy hercules record into interface table with record status N
5496                   INSERT INTO igs_uc_istara_ints (  appno,
5497                                                     addressarea,
5498                                                     address1,
5499                                                     address2,
5500                                                     address3,
5501                                                     address4,
5502                                                     postcode,
5503                                                     mailsort,
5504                                                     telephone,
5505                                                     email,
5506                                                     homepostcode,
5507                                                     record_status,
5508                                                     error_code
5509                                                      )
5510                                          VALUES (   l_appno,
5511                                                     c_ivgstara_rec.addressarea,
5512                                                     c_ivgstara_rec.address1,
5513                                                     c_ivgstara_rec.address2,
5514                                                     c_ivgstara_rec.address3,
5515                                                     c_ivgstara_rec.address4,
5516                                                     c_ivgstara_rec.postcode,
5517                                                     c_ivgstara_rec.mailsort,
5518                                                     c_ivgstara_rec.telephone,
5519                                                     c_ivgstara_rec.email,
5520                                                     c_ivgstara_rec.homepostcode,
5521                                                      'N',
5522                                                      NULL ) ;
5523                   -- increment count of records
5524                   l_count := l_count + 1;
5525 
5526               END IF;
5527 
5528        END LOOP ;
5529 
5530       IF g_sync_reqd THEN
5531               -- get the max timestamp of this hercules view
5532               OPEN c_max_timestamp ;
5533               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5534               CLOSE c_max_timestamp ;
5535 
5536                -- update /insert the timestamp record with new max timestamp
5537                ins_upd_timestamp ('IVGSTARA', l_new_max_timestamp) ;
5538 
5539               -- log message that this view has been loaded
5540                log_complete( 'IVGSTARA', l_count) ;
5541       ELSE
5542                 -- log message that this view is already in sync and need not be loaded
5543                log_already_insync('IVGSTARA') ;
5544       END IF ;
5545       COMMIT;
5546 
5547   EXCEPTION
5548       WHEN OTHERS THEN
5549                ROLLBACK;
5550                write_to_log(SQLERRM);
5551                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5552                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARA_2006');
5553                igs_ge_msg_stack.add;
5554                app_exception.raise_exception ;
5555   END   load_ivgstara_2006  ;
5556 
5557 
5558   PROCEDURE load_ivgstara_2007 IS
5559     /******************************************************************
5560      Created By      :   jbaber
5561      Date Created By :   11-Jul-06
5562      Purpose         :   loads each record in the hercules view ivgstara into the interface table
5563                          igs_uc_istara_ints with record status N
5564      Known limitations,enhancements,remarks:
5565      Change History
5566      Who       When         What
5567     ***************************************************************** */
5568 
5569      -- Get all the records from hercules  view whose timestamp is > passed timestamp
5570       -- or get all the records in hercules view if the timestamp passed is null
5571       CURSOR c_ivgstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5572       SELECT appno
5573       ,timestamp
5574       ,addressarea
5575       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5576       ,RTRIM(address2) address2
5577       ,RTRIM(address3) address3
5578       ,RTRIM(address4) address4
5579       ,RTRIM(postcode) postcode
5580       ,mailsort
5581       ,RTRIM(telephone) telephone
5582       ,RTRIM(email) email
5583       ,DECODE(RTRIM(home_address1),NULL, RPAD('*',LENGTH(home_address1),'*'), RTRIM(home_address1)) homeaddress1
5584       ,RTRIM(home_address2) homeaddress2
5585       ,RTRIM(home_address3) homeaddress3
5586       ,RTRIM(home_address4) homeaddress4
5587       ,RTRIM(homepostcode) homepostcode
5588       ,RTRIM(mobile) mobile
5589       ,RTRIM(countrycode) countrycode
5590       ,RTRIM(homecountrycode) homecountrycode
5591       FROM  igs_uc_ivgstara_2007_v
5592       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5593 
5594       -- get the max timestamp value of the hercules view
5595       CURSOR c_max_timestamp IS
5596       SELECT MAX(timestamp)
5597       FROM igs_uc_ivgstara_2007_v  ;
5598 
5599       -- Variables
5600       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5601       l_new_max_timestamp igs_uc_ivgstara_2007_v.timestamp%TYPE ;
5602       l_count NUMBER ;
5603 
5604       l_appno      igs_uc_istara_ints.appno%TYPE;
5605       l_checkdigit NUMBER;
5606 
5607   BEGIN
5608        -- set syncronization required to false
5609        g_sync_reqd := FALSE;
5610        l_count := 0 ;
5611 
5612       -- log message that this view is being loaded
5613       log_start( 'IVGSTARA ON ') ;
5614 
5615       -- Get the old timestamp for this view in the configured cycle
5616       Herc_timestamp_exists('IVGSTARA', p_old_timestamp) ;
5617 
5618        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5619        FOR c_ivgstara_rec IN c_ivgstara(p_old_timestamp) LOOP
5620               -- set x_sync_read to true if the loop is entered even once
5621               g_sync_reqd := TRUE;
5622 
5623               IF  is_valid(c_ivgstara_rec.appno,'IVGSTARA','APPNO','NUMBER') THEN
5624 
5625                   -- Determine actual appno
5626                   get_appno(c_ivgstara_rec.appno, NULL, l_appno, l_checkdigit);
5627 
5628                   -- Obsolete matching records in interface table with status N
5629                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5630                   WHERE record_status = 'N' AND  appno = l_appno;
5631 
5632                   -- copy hercules record into interface table with record status N
5633                   INSERT INTO igs_uc_istara_ints (  appno,
5634                                                     addressarea,
5635                                                     address1,
5636                                                     address2,
5637                                                     address3,
5638                                                     address4,
5639                                                     postcode,
5640                                                     mailsort,
5641                                                     telephone,
5642                                                     email,
5643                                                     homeaddress1,
5644                                                     homeaddress2,
5645                                                     homeaddress3,
5646                                                     homeaddress4,
5647                                                     homepostcode,
5648                                                     mobile,
5649                                                     countrycode,
5650                                                     homecountrycode,
5651                                                     record_status,
5652                                                     error_code
5653                                                      )
5654                                          VALUES (   l_appno,
5655                                                     c_ivgstara_rec.addressarea,
5656                                                     c_ivgstara_rec.address1,
5657                                                     c_ivgstara_rec.address2,
5658                                                     c_ivgstara_rec.address3,
5659                                                     c_ivgstara_rec.address4,
5660                                                     c_ivgstara_rec.postcode,
5661                                                     c_ivgstara_rec.mailsort,
5662                                                     c_ivgstara_rec.telephone,
5663                                                     c_ivgstara_rec.email,
5664                                                     c_ivgstara_rec.homeaddress1,
5665                                                     c_ivgstara_rec.homeaddress2,
5666                                                     c_ivgstara_rec.homeaddress3,
5667                                                     c_ivgstara_rec.homeaddress4,
5668                                                     c_ivgstara_rec.homepostcode,
5669                                                     c_ivgstara_rec.mobile,
5670                                                     c_ivgstara_rec.countrycode,
5671                                                     c_ivgstara_rec.homecountrycode,
5672                                                      'N',
5673                                                      NULL ) ;
5674                   -- increment count of records
5675                   l_count := l_count + 1;
5676 
5677               END IF;
5678 
5679        END LOOP ;
5680 
5681       IF g_sync_reqd THEN
5682               -- get the max timestamp of this hercules view
5683               OPEN c_max_timestamp ;
5684               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5685               CLOSE c_max_timestamp ;
5686 
5687                -- update /insert the timestamp record with new max timestamp
5688                ins_upd_timestamp ('IVGSTARA', l_new_max_timestamp) ;
5689 
5690               -- log message that this view has been loaded
5691                log_complete( 'IVGSTARA', l_count) ;
5692       ELSE
5693                 -- log message that this view is already in sync and need not be loaded
5694                log_already_insync('IVGSTARA') ;
5695       END IF ;
5696       COMMIT;
5697 
5698   EXCEPTION
5699       WHEN OTHERS THEN
5700                ROLLBACK;
5701                write_to_log(SQLERRM);
5702                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5703                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARA_2007');
5704                igs_ge_msg_stack.add;
5705                app_exception.raise_exception ;
5706   END   load_ivgstara_2007  ;
5707 
5708 
5709   PROCEDURE load_ivnstara_2006 IS
5710     /******************************************************************
5711      Created By      :   jbaber
5712      Date Created By :   12-Aug-03
5713      Purpose         :   loads each record in the hercules view ivnstara into the interface table
5714                          igs_uc_istara_ints with record status N
5715      Known limitations,enhancements,remarks:
5716      Change History
5717      Who       When         What
5718     ***************************************************************** */
5719 
5720      -- Get all the records from odbc-link view whose timestamp is > passed timestamp
5721       -- or get all the records in odbc-link view if the timestamp passed is null
5722       CURSOR c_ivnstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5723       SELECT appno
5724       ,timestamp
5725       ,RTRIM(addressarea) addressarea
5726       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5727       ,RTRIM(address2) address2
5728       ,RTRIM(address3) address3
5729       ,RTRIM(address4) address4
5730       ,RTRIM(postcode) postcode
5731       ,mailsort
5732       ,RTRIM(telephone) telephone
5733       ,RTRIM(email) email
5734       ,RTRIM(homepostcode) homepostcode
5735       FROM  igs_uc_ivnstara_2006_v
5736       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5737 
5738       -- get the max timestamp value of the hercules view
5739       CURSOR c_max_timestamp IS
5740       SELECT MAX(timestamp)
5741       FROM igs_uc_ivnstara_2006_v  ;
5742 
5743       -- Variables
5744       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5745       l_new_max_timestamp igs_uc_ivnstara_2006_v.timestamp%TYPE ;
5746       l_count NUMBER ;
5747 
5748       l_appno      igs_uc_istara_ints.appno%TYPE;
5749       l_checkdigit NUMBER;
5750 
5751   BEGIN
5752        -- set syncronization required to false
5753        g_sync_reqd := FALSE;
5754        l_count := 0 ;
5755 
5756       -- log message that this view is being loaded
5757       log_start( 'IVNSTARA ON ') ;
5758 
5759       -- Get the old timestamp for this view in the configured cycle
5760       Herc_timestamp_exists('IVNSTARA', p_old_timestamp) ;
5761 
5762        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5763        FOR c_ivnstara_rec IN c_ivnstara(p_old_timestamp) LOOP
5764               -- set x_sync_read to true if the loop is entered even once
5765               g_sync_reqd := TRUE;
5766 
5767               IF  is_valid(c_ivnstara_rec.appno,'IVNSTARA','APPNO','NUMBER') THEN
5768 
5769                   -- Determine actual appno
5770                   get_appno(c_ivnstara_rec.appno, NULL, l_appno, l_checkdigit);
5771 
5772                   -- Obsolete matching records in interface table with status N
5773                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5774                   WHERE record_status = 'N' AND  appno = l_appno;
5775 
5776                   -- copy hercules record into interface table with record status N
5777                   INSERT INTO igs_uc_istara_ints (  appno,
5778                                                     addressarea,
5779                                                     address1,
5780                                                     address2,
5781                                                     address3,
5782                                                     address4,
5783                                                     postcode,
5784                                                     mailsort,
5785                                                     telephone,
5786                                                     email,
5787                                                     homepostcode,
5788                                                     record_status,
5789                                                     error_code
5790                                                      )
5791                                          VALUES (   l_appno,
5792                                                     c_ivnstara_rec.addressarea,
5793                                                     c_ivnstara_rec.address1,
5794                                                     c_ivnstara_rec.address2,
5795                                                     c_ivnstara_rec.address3,
5796                                                     c_ivnstara_rec.address4,
5797                                                     c_ivnstara_rec.postcode,
5798                                                     c_ivnstara_rec.mailsort,
5799                                                     c_ivnstara_rec.telephone,
5800                                                     c_ivnstara_rec.email,
5801                                                     c_ivnstara_rec.homepostcode,
5802                                                      'N',
5803                                                      NULL ) ;
5804                   -- increment count of records
5805                   l_count := l_count + 1;
5806 
5807               END IF;
5808 
5809        END LOOP ;
5810 
5811       IF g_sync_reqd THEN
5812               -- get the max timestamp of this hercules view
5813               OPEN c_max_timestamp ;
5814               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5815               CLOSE c_max_timestamp ;
5816 
5817                -- update /insert the timestamp record with new max timestamp
5818                ins_upd_timestamp ('IVNSTARA', l_new_max_timestamp) ;
5819 
5820               -- log message that this view has been loaded
5821                log_complete( 'IVNSTARA', l_count) ;
5822       ELSE
5823                 -- log message that this view is already in sync and need not be loaded
5824                log_already_insync('IVNSTARA') ;
5825       END IF ;
5826       COMMIT;
5827 
5828   EXCEPTION
5829       WHEN OTHERS THEN
5830                ROLLBACK;
5831                write_to_log(SQLERRM);
5832                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5833                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARA_2006');
5834                igs_ge_msg_stack.add;
5835                app_exception.raise_exception ;
5836   END   load_ivnstara_2006  ;
5837 
5838 
5839   PROCEDURE load_ivnstara_2007 IS
5840     /******************************************************************
5841      Created By      :   jbaber
5842      Date Created By :   11-Jul-06
5843      Purpose         :   loads each record in the hercules view ivnstara into the interface table
5844                          igs_uc_istara_ints with record status N
5845      Known limitations,enhancements,remarks:
5846      Change History
5847      Who       When         What
5848     ***************************************************************** */
5849 
5850      -- Get all the records from hercules  view whose timestamp is > passed timestamp
5851       -- or get all the records in hercules view if the timestamp passed is null
5852       CURSOR c_ivnstara ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
5853       SELECT appno
5854       ,timestamp
5855       ,addressarea
5856       ,DECODE(RTRIM(address1),NULL, RPAD('*',LENGTH(address1),'*'), RTRIM(address1)) address1
5857       ,RTRIM(address2) address2
5858       ,RTRIM(address3) address3
5859       ,RTRIM(address4) address4
5860       ,RTRIM(postcode) postcode
5861       ,mailsort
5862       ,RTRIM(telephone) telephone
5863       ,RTRIM(email) email
5864       ,DECODE(RTRIM(homeaddress1),NULL, RPAD('*',LENGTH(homeaddress1),'*'), RTRIM(homeaddress1)) homeaddress1
5865       ,RTRIM(homeaddress2) homeaddress2
5866       ,RTRIM(homeaddress3) homeaddress3
5867       ,RTRIM(homeaddress4) homeaddress4
5868       ,RTRIM(homepostcode) homepostcode
5869       ,RTRIM(mobile) mobile
5870       ,RTRIM(countrycode) countrycode
5871       ,RTRIM(homecountrycode) homecountrycode
5872       FROM  igs_uc_ivnstara_2007_v
5873       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
5874 
5875       -- get the max timestamp value of the hercules view
5876       CURSOR c_max_timestamp IS
5877       SELECT MAX(timestamp)
5878       FROM igs_uc_ivnstara_2007_v  ;
5879 
5880       -- Variables
5881       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
5882       l_new_max_timestamp igs_uc_ivnstara_2007_v.timestamp%TYPE ;
5883       l_count NUMBER ;
5884 
5885       l_appno      igs_uc_istara_ints.appno%TYPE;
5886       l_checkdigit NUMBER;
5887 
5888   BEGIN
5889        -- set syncronization required to false
5890        g_sync_reqd := FALSE;
5891        l_count := 0 ;
5892 
5893       -- log message that this view is being loaded
5894       log_start( 'IVNSTARA ON ') ;
5895 
5896       -- Get the old timestamp for this view in the configured cycle
5897       Herc_timestamp_exists('IVNSTARA', p_old_timestamp) ;
5898 
5899        -- create interface records for each record in the hercules view whose timestamp > old timestamp
5900        FOR c_ivnstara_rec IN c_ivnstara(p_old_timestamp) LOOP
5901               -- set x_sync_read to true if the loop is entered even once
5902               g_sync_reqd := TRUE;
5903 
5904               IF  is_valid(c_ivnstara_rec.appno,'IVNSTARA','APPNO','NUMBER') THEN
5905 
5906                   -- Determine actual appno
5907                   get_appno(c_ivnstara_rec.appno, NULL, l_appno, l_checkdigit);
5908 
5909                   -- Obsolete matching records in interface table with status N
5910                   UPDATE igs_uc_istara_ints SET record_status = 'O'
5911                   WHERE record_status = 'N' AND  appno = l_appno;
5912 
5913                   -- copy hercules record into interface table with record status N
5914                   INSERT INTO igs_uc_istara_ints (  appno,
5915                                                     addressarea,
5916                                                     address1,
5917                                                     address2,
5918                                                     address3,
5919                                                     address4,
5920                                                     postcode,
5921                                                     mailsort,
5922                                                     telephone,
5923                                                     email,
5924                                                     homeaddress1,
5925                                                     homeaddress2,
5926                                                     homeaddress3,
5927                                                     homeaddress4,
5928                                                     homepostcode,
5929                                                     mobile,
5930                                                     countrycode,
5931                                                     homecountrycode,
5932                                                     record_status,
5933                                                     error_code
5934                                                      )
5935                                          VALUES (   l_appno,
5936                                                     c_ivnstara_rec.addressarea,
5937                                                     c_ivnstara_rec.address1,
5938                                                     c_ivnstara_rec.address2,
5939                                                     c_ivnstara_rec.address3,
5940                                                     c_ivnstara_rec.address4,
5941                                                     c_ivnstara_rec.postcode,
5942                                                     c_ivnstara_rec.mailsort,
5943                                                     c_ivnstara_rec.telephone,
5944                                                     c_ivnstara_rec.email,
5945                                                     c_ivnstara_rec.homeaddress1,
5946                                                     c_ivnstara_rec.homeaddress2,
5947                                                     c_ivnstara_rec.homeaddress3,
5948                                                     c_ivnstara_rec.homeaddress4,
5949                                                     c_ivnstara_rec.homepostcode,
5950                                                     c_ivnstara_rec.mobile,
5951                                                     c_ivnstara_rec.countrycode,
5952                                                     c_ivnstara_rec.homecountrycode,
5953                                                      'N',
5954                                                      NULL ) ;
5955                   -- increment count of records
5956                   l_count := l_count + 1;
5957 
5958               END IF;
5959 
5960        END LOOP ;
5961 
5962       IF g_sync_reqd THEN
5963               -- get the max timestamp of this hercules view
5964               OPEN c_max_timestamp ;
5965               FETCH c_max_timestamp INTO l_new_max_timestamp ;
5966               CLOSE c_max_timestamp ;
5967 
5968                -- update /insert the timestamp record with new max timestamp
5969                ins_upd_timestamp ('IVNSTARA', l_new_max_timestamp) ;
5970 
5971               -- log message that this view has been loaded
5972                log_complete( 'IVNSTARA', l_count) ;
5973       ELSE
5974                 -- log message that this view is already in sync and need not be loaded
5975                log_already_insync('IVNSTARA') ;
5976       END IF ;
5977       COMMIT;
5978 
5979   EXCEPTION
5980       WHEN OTHERS THEN
5981                ROLLBACK;
5982                write_to_log(SQLERRM);
5983                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
5984                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARA_2007');
5985                igs_ge_msg_stack.add;
5986                app_exception.raise_exception ;
5987   END   load_ivnstara_2007  ;
5988 
5989 
5990   PROCEDURE load_ivstarc_2003 IS
5991     /******************************************************************
5992      Created By      :  smaddali
5993      Date Created By :   11-Jun-03
5994      Purpose         :     loads each record in the hercules view ivstarc into the interface table
5995                            igs_uc_istarc_ints with record status N
5996      Known limitations,enhancements,remarks:
5997      Change History
5998      Who       When         What
5999      jbaber    15-Sep-05    Replace inst, course and campus values with '*' if NULL
6000                             and force 2-digit entry year for bug 4589994
6001      jbaber    11-Jul-06    Truncate detail to 20 characters for UCAS 2007 Support
6002      anwest    02-AUG-06    Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6003     ***************************************************************** */
6004 
6005      -- Get all the records from hercules  view whose timestamp is > passed timestamp
6006       -- or get all the records in hercules view if the timestamp passed is null
6007       CURSOR c_ivstarc ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6008       SELECT appno
6009             ,NVL(choiceno,9) choiceno -- 02-AUG-2006 anwest Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6010             ,timestamp
6011             ,NVL(lastchange,SYSDATE) lastchange
6012             ,NVL(DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)),'*') inst
6013             ,NVL(DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)),'*') course
6014             ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
6015             ,RTRIM(faculty) faculty
6016             ,RTRIM(home)  home
6017             ,RTRIM(decision) decision
6018             ,decisiondate
6019             ,decisionnumber
6020             ,RTRIM(reply) reply
6021             ,RTRIM(summaryconditions) summaryconditions
6022             ,entrymonth
6023             ,SUBSTR(LPAD(entryyear,4,0),3,2) entryyear
6024             ,entrypoint
6025             ,RTRIM(choicecancelled) choicecancelled
6026             ,RTRIM(action) action
6027             ,RTRIM(substitution) substitution
6028             ,datesubstituted
6029             ,DECODE(RTRIM(previousinst),NULL, RPAD('*',LENGTH(previousinst),'*'), RTRIM(previousinst)) previousinst
6030             ,DECODE(RTRIM(previouscourse),NULL, RPAD('*',LENGTH(previouscourse),'*'), RTRIM(previouscourse)) previouscourse
6031             ,DECODE(RTRIM(previouscampus),NULL, RPAD('*',LENGTH(previouscampus),'*'), RTRIM(previouscampus)) previouscampus
6032             ,RTRIM(ucasamendment) ucasamendment
6033             ,routebpref
6034             ,routebround
6035             ,RTRIM(SUBSTR(detail,1,20)) detail
6036             ,extraround
6037       FROM  igs_uc_ivstarc_2003_v
6038       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6039 
6040       -- get the max timestamp value of the hercules view
6041       CURSOR c_max_timestamp IS
6042       SELECT MAX(timestamp)
6043       FROM igs_uc_ivstarc_2003_v  ;
6044 
6045       -- Variables
6046       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6047       l_new_max_timestamp igs_uc_ivstarc_2003_v.timestamp%TYPE ;
6048       l_count NUMBER ;
6049 
6050       l_appno      igs_uc_istarc_ints.appno%TYPE;
6051       l_checkdigit NUMBER;
6052 
6053   BEGIN
6054        -- set syncronization required to false
6055        g_sync_reqd := FALSE;
6056        l_count := 0 ;
6057 
6058       -- log message that this view is being loaded
6059        log_start('IVSTARC ON ') ;
6060 
6061       -- Get the old timestamp for this view in the configured cycle
6062       Herc_timestamp_exists('IVSTARC', p_old_timestamp) ;
6063 
6064        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6065        FOR c_ivstarc_rec IN c_ivstarc(p_old_timestamp) LOOP
6066               -- set x_sync_read to true if the loop is entered even once
6067               g_sync_reqd := TRUE;
6068 
6069               IF  is_valid(c_ivstarc_rec.appno,'IVSTARC','APPNO','NUMBER') THEN
6070 
6071                   -- Determine actual appno
6072                   get_appno(c_ivstarc_rec.appno, NULL, l_appno, l_checkdigit);
6073 
6074                   -- Obsolete matching records in interface table with status N
6075                   UPDATE igs_uc_istarc_ints SET record_status = 'O'
6076                   WHERE record_status = 'N' AND  appno = l_appno
6077                   AND choiceno = c_ivstarc_rec.choiceno AND ucas_cycle = g_cyc_info_rec.configured_cycle ;
6078 
6079 
6080                   -- copy hercules record into interface table with record status N
6081                   INSERT INTO igs_uc_istarc_ints (  appno,
6082                                                     choiceno,
6083                                                     lastchange,
6084                                                     inst,
6085                                                     course,
6086                                                     campus,
6087                                                     faculty,
6088                                                     home,
6089                                                     decision,
6090                                                     decisiondate,
6091                                                     decisionnumber,
6092                                                     reply,
6093                                                     summaryconditions,
6094                                                     entrymonth,
6095                                                     entryyear,
6096                                                     entrypoint,
6097                                                     choicecancelled,
6098                                                     action,
6099                                                     substitution,
6100                                                     datesubstituted,
6101                                                     previousinst,
6102                                                     previouscourse,
6103                                                     previouscampus,
6104                                                     ucasamendment,
6105                                                     routebpref,
6106                                                     routebround,
6107                                                     detail,
6108                                                     extraround,
6109                                                     residential,
6110                                                     record_status,
6111                                                     error_code,
6112                                                     ucas_cycle
6113                                                      )
6114                                          VALUES (   l_appno,
6115                                                     c_ivstarc_rec.choiceno,
6116                                                     c_ivstarc_rec.lastchange,
6117                                                     c_ivstarc_rec.inst,
6118                                                     c_ivstarc_rec.course,
6119                                                     c_ivstarc_rec.campus,
6120                                                     c_ivstarc_rec.faculty,
6121                                                     c_ivstarc_rec.home,
6122                                                     c_ivstarc_rec.decision,
6123                                                     c_ivstarc_rec.decisiondate,
6124                                                     c_ivstarc_rec.decisionnumber,
6125                                                     c_ivstarc_rec.reply,
6126                                                     c_ivstarc_rec.summaryconditions,
6127                                                     c_ivstarc_rec.entrymonth,
6128                                                     c_ivstarc_rec.entryyear,
6129                                                     c_ivstarc_rec.entrypoint,
6130                                                     c_ivstarc_rec.choicecancelled,
6131                                                     c_ivstarc_rec.action,
6132                                                     c_ivstarc_rec.substitution,
6133                                                     c_ivstarc_rec.datesubstituted,
6134                                                     c_ivstarc_rec.previousinst,
6135                                                     c_ivstarc_rec.previouscourse,
6136                                                     c_ivstarc_rec.previouscampus,
6137                                                     c_ivstarc_rec.ucasamendment,
6138                                                     c_ivstarc_rec.routebpref,
6139                                                     c_ivstarc_rec.routebround,
6140                                                     c_ivstarc_rec.detail,
6141                                                     c_ivstarc_rec.extraround,
6142                                                     NULL,
6143                                                     'N',
6144                                                     NULL ,
6145                                                     g_cyc_info_rec.configured_cycle
6146                                                      ) ;
6147                   -- increment count of records
6148                   l_count := l_count + 1;
6149 
6150               END IF;
6151 
6152        END LOOP ;
6153 
6154       IF g_sync_reqd THEN
6155               -- get the max timestamp of this hercules view
6156               OPEN c_max_timestamp ;
6157               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6158               CLOSE c_max_timestamp ;
6159 
6160                -- update /insert the timestamp record with new max timestamp
6161                ins_upd_timestamp ('IVSTARC',   l_new_max_timestamp) ;
6162 
6163               -- log message that this view has been loaded
6164                log_complete('IVSTARC', l_count) ;
6165       ELSE
6166                 -- log message that this view is already in sync and need not be loaded
6167                log_already_insync('IVSTARC') ;
6168       END IF ;
6169       COMMIT;
6170 
6171   EXCEPTION
6172       WHEN OTHERS THEN
6173                ROLLBACK;
6174                write_to_log(SQLERRM);
6175                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6176                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARC_2003');
6177                igs_ge_msg_stack.add;
6178                app_exception.raise_exception ;
6179   END   load_ivstarc_2003  ;
6180 
6181 
6182   PROCEDURE load_ivnstarc_2006 IS
6183     /******************************************************************
6184      Created By      :   jbaber
6185      Date Created By :   12-Aug-03
6186      Purpose         :   loads each record in the hercules view ivnstarc into the interface table
6187                          igs_uc_istarc_ints with record status N
6188      Known limitations,enhancements,remarks:
6189      Change History
6190      Who       When         What
6191      jbaber    29-Sep-05    Replace inst, course and campus values with '*' if NULL
6192                             and force 2-digit entry year for bug 4638126
6193      anwest    02-AUG-06    Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6194     ***************************************************************** */
6195 
6196      -- Get all the records from odbc-link view whose timestamp is > passed timestamp
6197       -- or get all the records in odbc-link view if the timestamp passed is null
6198       CURSOR c_ivnstarc ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6199       SELECT appno
6200             ,NVL(choiceno,9) choiceno -- 02-AUG-2006 anwest Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6201             ,timestamp
6202             ,NVL(lastchange,SYSDATE) lastchange
6203             ,NVL(DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)),'*') inst
6204             ,NVL(DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)),'*') course
6205             ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
6206             ,RTRIM(residential) residential
6207             ,RTRIM(decision) decision
6208             ,decisiondate
6209             ,decisionnumber
6210             ,RTRIM(reply) reply
6211             ,entrymonth
6212             ,SUBSTR(LPAD(entryyear,4,0),3,2) entryyear
6213             ,RTRIM(choicecancelled) choicecancelled
6214             ,RTRIM(action) action
6215             ,RTRIM(substitution) substitution
6216             ,datesubstituted
6217             ,DECODE(RTRIM(previousinst),NULL, RPAD('*',LENGTH(previousinst),'*'), RTRIM(previousinst)) previousinst
6218             ,DECODE(RTRIM(previouscourse),NULL, RPAD('*',LENGTH(previouscourse),'*'), RTRIM(previouscourse)) previouscourse
6219             ,DECODE(RTRIM(previouscampus),NULL, RPAD('*',LENGTH(previouscampus),'*'), RTRIM(previouscampus)) previouscampus
6220       FROM  igs_uc_ivnstarc_2006_v
6221       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6222 
6223       -- get the max timestamp value of the hercules view
6224       CURSOR c_max_timestamp IS
6225       SELECT MAX(timestamp)
6226       FROM igs_uc_ivnstarc_2006_v  ;
6227 
6228       -- Variables
6229       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6230       l_new_max_timestamp igs_uc_ivnstarc_2006_v.timestamp%TYPE ;
6231       l_count NUMBER ;
6232 
6233       l_appno      igs_uc_istarc_ints.appno%TYPE;
6234       l_checkdigit NUMBER;
6235 
6236   BEGIN
6237        -- set syncronization required to false
6238        g_sync_reqd := FALSE;
6239        l_count := 0 ;
6240 
6241       -- log message that this view is being loaded
6242        log_start('IVNSTARC ON ') ;
6243 
6244       -- Get the old timestamp for this view in the configured cycle
6245       Herc_timestamp_exists('IVNSTARC', p_old_timestamp) ;
6246 
6247        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6248        FOR c_ivnstarc_rec IN c_ivnstarc(p_old_timestamp) LOOP
6249               -- set x_sync_read to true if the loop is entered even once
6250               g_sync_reqd := TRUE;
6251 
6252               IF  is_valid(c_ivnstarc_rec.appno,'IVNSTARC','APPNO','NUMBER') THEN
6253 
6254                   -- Determine actual appno
6255                   get_appno(c_ivnstarc_rec.appno, NULL, l_appno, l_checkdigit);
6256 
6257                   -- Obsolete matching records in interface table with status N
6258                   UPDATE igs_uc_istarc_ints SET record_status = 'O'
6259                   WHERE record_status = 'N' AND  appno = l_appno
6260                   AND choiceno = c_ivnstarc_rec.choiceno AND ucas_cycle = g_cyc_info_rec.configured_cycle ;
6261 
6262 
6263                   -- copy hercules record into interface table with record status N
6264                   INSERT INTO igs_uc_istarc_ints (  appno,
6265                                                     choiceno,
6266                                                     lastchange,
6267                                                     inst,
6268                                                     course,
6269                                                     campus,
6270                                                     residential,
6271                                                     decision,
6272                                                     decisiondate,
6273                                                     decisionnumber,
6274                                                     reply,
6275                                                     entrymonth,
6276                                                     entryyear,
6277                                                     choicecancelled,
6278                                                     action,
6279                                                     substitution,
6280                                                     datesubstituted,
6281                                                     previousinst,
6282                                                     previouscourse,
6283                                                     previouscampus,
6284                                                     record_status,
6285                                                     error_code,
6286                                                     ucas_cycle
6287                                                      )
6288                                          VALUES (   l_appno,
6289                                                     c_ivnstarc_rec.choiceno,
6290                                                     c_ivnstarc_rec.lastchange,
6291                                                     c_ivnstarc_rec.inst,
6292                                                     c_ivnstarc_rec.course,
6293                                                     c_ivnstarc_rec.campus,
6294                                                     c_ivnstarc_rec.residential,
6295                                                     c_ivnstarc_rec.decision,
6296                                                     c_ivnstarc_rec.decisiondate,
6297                                                     c_ivnstarc_rec.decisionnumber,
6298                                                     c_ivnstarc_rec.reply,
6299                                                     c_ivnstarc_rec.entrymonth,
6300                                                     c_ivnstarc_rec.entryyear,
6301                                                     c_ivnstarc_rec.choicecancelled,
6302                                                     c_ivnstarc_rec.action,
6303                                                     c_ivnstarc_rec.substitution,
6304                                                     c_ivnstarc_rec.datesubstituted,
6305                                                     c_ivnstarc_rec.previousinst,
6306                                                     c_ivnstarc_rec.previouscourse,
6307                                                     c_ivnstarc_rec.previouscampus,
6308                                                     'N',
6309                                                     NULL ,
6310                                                     g_cyc_info_rec.configured_cycle
6311                                                  ) ;
6312                   -- increment count of records
6313                   l_count := l_count + 1;
6314 
6315               END IF;
6316 
6317        END LOOP ;
6318 
6319       IF g_sync_reqd THEN
6320               -- get the max timestamp of this hercules view
6321               OPEN c_max_timestamp ;
6322               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6323               CLOSE c_max_timestamp ;
6324 
6325                -- update /insert the timestamp record with new max timestamp
6326                ins_upd_timestamp ('IVNSTARC',   l_new_max_timestamp) ;
6327 
6328               -- log message that this view has been loaded
6329                log_complete('IVNSTARC', l_count) ;
6330       ELSE
6331                 -- log message that this view is already in sync and need not be loaded
6332                log_already_insync('IVNSTARC') ;
6333       END IF ;
6334       COMMIT;
6335 
6336   EXCEPTION
6337       WHEN OTHERS THEN
6338                ROLLBACK;
6339                write_to_log(SQLERRM);
6340                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6341                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARC_2006');
6342                igs_ge_msg_stack.add;
6343                app_exception.raise_exception ;
6344   END   load_ivnstarc_2006  ;
6345 
6346 
6347   PROCEDURE load_ivgstarg_2006 IS
6348     /******************************************************************
6349      Created By      :   jbaber
6350      Date Created By :   12-Aug-03
6351      Purpose         :   loads each record in the hercules view ivgstarg into the interface table
6352                          igs_uc_istarg_ints with record status N
6353      Known limitations,enhancements,remarks:
6354      Change History
6355      Who       When         What
6356      jbaber    29-Sep-05    Replace inst, course and campus values with '*' if NULL
6357                             and force 2-digit entry year for bug 4638126
6358      anwest    02-AUG-06    Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6359     ***************************************************************** */
6360 
6361     -- Get all the records from odbc-link view whose timestamp is > passed timestamp
6362       -- or get all the records in odbc-link view if the timestamp passed is null
6363       CURSOR c_ivgstarg ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6364       SELECT appno
6365             ,NVL(roundno,99) roundno -- 02-AUG-2006 anwest Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
6366             ,timestamp
6367             ,NVL(lastchange,SYSDATE) lastchange
6368             ,NVL(DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)),'*') inst
6369             ,NVL(DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)),'*') course
6370             ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus
6371             ,RTRIM(modular) modular
6372             ,RTRIM(parttime) parttime
6373             ,RTRIM(decision) decision
6374             ,RTRIM(reply) reply
6375             ,entrymonth
6376             ,SUBSTR(LPAD(entryyear,4,0),3,2) entryyear
6377             ,RTRIM(action) action
6378             ,RTRIM(english) english
6379             ,RTRIM(maths) maths
6380             ,RTRIM(science) science
6381             ,RTRIM(degreestatus) degreestatus
6382             ,RTRIM(degreesubject) degreesubject
6383             ,RTRIM(degreeclass) degreeclass
6384             ,interviewdate
6385             ,RTRIM(lateapplication) lateapplication
6386       FROM  igs_uc_ivgstarg_2006_v
6387       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6388 
6389       -- get the max timestamp value of the hercules view
6390       CURSOR c_max_timestamp IS
6391       SELECT MAX(timestamp)
6392       FROM igs_uc_ivgstarg_2006_v  ;
6393 
6394       -- Variables
6395       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6396       l_new_max_timestamp igs_uc_ivgstarg_2006_v.timestamp%TYPE ;
6397       l_count NUMBER ;
6398 
6399       l_appno      igs_uc_istarc_ints.appno%TYPE;
6400       l_checkdigit NUMBER;
6401 
6402   BEGIN
6403        -- set syncronization required to false
6404        g_sync_reqd := FALSE;
6405        l_count := 0 ;
6406 
6407       -- log message that this view is being loaded
6408        log_start('IVGSTARG ON ') ;
6409 
6410       -- Get the old timestamp for this view in the configured cycle
6411       Herc_timestamp_exists('IVGSTARG', p_old_timestamp) ;
6412 
6413        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6414        FOR c_ivgstarg_rec IN c_ivgstarg(p_old_timestamp) LOOP
6415               -- set x_sync_read to true if the loop is entered even once
6416               g_sync_reqd := TRUE;
6417 
6418               IF  is_valid(c_ivgstarg_rec.appno,'IVGSTARG','APPNO','NUMBER') THEN
6419 
6420                   -- Determine actual appno
6421                   get_appno(c_ivgstarg_rec.appno, NULL, l_appno, l_checkdigit);
6422 
6423                   -- Obsolete matching records in interface table with status N
6424                   UPDATE igs_uc_istarg_ints SET record_status = 'O'
6425                   WHERE record_status = 'N' AND  appno = l_appno
6426                   AND roundno = c_ivgstarg_rec.roundno AND ucas_cycle = g_cyc_info_rec.configured_cycle ;
6427 
6428 
6429 
6430                   -- copy hercules record into interface table with record status N
6431                   INSERT INTO igs_uc_istarg_ints (  appno,
6432                                                     roundno,
6433                                                     lastchange,
6434                                                     inst,
6435                                                     course,
6436                                                     campus,
6437                                                     modular,
6438                                                     parttime,
6439                                                     decision,
6440                                                     reply,
6441                                                     entrymonth,
6442                                                     entryyear,
6443                                                     action,
6444                                                     gcseeng,
6445                                                     gcsemath,
6446                                                     gcsesci,
6447                                                     degreestatus,
6448                                                     degreesubject,
6449                                                     degreeclass,
6450                                                     interview,
6451                                                     lateapplication,
6452                                                     record_status,
6453                                                     error_code,
6454                                                     ucas_cycle
6455                                                      )
6456                                          VALUES (   l_appno,
6457                                                     c_ivgstarg_rec.roundno,
6458                                                     c_ivgstarg_rec.lastchange,
6459                                                     c_ivgstarg_rec.inst,
6460                                                     c_ivgstarg_rec.course,
6461                                                     c_ivgstarg_rec.campus,
6462                                                     c_ivgstarg_rec.modular,
6463                                                     c_ivgstarg_rec.parttime,
6464                                                     c_ivgstarg_rec.decision,
6465                                                     c_ivgstarg_rec.reply,
6466                                                     c_ivgstarg_rec.entrymonth,
6467                                                     c_ivgstarg_rec.entryyear,
6468                                                     c_ivgstarg_rec.action,
6469                                                     c_ivgstarg_rec.english,
6470                                                     c_ivgstarg_rec.maths,
6471                                                     c_ivgstarg_rec.science,
6472                                                     c_ivgstarg_rec.degreestatus,
6473                                                     c_ivgstarg_rec.degreesubject,
6474                                                     c_ivgstarg_rec.degreeclass,
6475                                                     c_ivgstarg_rec.interviewdate,
6476                                                     c_ivgstarg_rec.lateapplication,
6477                                                     'N',
6478                                                     NULL ,
6479                                                     g_cyc_info_rec.configured_cycle
6480                                                  ) ;
6481                   -- increment count of records
6482                   l_count := l_count + 1;
6483 
6484               END IF;
6485 
6486        END LOOP ;
6487 
6488       IF g_sync_reqd THEN
6489               -- get the max timestamp of this hercules view
6490               OPEN c_max_timestamp ;
6491               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6492               CLOSE c_max_timestamp ;
6493 
6494                -- update /insert the timestamp record with new max timestamp
6495                ins_upd_timestamp ('IVGSTARG',   l_new_max_timestamp) ;
6496 
6497               -- log message that this view has been loaded
6498                log_complete('IVGSTARG', l_count) ;
6499       ELSE
6500                 -- log message that this view is already in sync and need not be loaded
6501                log_already_insync('IVGSTARG') ;
6502       END IF ;
6503       COMMIT;
6504 
6505   EXCEPTION
6506       WHEN OTHERS THEN
6507                ROLLBACK;
6508                write_to_log(SQLERRM);
6509                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6510                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARG_2006');
6511                igs_ge_msg_stack.add;
6512                app_exception.raise_exception ;
6513   END   load_ivgstarg_2006  ;
6514 
6515 
6516   PROCEDURE load_ivstarh_2003 IS
6517     /******************************************************************
6518      Created By      :  smaddali
6519      Date Created By :   11-Jun-03
6520      Purpose         :     loads each record in the hercules view ivstarh into the interface table
6521                            igs_uc_istarh_ints with record status N
6522      Known limitations,enhancements,remarks:
6523      Change History
6524      Who       When         What
6525      jbaber    15-Sep-05    Load NULL for lasteducation and educationleavedate for bug 4589994
6526     ***************************************************************** */
6527 
6528      -- Get all the records from hercules  view whose timestamp is > passed timestamp
6529       -- or get all the records in hercules view if the timestamp passed is null
6530       CURSOR c_ivstarh ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6531       SELECT appno
6532            ,timestamp
6533            ,ethnic
6534            ,RTRIM(socialclass) socialclass
6535            ,pocceduchangedate
6536            ,RTRIM(pocc) pocc
6537            ,RTRIM(pocctext) pocctext
6538            ,NULL lasteducation
6539            ,NULL educationleavedate
6540            ,NULL lea    -- not used in hercules
6541            ,socialeconomic
6542       FROM  igs_uc_ivstarh_2003_v
6543       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6544 
6545       -- get the max timestamp value of the hercules view
6546       CURSOR c_max_timestamp IS
6547       SELECT MAX(timestamp)
6548       FROM igs_uc_ivstarh_2003_v  ;
6549 
6550       -- Variables
6551       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6552       l_new_max_timestamp igs_uc_ivstarh_2003_v.timestamp%TYPE ;
6553       l_count NUMBER ;
6554 
6555       l_appno      igs_uc_istarh_ints.appno%TYPE;
6556       l_checkdigit NUMBER;
6557 
6558   BEGIN
6559        -- set syncronization required to false
6560        g_sync_reqd := FALSE;
6561        l_count := 0 ;
6562 
6563       -- log message that this view is being loaded
6564        log_start('IVSTARH ON ') ;
6565 
6566       -- Get the old timestamp for this view in the configured cycle
6567       Herc_timestamp_exists('IVSTARH', p_old_timestamp) ;
6568 
6569        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6570        FOR c_ivstarh_rec IN c_ivstarh(p_old_timestamp) LOOP
6571               -- set x_sync_read to true if the loop is entered even once
6572               g_sync_reqd := TRUE;
6573 
6574               --Validate varchar to number conversion
6575               IF  is_valid(c_ivstarh_rec.appno,'IVSTARH','APPNO','NUMBER') AND
6576                   is_valid(c_ivstarh_rec.ethnic,'IVSTARH','Ethnic','NUMBER')THEN
6577 
6578                   -- Determine actual appno
6579                   get_appno(c_ivstarh_rec.appno, NULL, l_appno, l_checkdigit);
6580 
6581                   -- Obsolete matching records in interface table with status N
6582                   UPDATE igs_uc_istarh_ints SET record_status = 'O'
6583                   WHERE record_status = 'N' AND  appno = l_appno ;
6584 
6585                   -- copy hercules record into interface table with record status N
6586                   INSERT INTO igs_uc_istarh_ints (   appno,
6587                                                      ethnic,
6588                                                      socialclass,
6589                                                      pocceduchangedate,
6590                                                      pocc,
6591                                                      pocctext,
6592                                                      lasteducation,
6593                                                      educationleavedate,
6594                                                      lea,
6595                                                      socialeconomic,
6596                                                      dependants,
6597                                                      married,
6598                                                      record_status,
6599                                                      error_code
6600                                                      )
6601                                          VALUES (    l_appno,
6602                                                      c_ivstarh_rec.ethnic,
6603                                                      c_ivstarh_rec.socialclass,
6604                                                      c_ivstarh_rec.pocceduchangedate,
6605                                                      c_ivstarh_rec.pocc,
6606                                                      c_ivstarh_rec.pocctext,
6607                                                      c_ivstarh_rec.lasteducation,
6608                                                      c_ivstarh_rec.educationleavedate,
6609                                                      c_ivstarh_rec.lea,
6610                                                      c_ivstarh_rec.socialeconomic,
6611                                                      NULL ,
6612                                                      NULL ,
6613                                                      'N',
6614                                                      NULL
6615                                                      ) ;
6616                   -- increment count of records
6617                   l_count := l_count + 1;
6618 
6619               END IF;
6620 
6621        END LOOP ;
6622 
6623        IF g_sync_reqd THEN
6624               -- get the max timestamp of this hercules view
6625               OPEN c_max_timestamp ;
6626               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6627               CLOSE c_max_timestamp ;
6628 
6629                -- update /insert the timestamp record with new max timestamp
6630                ins_upd_timestamp ('IVSTARH', l_new_max_timestamp) ;
6631 
6632               -- log message that this view has been loaded
6633                log_complete('IVSTARH', l_count) ;
6634        ELSE
6635                 -- log message that this view is already in sync and need not be loaded
6636                log_already_insync('IVSTARH') ;
6637        END IF;
6638        COMMIT;
6639 
6640   EXCEPTION
6641       WHEN OTHERS THEN
6642                ROLLBACK;
6643                write_to_log(SQLERRM);
6644                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6645                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARH_2003');
6646                igs_ge_msg_stack.add;
6647                app_exception.raise_exception ;
6648   END  load_ivstarh_2003   ;
6649 
6650 
6651   PROCEDURE load_ivgstarh_2006 IS
6652     /******************************************************************
6653      Created By      :  jbaber
6654      Date Created By :   15-Aug-05
6655      Purpose         :     loads each record in the hercules view ivgstarh into the interface table
6656                            igs_uc_istarh_ints with record status N
6657      Known limitations,enhancements,remarks:
6658      Change History
6659      Who       When         What
6660     ***************************************************************** */
6661 
6662      -- Get all the records from hercules  view whose timestamp is > passed timestamp
6663       -- or get all the records in hercules view if the timestamp passed is null
6664       CURSOR c_ivgstarh ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6665       SELECT appno
6666            ,timestamp
6667            ,RTRIM(ethnic) ethnic
6668       FROM  igs_uc_ivgstarh_2006_v
6669       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6670 
6671       -- get the max timestamp value of the hercules view
6672       CURSOR c_max_timestamp IS
6673       SELECT MAX(timestamp)
6674       FROM igs_uc_ivgstarh_2006_v  ;
6675 
6676       -- Variables
6677       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6678       l_new_max_timestamp igs_uc_ivgstarh_2006_v.timestamp%TYPE ;
6679       l_count NUMBER ;
6680 
6681       l_appno      igs_uc_istarh_ints.appno%TYPE;
6682       l_checkdigit NUMBER;
6683 
6684   BEGIN
6685        -- set syncronization required to false
6686        g_sync_reqd := FALSE;
6687        l_count := 0 ;
6688 
6689       -- log message that this view is being loaded
6690        log_start('IVGSTARH ON ') ;
6691 
6692       -- Get the old timestamp for this view in the configured cycle
6693       Herc_timestamp_exists('IVGSTARH', p_old_timestamp) ;
6694 
6695        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6696        FOR c_ivgstarh_rec IN c_ivgstarh(p_old_timestamp) LOOP
6697               -- set x_sync_read to true if the loop is entered even once
6698               g_sync_reqd := TRUE;
6699 
6700               --Validate varchar to number conversion
6701               IF  is_valid(c_ivgstarh_rec.appno,'IVGSTARH','APPNO','NUMBER') AND
6702                   is_valid(c_ivgstarh_rec.ethnic,'IVGSTARH','Ethnic','NUMBER')THEN
6703 
6704                   -- Determine actual appno
6705                   get_appno(c_ivgstarh_rec.appno, NULL, l_appno, l_checkdigit);
6706 
6707                   -- Obsolete matching records in interface table with status N
6708                   UPDATE igs_uc_istarh_ints SET record_status = 'O'
6709                   WHERE record_status = 'N' AND  appno = l_appno ;
6710 
6711                   -- copy hercules record into interface table with record status N
6712                   INSERT INTO igs_uc_istarh_ints (   appno,
6713                                                      ethnic,
6714                                                      record_status,
6715                                                      error_code
6716                                                      )
6717                                          VALUES (    l_appno,
6718                                                      c_ivgstarh_rec.ethnic,
6722                   -- increment count of records
6719                                                      'N',
6720                                                      NULL
6721                                                      ) ;
6723                   l_count := l_count + 1;
6724 
6725               END IF;
6726 
6727        END LOOP ;
6728 
6729        IF g_sync_reqd THEN
6730               -- get the max timestamp of this hercules view
6731               OPEN c_max_timestamp ;
6732               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6733               CLOSE c_max_timestamp ;
6734 
6735                -- update /insert the timestamp record with new max timestamp
6736                ins_upd_timestamp ('IVGSTARH', l_new_max_timestamp) ;
6737 
6738               -- log message that this view has been loaded
6739                log_complete('IVGSTARH', l_count) ;
6740        ELSE
6741                 -- log message that this view is already in sync and need not be loaded
6742                log_already_insync('IVGSTARH') ;
6743        END IF;
6744        COMMIT;
6745 
6746   EXCEPTION
6747       WHEN OTHERS THEN
6748                ROLLBACK;
6749                write_to_log(SQLERRM);
6750                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6751                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARH_2006');
6752                igs_ge_msg_stack.add;
6753                app_exception.raise_exception ;
6754   END  load_ivgstarh_2006   ;
6755 
6756 
6757   PROCEDURE load_ivnstarh_2006 IS
6758     /******************************************************************
6759      Created By      :   jbaber
6760      Date Created By :   15-Aug-05
6761      Purpose         :   loads each record in the hercules view ivnstarh into the interface table
6762                           with record status N
6763      Known limitations,enhancements,remarks:
6764      Change History
6765      Who       When         What
6766     ***************************************************************** */
6767 
6768      -- Get all the records from hercules  view whose timestamp is > passed timestamp
6769       -- or get all the records in hercules view if the timestamp passed is null
6770       CURSOR c_ivnstarh ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6771       SELECT appno
6772            ,timestamp
6773            ,RTRIM(ethnic) ethnic
6774            ,numberdependants
6775            ,RTRIM(maritalstatus) maritalstatus
6776       FROM  igs_uc_ivnstarh_2006_v
6777       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6778 
6779       -- get the max timestamp value of the hercules view
6780       CURSOR c_max_timestamp IS
6781       SELECT MAX(timestamp)
6782       FROM igs_uc_ivnstarh_2006_v  ;
6783 
6784       -- Variables
6785       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6786       l_new_max_timestamp igs_uc_ivnstarh_2006_v.timestamp%TYPE ;
6787       l_count NUMBER ;
6788 
6789       l_appno      igs_uc_istarh_ints.appno%TYPE;
6790       l_checkdigit NUMBER;
6791 
6792   BEGIN
6793        -- set syncronization required to false
6794        g_sync_reqd := FALSE;
6795        l_count := 0 ;
6796 
6797       -- log message that this view is being loaded
6798        log_start('IVNSTARH ON ') ;
6799 
6800       -- Get the old timestamp for this view in the configured cycle
6801       Herc_timestamp_exists('IVNSTARH', p_old_timestamp) ;
6802 
6803        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6804        FOR c_ivnstarh_rec IN c_ivnstarh(p_old_timestamp) LOOP
6805               -- set x_sync_read to true if the loop is entered even once
6806               g_sync_reqd := TRUE;
6807 
6808               --Validate varchar to number conversion
6809               IF  is_valid(c_ivnstarh_rec.appno,'IVNSTARH','APPNO','NUMBER') AND
6810                   is_valid(c_ivnstarh_rec.ethnic,'IVNSTARH','Ethnic','NUMBER')THEN
6811 
6812                   -- Determine actual appno
6813                   get_appno(c_ivnstarh_rec.appno, NULL, l_appno, l_checkdigit);
6814 
6815                   -- Obsolete matching records in interface table with status N
6816                   UPDATE igs_uc_istarh_ints SET record_status = 'O'
6817                   WHERE record_status = 'N' AND  appno = l_appno ;
6818 
6819                   -- copy hercules record into interface table with record status N
6820                   INSERT INTO igs_uc_istarh_ints (   appno,
6821                                                      ethnic,
6822                                                      dependants,
6823                                                      married,
6824                                                      record_status,
6825                                                      error_code
6826                                                      )
6827                                          VALUES (    l_appno,
6828                                                      c_ivnstarh_rec.ethnic,
6829                                                      c_ivnstarh_rec.numberdependants,
6830                                                      c_ivnstarh_rec.maritalstatus,
6831                                                      'N',
6832                                                      NULL
6833                                                      ) ;
6834                   -- increment count of records
6835                   l_count := l_count + 1;
6836 
6837               END IF;
6838 
6839        END LOOP ;
6840 
6841        IF g_sync_reqd THEN
6842               -- get the max timestamp of this hercules view
6843               OPEN c_max_timestamp ;
6844               FETCH c_max_timestamp INTO l_new_max_timestamp ;
6845               CLOSE c_max_timestamp ;
6846 
6847                -- update /insert the timestamp record with new max timestamp
6848                ins_upd_timestamp ('IVNSTARH', l_new_max_timestamp) ;
6849 
6850               -- log message that this view has been loaded
6851                log_complete('IVNSTARH', l_count) ;
6852        ELSE
6853                 -- log message that this view is already in sync and need not be loaded
6854                log_already_insync('IVNSTARH') ;
6855        END IF;
6856        COMMIT;
6857 
6858   EXCEPTION
6859       WHEN OTHERS THEN
6860                ROLLBACK;
6861                write_to_log(SQLERRM);
6862                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
6863                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARH_2006');
6864                igs_ge_msg_stack.add;
6865                app_exception.raise_exception ;
6866   END  load_ivnstarh_2006   ;
6867 
6868 
6869   PROCEDURE load_ivstark_2003 IS
6870     /******************************************************************
6871      Created By      :  smaddali
6872      Date Created By :   11-Jun-03
6873      Purpose         :     loads each record in the hercules view ivstark into the interface table
6874                            igs_uc_istark_ints with record status N
6875      Known limitations,enhancements,remarks:
6876      Change History
6877      Who       When         What
6878      smaddali  7-aug-03   Modified value for field EAS for bug#3087852
6879     ***************************************************************** */
6880 
6881      -- Get all the records from hercules  view whose timestamp is > passed timestamp
6882       -- or get all the records in hercules view if the timestamp passed is null
6883       -- converting EAS field ,for bug#3087852
6884       CURSOR c_ivstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
6885       SELECT appno
6886              ,timestamp
6887              ,applicationdate
6888              ,sentdate
6889              ,runsent
6890              ,codedchangedate
6891              ,school
6892              ,RTRIM(rescat) rescat
6893              ,feelevel
6894              ,feepayer
6895              ,RTRIM(feetext) feetext
6896              ,apr
6897              ,NULL lea    -- not used in hercules
6898              ,countrybirth
6899              ,nationality
6900              ,dualnationality
6901              ,RTRIM(withdrawn) withdrawn
6902              ,withdrawndate
6903              ,RTRIM(routeb) routeb
6904              ,examchangedate
6905              ,NULL alevels   -- not used in hercules
6906              ,NULL aslevels  -- not used in hercules
6907              ,NULL highers   -- not used in hercules
6908              ,NULL csys      -- not used in hercules
6909              ,winter
6910              ,previousa
6911              ,RTRIM(btec) btec
6912              ,RTRIM(ilc) ilc
6913              ,RTRIM(aice) aice
6914              ,RTRIM(ib) ib
6915              ,RTRIM(manual) manual
6916              ,RTRIM(regno) regno
6917              ,RTRIM(oeq) oeq
6918              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
6919              ,RTRIM(roa) roa
6920              ,specialneeds
6921              ,RTRIM(status) status
6922              ,firmnow
6923              ,firmreply
6924              ,insurancereply
6925              ,confhistfirmreply
6926              ,confhistinsurancereply
6927              ,gce
6928              ,vce
6929              ,RTRIM(sqa) sqa
6930              ,previousas
6931              ,RTRIM(keyskills) keyskills
6932              ,RTRIM(vocational) vocational
6933              ,NULL gnvq      -- not used in hercules
6934              ,RTRIM(scn) scn
6935              ,RTRIM(prevoeq) prevoeq
6936              ,ukentrydate
6937              ,RTRIM(criminalconv) criminalconv
6938              ,RTRIM(choicesalltransparent) choicesalltransparent
6939              ,extrastatus
6940              ,RTRIM(extrapassportno) extrapassportno
6941       FROM  igs_uc_ivstark_2003_v
6942       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
6943 
6944       -- get the max timestamp value of the hercules view
6945       CURSOR c_max_timestamp IS
6946       SELECT MAX(timestamp)
6947       FROM igs_uc_ivstark_2003_v  ;
6948 
6949       -- Variables
6950       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
6951       l_new_max_timestamp igs_uc_ivstark_2003_v.timestamp%TYPE ;
6952       l_count NUMBER ;
6953 
6954       l_appno      igs_uc_istark_ints.appno%TYPE;
6955       l_checkdigit NUMBER;
6956 
6957   BEGIN
6958        -- set syncronization required to false
6959        g_sync_reqd := FALSE;
6960        l_count := 0 ;
6961 
6962       -- log message that this view is being loaded
6963        log_start('IVSTARK ON ') ;
6964 
6965       -- Get the old timestamp for this view in the configured cycle
6966       Herc_timestamp_exists('IVSTARK', p_old_timestamp) ;
6967 
6968        -- create interface records for each record in the hercules view whose timestamp > old timestamp
6969        FOR c_ivstark_rec IN c_ivstark(p_old_timestamp) LOOP
6970               -- set x_sync_read to true if the loop is entered even once
6971               g_sync_reqd := TRUE;
6972 
6973               --Validate varchar to number conversion
6974               IF  is_valid(c_ivstark_rec.appno,'IVSTARK','APPNO','NUMBER') AND
6975                   is_valid(c_ivstark_rec.runsent,'IVSTARK','RunSent','NUMBER') AND
6976                   is_valid(c_ivstark_rec.school,'IVSTARK','School','NUMBER') AND
6977                   is_valid(c_ivstark_rec.feepayer,'IVSTARK','FeePayer','NUMBER') AND
6978                   is_valid(c_ivstark_rec.apr,'IVSTARK','APR','NUMBER') AND
6979                   is_valid(c_ivstark_rec.countrybirth,'IVSTARK','CountryBirth','NUMBER') AND
6980                   is_valid(c_ivstark_rec.nationality,'IVSTARK','Nationality','NUMBER') AND
6981                   is_valid(c_ivstark_rec.dualnationality,'IVSTARK','DualNationality','NUMBER') AND
6982                   is_valid(c_ivstark_rec.extrastatus,'IVSTARK','ExtraStatus','NUMBER') THEN
6983 
6984                   -- Determine actual appno
6985                   get_appno(c_ivstark_rec.appno, NULL, l_appno, l_checkdigit);
6986 
6987                   -- Obsolete matching records in interface table with status N
6988                   UPDATE igs_uc_istark_ints SET record_status = 'O'
6989                   WHERE record_status = 'N' AND  appno = l_appno   ;
6990 
6991 
6992                   -- copy hercules record into interface table with record status N
6993                   INSERT INTO igs_uc_istark_ints (   appno,
6994                                                      applicationdate,
6995                                                      sentdate,
6996                                                      runsent,
6997                                                      codedchangedate,
6998                                                      school,
6999                                                      rescat,
7000                                                      feelevel,
7001                                                      feepayer,
7002                                                      feetext,
7003                                                      apr,
7004                                                      lea,
7005                                                      countrybirth,
7006                                                      nationality,
7007                                                      dualnationality,
7008                                                      withdrawn,
7009                                                      withdrawndate,
7010                                                      routeb,
7011                                                      examchangedate,
7012                                                      alevels,
7013                                                      aslevels,
7014                                                      highers,
7015                                                      csys,
7016                                                      gce,
7017                                                      vce,
7018                                                      sqa,
7019                                                      winter,
7020                                                      previousa,
7021                                                      previousas,
7022                                                      keyskills,
7023                                                      vocational,
7024                                                      gnvq,
7025                                                      btec,
7026                                                      ilc,
7027                                                      aice,
7028                                                      ib,
7029                                                      manual,
7030                                                      regno,
7031                                                      scn,
7032                                                      oeq,
7033                                                      prevoeq,
7034                                                      eas,
7035                                                      roa,
7036                                                      specialneeds,
7037                                                      criminalconv,
7038                                                      ukentrydate,
7039                                                      status,
7040                                                      firmnow,
7041                                                      firmreply,
7042                                                      insurancereply,
7043                                                      confhistfirmreply,
7044                                                      confhistinsurancereply,
7045                                                      choicesalltransparent,
7046                                                      extrastatus,
7047                                                      extrapassportno,
7048                                                      welshspeaker,
7049                                                      ninumber,
7050                                                      earlieststart,
7051                                                      nearinst,
7052                                                      prefreg,
7053                                                      qualeng,
7054                                                      qualmath,
7055                                                      qualsci,
7056                                                      mainqual,
7057                                                      qual5,
7058                                                      record_status,
7059                                                      error_code
7060                                                      )
7061                                          VALUES (    l_appno,
7062                                                      c_ivstark_rec.applicationdate,
7063                                                      c_ivstark_rec.sentdate,
7064                                                      c_ivstark_rec.runsent,
7065                                                      c_ivstark_rec.codedchangedate,
7066                                                      c_ivstark_rec.school,
7067                                                      c_ivstark_rec.rescat,
7068                                                      c_ivstark_rec.feelevel,
7069                                                      c_ivstark_rec.feepayer,
7070                                                      c_ivstark_rec.feetext,
7071                                                      c_ivstark_rec.apr,
7072                                                      c_ivstark_rec.lea,
7073                                                      c_ivstark_rec.countrybirth,
7074                                                      c_ivstark_rec.nationality,
7075                                                      c_ivstark_rec.dualnationality,
7076                                                      c_ivstark_rec.withdrawn,
7077                                                      c_ivstark_rec.withdrawndate,
7078                                                      c_ivstark_rec.routeb,
7079                                                      c_ivstark_rec.examchangedate,
7080                                                      c_ivstark_rec.alevels,
7081                                                      c_ivstark_rec.aslevels,
7082                                                      c_ivstark_rec.highers,
7083                                                      c_ivstark_rec.csys,
7084                                                      c_ivstark_rec.gce,
7085                                                      c_ivstark_rec.vce,
7086                                                      c_ivstark_rec.sqa,
7087                                                      c_ivstark_rec.winter,
7088                                                      c_ivstark_rec.previousa,
7089                                                      c_ivstark_rec.previousas,
7090                                                      c_ivstark_rec.keyskills,
7091                                                      c_ivstark_rec.vocational,
7092                                                      c_ivstark_rec.gnvq,
7093                                                      c_ivstark_rec.btec,
7094                                                      c_ivstark_rec.ilc,
7095                                                      c_ivstark_rec.aice,
7096                                                      c_ivstark_rec.ib,
7097                                                      c_ivstark_rec.manual,
7098                                                      c_ivstark_rec.regno,
7099                                                      c_ivstark_rec.scn,
7100                                                      c_ivstark_rec.oeq,
7101                                                      c_ivstark_rec.prevoeq,
7102                                                      NVL(c_ivstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
7103                                                      c_ivstark_rec.roa,
7104                                                      c_ivstark_rec.specialneeds,
7105                                                      c_ivstark_rec.criminalconv,
7106                                                      c_ivstark_rec.ukentrydate,
7107                                                      c_ivstark_rec.status,
7108                                                      c_ivstark_rec.firmnow,
7109                                                      c_ivstark_rec.firmreply,
7110                                                      c_ivstark_rec.insurancereply,
7111                                                      c_ivstark_rec.confhistfirmreply,
7112                                                      c_ivstark_rec.confhistinsurancereply,
7113                                                      c_ivstark_rec.choicesalltransparent,
7114                                                      c_ivstark_rec.extrastatus,
7115                                                      c_ivstark_rec.extrapassportno,
7116                                                      NULL,
7117                                                      NULL,
7118                                                      NULL,
7119                                                      NULL,
7120                                                      NULL,
7121                                                      NULL,
7122                                                      NULL,
7123                                                      NULL,
7124                                                      NULL,
7125                                                      NULL,
7126                                                     'N',
7127                                                     NULL
7128                                                      ) ;
7129                   -- increment count of records
7130                   l_count := l_count + 1;
7131 
7132               END IF;
7133 
7134        END LOOP ;
7138               OPEN c_max_timestamp ;
7135 
7136       IF g_sync_reqd THEN
7137               -- get the max timestamp of this hercules view
7139               FETCH c_max_timestamp INTO l_new_max_timestamp ;
7140               CLOSE c_max_timestamp ;
7141 
7142                -- update /insert the timestamp record with new max timestamp
7143                ins_upd_timestamp ('IVSTARK',   l_new_max_timestamp) ;
7144 
7145               -- log message that this view has been loaded
7146                log_complete('IVSTARK', l_count) ;
7147       ELSE
7148                 -- log message that this view is already in sync and need not be loaded
7149                log_already_insync('IVSTARK') ;
7150       END IF ;
7151       COMMIT;
7152 
7153   EXCEPTION
7154       WHEN OTHERS THEN
7155                ROLLBACK;
7156                write_to_log(SQLERRM);
7157                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
7158                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARK_2003');
7159                igs_ge_msg_stack.add;
7160                app_exception.raise_exception ;
7161   END  load_ivstark_2003   ;
7162 
7163   PROCEDURE load_ivstark_2007 IS
7164     /******************************************************************
7165      Created By      :  smaddali
7166      Date Created By :   11-Jul-06
7167      Purpose         :     loads each record in the hercules view ivstark into the interface table
7168                            igs_uc_istark_ints with record status N
7169      Known limitations,enhancements,remarks:
7170      Change History
7171      Who       When         What
7172      smaddali  7-aug-03   Modified value for field EAS for bug#3087852
7173     ***************************************************************** */
7174 
7175      -- Get all the records from hercules  view whose timestamp is > passed timestamp
7176       -- or get all the records in hercules view if the timestamp passed is null
7177       -- converting EAS field ,for bug#3087852
7178       CURSOR c_ivstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
7179       SELECT appno
7180              ,timestamp
7181              ,applicationdate
7182              ,sentdate
7183              ,runsent
7184              ,codedchangedate
7185              ,school
7186              ,RTRIM(rescat) rescat
7187              ,feelevel
7188              ,feepayer
7189              ,RTRIM(feetext) feetext
7190              ,apr
7191              ,NULL lea    -- not used in hercules
7192              ,countrybirth
7193              ,nationality
7194              ,dualnationality
7195              ,RTRIM(withdrawn) withdrawn
7196              ,withdrawndate
7197              ,RTRIM(routeb) routeb
7198              ,examchangedate
7199              ,NULL alevels   -- not used in hercules
7200              ,NULL aslevels  -- not used in hercules
7201              ,NULL highers   -- not used in hercules
7202              ,NULL csys      -- not used in hercules
7203              ,winter
7204              ,previousa
7205              ,RTRIM(btec) btec
7206              ,RTRIM(ilc) ilc
7207              ,RTRIM(aice) aice
7208              ,RTRIM(ib) ib
7209              ,RTRIM(manual) manual
7210              ,RTRIM(regno) regno
7211              ,RTRIM(oeq) oeq
7212              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
7213              ,RTRIM(roa) roa
7214              ,disability
7215              ,RTRIM(status) status
7216              ,firmnow
7217              ,firmreply
7218              ,insurancereply
7219              ,confhistfirmreply
7220              ,confhistinsurancereply
7221              ,gce
7222              ,vce
7223              ,RTRIM(sqa) sqa
7224              ,previousas
7225              ,RTRIM(keyskills) keyskills
7226              ,RTRIM(vocational) vocational
7227              ,NULL gnvq      -- not used in hercules
7228              ,RTRIM(scn) scn
7229              ,RTRIM(prevoeq) prevoeq
7230              ,ukentrydate
7231              ,RTRIM(criminalconv) criminalconv
7232              ,RTRIM(choicesalltransparent) choicesalltransparent
7233              ,extrastatus
7234              ,RTRIM(extrapassportno) extrapassportno
7235       FROM  igs_uc_ivstark_2007_v
7236       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
7237 
7238       -- get the max timestamp value of the hercules view
7239       CURSOR c_max_timestamp IS
7240       SELECT MAX(timestamp)
7241       FROM igs_uc_ivstark_2007_v  ;
7242 
7243       -- Variables
7244       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
7245       l_new_max_timestamp igs_uc_ivstark_2007_v.timestamp%TYPE ;
7246       l_count NUMBER ;
7247 
7248       l_appno      igs_uc_istark_ints.appno%TYPE;
7249       l_checkdigit NUMBER;
7250 
7251   BEGIN
7252        -- set syncronization required to false
7253        g_sync_reqd := FALSE;
7254        l_count := 0 ;
7255 
7256       -- log message that this view is being loaded
7257        log_start('IVSTARK ON ') ;
7258 
7259       -- Get the old timestamp for this view in the configured cycle
7260       Herc_timestamp_exists('IVSTARK', p_old_timestamp) ;
7261 
7262        -- create interface records for each record in the hercules view whose timestamp > old timestamp
7263        FOR c_ivstark_rec IN c_ivstark(p_old_timestamp) LOOP
7264               -- set x_sync_read to true if the loop is entered even once
7265               g_sync_reqd := TRUE;
7266 
7267               --Validate varchar to number conversion
7268               IF  is_valid(c_ivstark_rec.appno,'IVSTARK','APPNO','NUMBER') AND
7269                   is_valid(c_ivstark_rec.runsent,'IVSTARK','RunSent','NUMBER') AND
7270                   is_valid(c_ivstark_rec.school,'IVSTARK','School','NUMBER') AND
7271                   is_valid(c_ivstark_rec.feepayer,'IVSTARK','FeePayer','NUMBER') AND
7272                   is_valid(c_ivstark_rec.apr,'IVSTARK','APR','NUMBER') AND
7273                   is_valid(c_ivstark_rec.countrybirth,'IVSTARK','CountryBirth','NUMBER') AND
7274                   is_valid(c_ivstark_rec.nationality,'IVSTARK','Nationality','NUMBER') AND
7275                   is_valid(c_ivstark_rec.dualnationality,'IVSTARK','DualNationality','NUMBER') AND
7276                   is_valid(c_ivstark_rec.extrastatus,'IVSTARK','ExtraStatus','NUMBER') THEN
7277 
7278                   -- Determine actual appno
7279                   get_appno(c_ivstark_rec.appno, NULL, l_appno, l_checkdigit);
7280 
7281                   -- Obsolete matching records in interface table with status N
7282                   UPDATE igs_uc_istark_ints SET record_status = 'O'
7283                   WHERE record_status = 'N' AND  appno = l_appno   ;
7284 
7285 
7286                   -- copy hercules record into interface table with record status N
7287                   INSERT INTO igs_uc_istark_ints (   appno,
7288                                                      applicationdate,
7289                                                      sentdate,
7290                                                      runsent,
7291                                                      codedchangedate,
7292                                                      school,
7293                                                      rescat,
7294                                                      feelevel,
7295                                                      feepayer,
7296                                                      feetext,
7297                                                      apr,
7298                                                      lea,
7299                                                      countrybirth,
7300                                                      nationality,
7301                                                      dualnationality,
7302                                                      withdrawn,
7303                                                      withdrawndate,
7304                                                      routeb,
7305                                                      examchangedate,
7306                                                      alevels,
7307                                                      aslevels,
7308                                                      highers,
7309                                                      csys,
7310                                                      gce,
7311                                                      vce,
7312                                                      sqa,
7313                                                      winter,
7314                                                      previousa,
7315                                                      previousas,
7316                                                      keyskills,
7317                                                      vocational,
7318                                                      gnvq,
7319                                                      btec,
7320                                                      ilc,
7321                                                      aice,
7322                                                      ib,
7323                                                      manual,
7324                                                      regno,
7325                                                      scn,
7326                                                      oeq,
7327                                                      prevoeq,
7328                                                      eas,
7329                                                      roa,
7330                                                      specialneeds,
7331                                                      criminalconv,
7332                                                      ukentrydate,
7333                                                      status,
7334                                                      firmnow,
7335                                                      firmreply,
7336                                                      insurancereply,
7337                                                      confhistfirmreply,
7338                                                      confhistinsurancereply,
7339                                                      choicesalltransparent,
7340                                                      extrastatus,
7341                                                      extrapassportno,
7342                                                      welshspeaker,
7343                                                      ninumber,
7344                                                      earlieststart,
7345                                                      nearinst,
7346                                                      prefreg,
7347                                                      qualeng,
7348                                                      qualmath,
7349                                                      qualsci,
7350                                                      mainqual,
7351                                                      qual5,
7352                                                      record_status,
7353                                                      error_code
7354                                                      )
7355                                          VALUES (    l_appno,
7356                                                      c_ivstark_rec.applicationdate,
7357                                                      c_ivstark_rec.sentdate,
7358                                                      c_ivstark_rec.runsent,
7359                                                      c_ivstark_rec.codedchangedate,
7360                                                      c_ivstark_rec.school,
7361                                                      c_ivstark_rec.rescat,
7362                                                      c_ivstark_rec.feelevel,
7363                                                      c_ivstark_rec.feepayer,
7364                                                      c_ivstark_rec.feetext,
7365                                                      c_ivstark_rec.apr,
7366                                                      c_ivstark_rec.lea,
7367                                                      c_ivstark_rec.countrybirth,
7368                                                      c_ivstark_rec.nationality,
7369                                                      c_ivstark_rec.dualnationality,
7370                                                      c_ivstark_rec.withdrawn,
7371                                                      c_ivstark_rec.withdrawndate,
7372                                                      c_ivstark_rec.routeb,
7373                                                      c_ivstark_rec.examchangedate,
7374                                                      c_ivstark_rec.alevels,
7375                                                      c_ivstark_rec.aslevels,
7376                                                      c_ivstark_rec.highers,
7377                                                      c_ivstark_rec.csys,
7378                                                      c_ivstark_rec.gce,
7379                                                      c_ivstark_rec.vce,
7380                                                      c_ivstark_rec.sqa,
7381                                                      c_ivstark_rec.winter,
7382                                                      c_ivstark_rec.previousa,
7383                                                      c_ivstark_rec.previousas,
7384                                                      c_ivstark_rec.keyskills,
7385                                                      c_ivstark_rec.vocational,
7386                                                      c_ivstark_rec.gnvq,
7387                                                      c_ivstark_rec.btec,
7388                                                      c_ivstark_rec.ilc,
7389                                                      c_ivstark_rec.aice,
7390                                                      c_ivstark_rec.ib,
7391                                                      c_ivstark_rec.manual,
7392                                                      c_ivstark_rec.regno,
7393                                                      c_ivstark_rec.scn,
7394                                                      c_ivstark_rec.oeq,
7395                                                      c_ivstark_rec.prevoeq,
7396                                                      NVL(c_ivstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
7397                                                      c_ivstark_rec.roa,
7398                                                      c_ivstark_rec.disability,
7399                                                      c_ivstark_rec.criminalconv,
7400                                                      c_ivstark_rec.ukentrydate,
7401                                                      c_ivstark_rec.status,
7402                                                      c_ivstark_rec.firmnow,
7403                                                      c_ivstark_rec.firmreply,
7404                                                      c_ivstark_rec.insurancereply,
7405                                                      c_ivstark_rec.confhistfirmreply,
7406                                                      c_ivstark_rec.confhistinsurancereply,
7407                                                      c_ivstark_rec.choicesalltransparent,
7408                                                      c_ivstark_rec.extrastatus,
7409                                                      c_ivstark_rec.extrapassportno,
7410                                                      NULL,
7411                                                      NULL,
7412                                                      NULL,
7413                                                      NULL,
7414                                                      NULL,
7415                                                      NULL,
7416                                                      NULL,
7417                                                      NULL,
7418                                                      NULL,
7419                                                      NULL,
7420                                                     'N',
7421                                                     NULL
7422                                                      ) ;
7423                   -- increment count of records
7424                   l_count := l_count + 1;
7425 
7426               END IF;
7427 
7428        END LOOP ;
7429 
7430       IF g_sync_reqd THEN
7431               -- get the max timestamp of this hercules view
7432               OPEN c_max_timestamp ;
7433               FETCH c_max_timestamp INTO l_new_max_timestamp ;
7434               CLOSE c_max_timestamp ;
7435 
7436                -- update /insert the timestamp record with new max timestamp
7437                ins_upd_timestamp ('IVSTARK',   l_new_max_timestamp) ;
7438 
7439               -- log message that this view has been loaded
7440                log_complete('IVSTARK', l_count) ;
7441       ELSE
7442                 -- log message that this view is already in sync and need not be loaded
7443                log_already_insync('IVSTARK') ;
7444       END IF ;
7445       COMMIT;
7446 
7447   EXCEPTION
7448       WHEN OTHERS THEN
7449                ROLLBACK;
7450                write_to_log(SQLERRM);
7451                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
7452                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARK_2007');
7453                igs_ge_msg_stack.add;
7454                app_exception.raise_exception ;
7455   END  load_ivstark_2007   ;
7456 
7457 
7458   PROCEDURE load_ivgstark_2006 IS
7459     /******************************************************************
7460      Created By      :  jbaber
7461      Date Created By :  15-Aug-05
7462      Purpose         :  loads each record in the hercules view ivgstark into the interface table
7463                         igs_uc_istark_ints with record status N
7464      Known limitations,enhancements,remarks:
7465      Change History
7466      Who       When         What
7467     ***************************************************************** */
7468 
7469      -- Get all the records from hercules  view whose timestamp is > passed timestamp
7470       -- or get all the records in hercules view if the timestamp passed is null
7471       -- converting EAS field ,for bug#3087852
7472       CURSOR c_ivgstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
7473       SELECT appno
7474              ,timestamp
7475              ,applicationdate
7476              ,codedchangedate
7477              ,RTRIM(rescat) rescat
7478              ,feepayer
7479              ,apr
7480              ,countrybirth
7481              ,nationality
7482              ,RTRIM(withdrawn) withdrawn
7483              ,withdrawndate
7484              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
7485              ,specialneeds
7486              ,ukentrydate
7487              ,RTRIM(status) status
7488              ,firmnow
7489              ,extrastatus
7490       FROM  igs_uc_ivgstark_2006_v
7491       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
7492 
7493       -- get the max timestamp value of the hercules view
7494       CURSOR c_max_timestamp IS
7495       SELECT MAX(timestamp)
7496       FROM igs_uc_ivgstark_2006_v  ;
7497 
7498       -- Variables
7499       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
7500       l_new_max_timestamp igs_uc_ivgstark_2006_v.timestamp%TYPE ;
7501       l_count NUMBER ;
7502 
7503       l_appno      igs_uc_istark_ints.appno%TYPE;
7504       l_checkdigit NUMBER;
7505 
7506   BEGIN
7507        -- set syncronization required to false
7508        g_sync_reqd := FALSE;
7509        l_count := 0 ;
7510 
7511       -- log message that this view is being loaded
7512        log_start('IVGSTARK ON ') ;
7513 
7514       -- Get the old timestamp for this view in the configured cycle
7515       Herc_timestamp_exists('IVGSTARK', p_old_timestamp) ;
7516 
7517        -- create interface records for each record in the hercules view whose timestamp > old timestamp
7518        FOR c_ivgstark_rec IN c_ivgstark(p_old_timestamp) LOOP
7519               -- set x_sync_read to true if the loop is entered even once
7520               g_sync_reqd := TRUE;
7521 
7522               --Validate varchar to number conversion
7523               IF  is_valid(c_ivgstark_rec.appno,'IVGSTARK','APPNO','NUMBER') AND
7524                   is_valid(c_ivgstark_rec.feepayer,'IVGSTARK','FeePayer','NUMBER') AND
7525                   is_valid(c_ivgstark_rec.apr,'IVGSTARK','APR','NUMBER') AND
7526                   is_valid(c_ivgstark_rec.countrybirth,'IVGSTARK','CountryBirth','NUMBER') AND
7527                   is_valid(c_ivgstark_rec.nationality,'IVGSTARK','Nationality','NUMBER') AND
7528                   is_valid(c_ivgstark_rec.extrastatus,'IVGSTARK','ExtraStatus','NUMBER') THEN
7529 
7530                   -- Determine actual appno
7531                   get_appno(c_ivgstark_rec.appno, NULL, l_appno, l_checkdigit);
7532 
7533                   -- Obsolete matching records in interface table with status N
7534                   UPDATE igs_uc_istark_ints SET record_status = 'O'
7535                   WHERE record_status = 'N' AND  appno = l_appno   ;
7536 
7537 
7538                   -- copy hercules record into interface table with record status N
7539                   INSERT INTO igs_uc_istark_ints (   appno,
7540                                                      applicationdate,
7541                                                      rescat,
7542                                                      feepayer,
7543                                                      apr,
7544                                                      countrybirth,
7545                                                      nationality,
7546                                                      withdrawn,
7547                                                      withdrawndate,
7548                                                      eas,
7549                                                      specialneeds,
7550                                                      ukentrydate,
7551                                                      status,
7552                                                      firmnow,
7553                                                      extrastatus,
7554                                                      record_status,
7555                                                      error_code
7556                                                      )
7557                                          VALUES (    l_appno,
7558                                                      c_ivgstark_rec.applicationdate,
7559                                                      c_ivgstark_rec.rescat,
7560                                                      c_ivgstark_rec.feepayer,
7561                                                      c_ivgstark_rec.apr,
7562                                                      c_ivgstark_rec.countrybirth,
7563                                                      c_ivgstark_rec.nationality,
7564                                                      c_ivgstark_rec.withdrawn,
7565                                                      c_ivgstark_rec.withdrawndate,
7566                                                      NVL(c_ivgstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
7567                                                      c_ivgstark_rec.specialneeds,
7568                                                      c_ivgstark_rec.ukentrydate,
7569                                                      c_ivgstark_rec.status,
7570                                                      c_ivgstark_rec.firmnow,
7571                                                      c_ivgstark_rec.extrastatus,
7572                                                     'N',
7573                                                     NULL
7574                                                      ) ;
7575                   -- increment count of records
7576                   l_count := l_count + 1;
7577 
7578               END IF;
7579 
7580        END LOOP ;
7581 
7582       IF g_sync_reqd THEN
7583               -- get the max timestamp of this hercules view
7584               OPEN c_max_timestamp ;
7585               FETCH c_max_timestamp INTO l_new_max_timestamp ;
7586               CLOSE c_max_timestamp ;
7587 
7588                -- update /insert the timestamp record with new max timestamp
7589                ins_upd_timestamp ('IVGSTARK',   l_new_max_timestamp) ;
7590 
7591               -- log message that this view has been loaded
7592                log_complete('IVGSTARK', l_count) ;
7593       ELSE
7594                 -- log message that this view is already in sync and need not be loaded
7595                log_already_insync('IVGSTARK') ;
7596       END IF ;
7597       COMMIT;
7598 
7599   EXCEPTION
7600       WHEN OTHERS THEN
7601                ROLLBACK;
7602                write_to_log(SQLERRM);
7603                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
7604                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARK_2006');
7605                igs_ge_msg_stack.add;
7606                app_exception.raise_exception ;
7607   END  load_ivgstark_2006   ;
7608 
7609 
7610   PROCEDURE load_ivgstark_2007 IS
7611     /******************************************************************
7612      Created By      :  jbaber
7613      Date Created By :  11-Jul-06
7614      Purpose         :  loads each record in the hercules view ivgstark into the interface table
7615                         igs_uc_istark_ints with record status N
7616      Known limitations,enhancements,remarks:
7617      Change History
7618      Who       When         What
7619     ***************************************************************** */
7620 
7621      -- Get all the records from hercules  view whose timestamp is > passed timestamp
7622       -- or get all the records in hercules view if the timestamp passed is null
7623       -- converting EAS field ,for bug#3087852
7624       CURSOR c_ivgstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
7625       SELECT appno
7626              ,timestamp
7627              ,applicationdate
7628              ,codedchangedate
7629              ,RTRIM(rescat) rescat
7630              ,feepayer
7631              ,apr
7632              ,countrybirth
7633              ,nationality
7634              ,RTRIM(withdrawn) withdrawn
7635              ,withdrawndate
7636              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
7637              ,disability
7638              ,ukentrydate
7639              ,RTRIM(status) status
7640              ,firmnow
7641              ,extrastatus
7642       FROM  igs_uc_ivgstark_2007_v
7643       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
7644 
7645       -- get the max timestamp value of the hercules view
7646       CURSOR c_max_timestamp IS
7647       SELECT MAX(timestamp)
7648       FROM igs_uc_ivgstark_2007_v  ;
7649 
7650       -- Variables
7651       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
7652       l_new_max_timestamp igs_uc_ivgstark_2007_v.timestamp%TYPE ;
7653       l_count NUMBER ;
7654 
7655       l_appno      igs_uc_istark_ints.appno%TYPE;
7656       l_checkdigit NUMBER;
7657 
7658   BEGIN
7659        -- set syncronization required to false
7660        g_sync_reqd := FALSE;
7661        l_count := 0 ;
7662 
7663       -- log message that this view is being loaded
7664        log_start('IVGSTARK ON ') ;
7665 
7666       -- Get the old timestamp for this view in the configured cycle
7667       Herc_timestamp_exists('IVGSTARK', p_old_timestamp) ;
7668 
7669        -- create interface records for each record in the hercules view whose timestamp > old timestamp
7670        FOR c_ivgstark_rec IN c_ivgstark(p_old_timestamp) LOOP
7671               -- set x_sync_read to true if the loop is entered even once
7672               g_sync_reqd := TRUE;
7673 
7674               --Validate varchar to number conversion
7675               IF  is_valid(c_ivgstark_rec.appno,'IVGSTARK','APPNO','NUMBER') AND
7676                   is_valid(c_ivgstark_rec.feepayer,'IVGSTARK','FeePayer','NUMBER') AND
7677                   is_valid(c_ivgstark_rec.apr,'IVGSTARK','APR','NUMBER') AND
7678                   is_valid(c_ivgstark_rec.countrybirth,'IVGSTARK','CountryBirth','NUMBER') AND
7679                   is_valid(c_ivgstark_rec.nationality,'IVGSTARK','Nationality','NUMBER') AND
7680                   is_valid(c_ivgstark_rec.extrastatus,'IVGSTARK','ExtraStatus','NUMBER') THEN
7681 
7682                   -- Determine actual appno
7683                   get_appno(c_ivgstark_rec.appno, NULL, l_appno, l_checkdigit);
7684 
7685                   -- Obsolete matching records in interface table with status N
7686                   UPDATE igs_uc_istark_ints SET record_status = 'O'
7687                   WHERE record_status = 'N' AND  appno = l_appno   ;
7688 
7689 
7690                   -- copy hercules record into interface table with record status N
7691                   INSERT INTO igs_uc_istark_ints (   appno,
7692                                                      applicationdate,
7693                                                      rescat,
7694                                                      feepayer,
7695                                                      apr,
7696                                                      countrybirth,
7697                                                      nationality,
7698                                                      withdrawn,
7699                                                      withdrawndate,
7700                                                      eas,
7701                                                      specialneeds,
7702                                                      ukentrydate,
7703                                                      status,
7704                                                      firmnow,
7705                                                      extrastatus,
7706                                                      record_status,
7707                                                      error_code
7708                                                      )
7709                                          VALUES (    l_appno,
7710                                                      c_ivgstark_rec.applicationdate,
7711                                                      c_ivgstark_rec.rescat,
7712                                                      c_ivgstark_rec.feepayer,
7713                                                      c_ivgstark_rec.apr,
7714                                                      c_ivgstark_rec.countrybirth,
7715                                                      c_ivgstark_rec.nationality,
7716                                                      c_ivgstark_rec.withdrawn,
7717                                                      c_ivgstark_rec.withdrawndate,
7718                                                      NVL(c_ivgstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
7719                                                      c_ivgstark_rec.disability,
7720                                                      c_ivgstark_rec.ukentrydate,
7721                                                      c_ivgstark_rec.status,
7722                                                      c_ivgstark_rec.firmnow,
7723                                                      c_ivgstark_rec.extrastatus,
7724                                                     'N',
7725                                                     NULL
7726                                                      ) ;
7727                   -- increment count of records
7728                   l_count := l_count + 1;
7729 
7730               END IF;
7731 
7732        END LOOP ;
7733 
7734       IF g_sync_reqd THEN
7735               -- get the max timestamp of this hercules view
7736               OPEN c_max_timestamp ;
7737               FETCH c_max_timestamp INTO l_new_max_timestamp ;
7738               CLOSE c_max_timestamp ;
7739 
7740                -- update /insert the timestamp record with new max timestamp
7741                ins_upd_timestamp ('IVGSTARK',   l_new_max_timestamp) ;
7742 
7743               -- log message that this view has been loaded
7744                log_complete('IVGSTARK', l_count) ;
7745       ELSE
7746                 -- log message that this view is already in sync and need not be loaded
7747                log_already_insync('IVGSTARK') ;
7748       END IF ;
7749       COMMIT;
7750 
7751   EXCEPTION
7752       WHEN OTHERS THEN
7753                ROLLBACK;
7754                write_to_log(SQLERRM);
7755                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
7756                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARK_2007');
7757                igs_ge_msg_stack.add;
7758                app_exception.raise_exception ;
7759   END  load_ivgstark_2007   ;
7760 
7761 
7762   PROCEDURE load_ivnstark_2006 IS
7763     /******************************************************************
7764      Created By      :  jbaber
7765      Date Created By :  15-Aug-05
7766      Purpose         :  loads each record in the hercules view ivnstark into the interface table
7767                         igs_uc_istark_ints with record status N
7768      Known limitations,enhancements,remarks:
7769      Change History
7770      Who       When         What
7771     ***************************************************************** */
7772 
7773      -- Get all the records from hercules  view whose timestamp is > passed timestamp
7774       -- or get all the records in hercules view if the timestamp passed is null
7775       -- converting EAS field ,for bug#3087852
7776       CURSOR c_ivnstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
7777       SELECT appno
7778              ,timestamp
7779              ,applicationdate
7780              ,sentdate
7781              ,runsent
7782              ,codedchangedate
7783              ,RTRIM(rescat) rescat
7784              ,feelevel
7785              ,apr
7786              ,countrybirth
7787              ,nationality
7788              ,RTRIM(withdrawn) withdrawn
7789              ,withdrawndate
7790              ,qualenglish
7791              ,qualmaths
7792              ,qualscience
7793              ,qual5point
7794              ,qualmain
7795              ,nationalinsurance
7796              ,startdate
7797              ,nearestinst
7798              ,prefregion
7799              ,specialneeds
7800              ,RTRIM(status) status
7801              ,firmnow
7802              ,ukentrydate
7803              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
7804       FROM  igs_uc_ivnstark_2006_v
7805       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
7806 
7807       -- get the max timestamp value of the hercules view
7808       CURSOR c_max_timestamp IS
7809       SELECT MAX(timestamp)
7810       FROM igs_uc_ivnstark_2006_v  ;
7811 
7812       -- Variables
7813       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
7814       l_new_max_timestamp igs_uc_ivnstark_2006_v.timestamp%TYPE ;
7815       l_count NUMBER ;
7816 
7817       l_appno      igs_uc_istark_ints.appno%TYPE;
7818       l_checkdigit NUMBER;
7819 
7820       l_startdate  DATE;
7821 
7822   BEGIN
7823        -- set syncronization required to false
7824        g_sync_reqd := FALSE;
7825        l_count := 0 ;
7826 
7827       -- log message that this view is being loaded
7828        log_start('IVNSTARK ON ') ;
7829 
7830       -- Get the old timestamp for this view in the configured cycle
7831       Herc_timestamp_exists('IVNSTARK', p_old_timestamp) ;
7832 
7833        -- create interface records for each record in the hercules view whose timestamp > old timestamp
7834        FOR c_ivnstark_rec IN c_ivnstark(p_old_timestamp) LOOP
7835               -- set x_sync_read to true if the loop is entered even once
7836               g_sync_reqd := TRUE;
7837 
7838               --Validate varchar to number conversion
7839               IF  is_valid(c_ivnstark_rec.appno,'IVNSTARK','APPNO','NUMBER') AND
7840                   is_valid(c_ivnstark_rec.runsent,'IVNSTARK','RunSent','NUMBER') AND
7841                   is_valid(c_ivnstark_rec.apr,'IVNSTARK','APR','NUMBER') AND
7842                   is_valid(c_ivnstark_rec.countrybirth,'IVNSTARK','CountryBirth','NUMBER') AND
7843                   is_valid(c_ivnstark_rec.nationality,'IVNSTARK','Nationality','NUMBER') AND
7844                   is_valid(c_ivnstark_rec.prefregion,'IVNSTARK','PrefRegion','NUMBER') THEN
7845 
7846                   -- Determine actual appno
7847                   get_appno(c_ivnstark_rec.appno, NULL, l_appno, l_checkdigit);
7848 
7849                   -- Implicility convert startdate to date to avoid compile errors when pointing to DUMMY
7850                   l_startdate := c_ivnstark_rec.startdate;
7851 
7852                   -- Obsolete matching records in interface table with status N
7853                   UPDATE igs_uc_istark_ints SET record_status = 'O'
7854                   WHERE record_status = 'N' AND  appno = l_appno   ;
7855 
7856 
7857                   -- copy hercules record into interface table with record status N
7858                   INSERT INTO igs_uc_istark_ints (   appno,
7859                                                      applicationdate,
7860                                                      sentdate,
7861                                                      runsent,
7862                                                      codedchangedate,
7863                                                      rescat,
7864                                                      feelevel,
7865                                                      apr,
7866                                                      countrybirth,
7867                                                      nationality,
7868                                                      withdrawn,
7869                                                      withdrawndate,
7870                                                      qualeng,
7871                                                      qualmath,
7872                                                      qualsci,
7873                                                      qual5,
7874                                                      mainqual,
7875                                                      ninumber,
7876                                                      earlieststart,
7877                                                      nearinst,
7878                                                      prefreg,
7879                                                      specialneeds,
7880                                                      status,
7881                                                      firmnow,
7882                                                      ukentrydate,
7883                                                      eas,
7887                                          VALUES (    l_appno,
7884                                                      record_status,
7885                                                      error_code
7886                                                      )
7888                                                      c_ivnstark_rec.applicationdate,
7889                                                      c_ivnstark_rec.sentdate,
7890                                                      c_ivnstark_rec.runsent,
7891                                                      c_ivnstark_rec.codedchangedate,
7892                                                      c_ivnstark_rec.rescat,
7893                                                      c_ivnstark_rec.feelevel,
7894                                                      c_ivnstark_rec.apr,
7895                                                      c_ivnstark_rec.countrybirth,
7896                                                      c_ivnstark_rec.nationality,
7897                                                      c_ivnstark_rec.withdrawn,
7898                                                      c_ivnstark_rec.withdrawndate,
7899                                                      c_ivnstark_rec.qualenglish,
7900                                                      c_ivnstark_rec.qualmaths,
7901                                                      c_ivnstark_rec.qualscience,
7902                                                      c_ivnstark_rec.qual5point,
7903                                                      c_ivnstark_rec.qualmain,
7904                                                      c_ivnstark_rec.nationalinsurance,
7905                                                      TO_CHAR(l_startdate,'mmyy'),
7906                                                      c_ivnstark_rec.nearestinst,
7907                                                      c_ivnstark_rec.prefregion,
7908                                                      c_ivnstark_rec.specialneeds,
7909                                                      c_ivnstark_rec.status,
7910                                                      c_ivnstark_rec.firmnow,
7911                                                      c_ivnstark_rec.ukentrydate,
7912                                                      NVL(c_ivnstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
7913                                                      'N',
7914                                                      NULL
7915                                                      ) ;
7916 
7917                   -- increment count of records
7918                   l_count := l_count + 1;
7919 
7920               END IF;
7921 
7922        END LOOP ;
7923 
7924       IF g_sync_reqd THEN
7925               -- get the max timestamp of this hercules view
7926               OPEN c_max_timestamp ;
7927               FETCH c_max_timestamp INTO l_new_max_timestamp ;
7928               CLOSE c_max_timestamp ;
7929 
7930                -- update /insert the timestamp record with new max timestamp
7931                ins_upd_timestamp ('IVNSTARK',   l_new_max_timestamp) ;
7932 
7933               -- log message that this view has been loaded
7934                log_complete('IVNSTARK', l_count) ;
7935       ELSE
7936                 -- log message that this view is already in sync and need not be loaded
7937                log_already_insync('IVNSTARK') ;
7938       END IF ;
7939       COMMIT;
7940 
7941   EXCEPTION
7942       WHEN OTHERS THEN
7943                ROLLBACK;
7944                write_to_log(SQLERRM);
7945                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
7946                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARK_2006');
7947                igs_ge_msg_stack.add;
7948                app_exception.raise_exception ;
7949   END  load_ivnstark_2006   ;
7950 
7951 
7952   PROCEDURE load_ivnstark_2007 IS
7953     /******************************************************************
7954      Created By      :  jbaber
7955      Date Created By :  11-Jul-06
7956      Purpose         :  loads each record in the hercules view ivnstark into the interface table
7957                         igs_uc_istark_ints with record status N
7958      Known limitations,enhancements,remarks:
7959      Change History
7960      Who       When         What
7961     ***************************************************************** */
7962 
7963      -- Get all the records from hercules  view whose timestamp is > passed timestamp
7964       -- or get all the records in hercules view if the timestamp passed is null
7965       -- converting EAS field ,for bug#3087852
7966       CURSOR c_ivnstark ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
7967       SELECT appno
7968              ,timestamp
7969              ,applicationdate
7970              ,sentdate
7971              ,runsent
7972              ,codedchangedate
7973              ,RTRIM(rescat) rescat
7974              ,feelevel
7975              ,apr
7976              ,countrybirth
7977              ,nationality
7978              ,RTRIM(withdrawn) withdrawn
7979              ,withdrawndate
7980              ,qualenglish
7981              ,qualmaths
7982              ,qualscience
7983              ,qual5point
7984              ,qualmain
7985              ,nationalinsurance
7986              ,startdate
7987              ,nearestinst
7988              ,prefregion
7989              ,disability
7990              ,RTRIM(status) status
7991              ,firmnow
7992              ,ukentrydate
7993              ,DECODE(RTRIM(eas),'Y','E',RTRIM(eas) )  eas
7994       FROM  igs_uc_ivnstark_2007_v
7995       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
7996 
7997       -- get the max timestamp value of the hercules view
7998       CURSOR c_max_timestamp IS
7999       SELECT MAX(timestamp)
8000       FROM igs_uc_ivnstark_2007_v  ;
8001 
8002       -- Variables
8003       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8004       l_new_max_timestamp igs_uc_ivnstark_2007_v.timestamp%TYPE ;
8005       l_count NUMBER ;
8006 
8007       l_appno      igs_uc_istark_ints.appno%TYPE;
8008       l_checkdigit NUMBER;
8009 
8010       l_startdate  DATE;
8011 
8012   BEGIN
8013        -- set syncronization required to false
8014        g_sync_reqd := FALSE;
8015        l_count := 0 ;
8016 
8017       -- log message that this view is being loaded
8018        log_start('IVNSTARK ON ') ;
8019 
8020       -- Get the old timestamp for this view in the configured cycle
8021       Herc_timestamp_exists('IVNSTARK', p_old_timestamp) ;
8022 
8023        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8024        FOR c_ivnstark_rec IN c_ivnstark(p_old_timestamp) LOOP
8025               -- set x_sync_read to true if the loop is entered even once
8026               g_sync_reqd := TRUE;
8027 
8028               --Validate varchar to number conversion
8029               IF  is_valid(c_ivnstark_rec.appno,'IVNSTARK','APPNO','NUMBER') AND
8030                   is_valid(c_ivnstark_rec.runsent,'IVNSTARK','RunSent','NUMBER') AND
8031                   is_valid(c_ivnstark_rec.apr,'IVNSTARK','APR','NUMBER') AND
8032                   is_valid(c_ivnstark_rec.countrybirth,'IVNSTARK','CountryBirth','NUMBER') AND
8033                   is_valid(c_ivnstark_rec.nationality,'IVNSTARK','Nationality','NUMBER') AND
8034                   is_valid(c_ivnstark_rec.prefregion,'IVNSTARK','PrefRegion','NUMBER') THEN
8035 
8036                   -- Determine actual appno
8037                   get_appno(c_ivnstark_rec.appno, NULL, l_appno, l_checkdigit);
8038 
8039                   -- Implicility convert startdate to date to avoid compile errors when pointing to DUMMY
8040                   l_startdate := c_ivnstark_rec.startdate;
8041 
8042                   -- Obsolete matching records in interface table with status N
8043                   UPDATE igs_uc_istark_ints SET record_status = 'O'
8044                   WHERE record_status = 'N' AND  appno = l_appno   ;
8045 
8046 
8047                   -- copy hercules record into interface table with record status N
8048                   INSERT INTO igs_uc_istark_ints (   appno,
8049                                                      applicationdate,
8050                                                      sentdate,
8051                                                      runsent,
8052                                                      codedchangedate,
8053                                                      rescat,
8054                                                      feelevel,
8055                                                      apr,
8056                                                      countrybirth,
8057                                                      nationality,
8058                                                      withdrawn,
8059                                                      withdrawndate,
8060                                                      qualeng,
8061                                                      qualmath,
8062                                                      qualsci,
8063                                                      qual5,
8064                                                      mainqual,
8065                                                      ninumber,
8066                                                      earlieststart,
8067                                                      nearinst,
8068                                                      prefreg,
8069                                                      specialneeds,
8070                                                      status,
8071                                                      firmnow,
8072                                                      ukentrydate,
8073                                                      eas,
8074                                                      record_status,
8075                                                      error_code
8076                                                      )
8077                                          VALUES (    l_appno,
8078                                                      c_ivnstark_rec.applicationdate,
8079                                                      c_ivnstark_rec.sentdate,
8080                                                      c_ivnstark_rec.runsent,
8081                                                      c_ivnstark_rec.codedchangedate,
8082                                                      c_ivnstark_rec.rescat,
8083                                                      c_ivnstark_rec.feelevel,
8084                                                      c_ivnstark_rec.apr,
8085                                                      c_ivnstark_rec.countrybirth,
8086                                                      c_ivnstark_rec.nationality,
8087                                                      c_ivnstark_rec.withdrawn,
8088                                                      c_ivnstark_rec.withdrawndate,
8089                                                      c_ivnstark_rec.qualenglish,
8090                                                      c_ivnstark_rec.qualmaths,
8091                                                      c_ivnstark_rec.qualscience,
8092                                                      c_ivnstark_rec.qual5point,
8093                                                      c_ivnstark_rec.qualmain,
8094                                                      c_ivnstark_rec.nationalinsurance,
8095                                                      TO_CHAR(l_startdate,'mmyy'),
8096                                                      c_ivnstark_rec.nearestinst,
8097                                                      c_ivnstark_rec.prefregion,
8098                                                      c_ivnstark_rec.disability,
8099                                                      c_ivnstark_rec.status,
8100                                                      c_ivnstark_rec.firmnow,
8101                                                      c_ivnstark_rec.ukentrydate,
8102                                                      NVL(c_ivnstark_rec.eas,'P'), -- converting EAS field ,for bug#3087852
8103                                                      'N',
8104                                                      NULL
8105                                                      ) ;
8106 
8107                   -- increment count of records
8108                   l_count := l_count + 1;
8109 
8110               END IF;
8111 
8112        END LOOP ;
8113 
8114       IF g_sync_reqd THEN
8115               -- get the max timestamp of this hercules view
8116               OPEN c_max_timestamp ;
8117               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8118               CLOSE c_max_timestamp ;
8119 
8120                -- update /insert the timestamp record with new max timestamp
8121                ins_upd_timestamp ('IVNSTARK',   l_new_max_timestamp) ;
8122 
8123               -- log message that this view has been loaded
8124                log_complete('IVNSTARK', l_count) ;
8125       ELSE
8126                 -- log message that this view is already in sync and need not be loaded
8127                log_already_insync('IVNSTARK') ;
8128       END IF ;
8129       COMMIT;
8130 
8131   EXCEPTION
8132       WHEN OTHERS THEN
8133                ROLLBACK;
8134                write_to_log(SQLERRM);
8135                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8136                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARK_2007');
8137                igs_ge_msg_stack.add;
8138                app_exception.raise_exception ;
8139   END  load_ivnstark_2007   ;
8140 
8141 
8142   PROCEDURE load_ivstarn_2003 IS
8143     /******************************************************************
8144      Created By      :  smaddali
8145      Date Created By :   11-Jun-03
8146      Purpose         :     loads each record in the hercules view ivstarn into the interface table
8147                            igs_uc_istarn_ints with record status N
8148      Known limitations,enhancements,remarks:
8149      Change History
8150      Who       When         What
8151     ***************************************************************** */
8152 
8153      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8154       -- or get all the records in hercules view if the timestamp passed is null
8155       CURSOR c_ivstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8156       SELECT  appno
8157             ,timestamp
8158             ,checkdigit
8159             ,namechangedate
8160             ,UPPER(RTRIM(title)) title
8161             ,RTRIM(forenames) forenames
8162             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8163             ,birthdate
8164             ,sex
8165       FROM  igs_uc_ivstarn_2003_v
8166       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8167 
8168       -- get the max timestamp value of the hercules view
8169       CURSOR c_max_timestamp IS
8170       SELECT MAX(timestamp)
8171       FROM igs_uc_ivstarn_2003_v  ;
8172 
8173       -- Variables
8174       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8175       l_new_max_timestamp igs_uc_ivstarn_2003_v.timestamp%TYPE ;
8176       l_count NUMBER ;
8177 
8178       l_appno      igs_uc_istarn_ints.appno%TYPE;
8179       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8180 
8181   BEGIN
8182        -- set syncronization required to false
8183        g_sync_reqd := FALSE;
8184        l_count := 0 ;
8185 
8186       -- log message that this view is being loaded
8187        log_start('IVSTARN ON ' ) ;
8188 
8189       -- Get the old timestamp for this view in the configured cycle
8190       Herc_timestamp_exists('IVSTARN',  p_old_timestamp) ;
8191 
8192        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8193        FOR c_ivstarn_rec IN c_ivstarn(p_old_timestamp) LOOP
8194               -- set x_sync_read to true if the loop is entered even once
8195               g_sync_reqd := TRUE;
8196 
8197               IF  is_valid(c_ivstarn_rec.appno,'IVSTARN','APPNO','NUMBER') THEN
8198 
8199                   -- Determine actual appno and checkdigit
8200                   get_appno(c_ivstarn_rec.appno, c_ivstarn_rec.checkdigit, l_appno, l_checkdigit);
8201 
8202                   -- Obsolete matching records in interface table with status N / I
8203                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8204                   WHERE record_status = 'N' AND appno = l_appno  ;
8205 
8206                   -- copy hercules record into interface table with record status N
8207                   INSERT INTO igs_uc_istarn_ints (  appno,
8208                                                     checkdigit,
8209                                                     namechangedate,
8210                                                     title,
8211                                                     forenames,
8212                                                     surname,
8213                                                     birthdate,
8214                                                     sex,
8215                                                     ad_batch_id,
8216                                                     ad_interface_id,
8217                                                     ad_api_id,
8218                                                     record_status,
8219                                                     error_code
8220                                                      )
8221                                          VALUES (   l_appno,
8222                                                     l_checkdigit,
8223                                                     c_ivstarn_rec.namechangedate,
8224                                                     c_ivstarn_rec.title,
8225                                                     c_ivstarn_rec.forenames,
8226                                                     c_ivstarn_rec.surname,
8227                                                     c_ivstarn_rec.birthdate,
8228                                                     c_ivstarn_rec.sex,
8229                                                     NULL,
8230                                                     NULL,
8231                                                     NULL,
8232                                                     'N',
8233                                                     NULL
8234                                                      ) ;
8235                   -- increment count of records
8236                   l_count := l_count + 1;
8237 
8238               END IF;
8239 
8240        END LOOP ;
8241 
8242       IF g_sync_reqd THEN
8243               -- get the max timestamp of this hercules view
8244               OPEN c_max_timestamp ;
8245               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8246               CLOSE c_max_timestamp ;
8247 
8248                -- update /insert the timestamp record with new max timestamp
8249                ins_upd_timestamp ('IVSTARN', l_new_max_timestamp) ;
8250 
8251               -- log message that this view has been loaded
8252                log_complete('IVSTARN', l_count ) ;
8253       ELSE
8254                 -- log message that this view is already in sync and need not be loaded
8255                log_already_insync('IVSTARN') ;
8256       END IF ;
8257       COMMIT;
8258 
8259   EXCEPTION
8260       WHEN OTHERS THEN
8261                ROLLBACK;
8262                write_to_log(SQLERRM);
8263                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8264                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARN_2003');
8265                igs_ge_msg_stack.add;
8266                app_exception.raise_exception ;
8267   END   load_ivstarn_2003  ;
8268 
8269 
8270   PROCEDURE load_ivstarn_2007 IS
8271     /******************************************************************
8272      Created By      :  jbaber
8273      Date Created By :   11-Jul-06
8274      Purpose         :     loads each record in the hercules view ivstarn into the interface table
8275                            igs_uc_istarn_ints with record status N
8276      Known limitations,enhancements,remarks:
8277      Change History
8278      Who       When         What
8279     ***************************************************************** */
8280 
8281      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8282       -- or get all the records in hercules view if the timestamp passed is null
8283       CURSOR c_ivstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8284       SELECT  appno
8285             ,RTRIM(personalid) personalid
8286             ,timestamp
8287             ,checkdigit
8288             ,namechangedate
8289             ,UPPER(RTRIM(title)) title
8290             ,RTRIM(forenames) forenames
8291             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8292             ,birthdate
8293             ,sex
8294       FROM  igs_uc_ivstarn_2007_v
8295       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8296 
8297       -- get the max timestamp value of the hercules view
8298       CURSOR c_max_timestamp IS
8299       SELECT MAX(timestamp)
8300       FROM igs_uc_ivstarn_2007_v  ;
8301 
8302       -- Variables
8303       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8304       l_new_max_timestamp igs_uc_ivstarn_2007_v.timestamp%TYPE ;
8305       l_count NUMBER ;
8306 
8307       l_appno      igs_uc_istarn_ints.appno%TYPE;
8308       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8309 
8310   BEGIN
8311        -- set syncronization required to false
8312        g_sync_reqd := FALSE;
8313        l_count := 0 ;
8314 
8315       -- log message that this view is being loaded
8316        log_start('IVSTARN ON ' ) ;
8317 
8318       -- Get the old timestamp for this view in the configured cycle
8319       Herc_timestamp_exists('IVSTARN',  p_old_timestamp) ;
8320 
8321        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8322        FOR c_ivstarn_rec IN c_ivstarn(p_old_timestamp) LOOP
8323               -- set x_sync_read to true if the loop is entered even once
8324               g_sync_reqd := TRUE;
8325 
8326               IF  is_valid(c_ivstarn_rec.appno,'IVSTARN','APPNO','NUMBER') THEN
8327 
8328                   -- Determine actual appno and checkdigit
8329                   get_appno(c_ivstarn_rec.appno, c_ivstarn_rec.checkdigit, l_appno, l_checkdigit);
8330 
8331                   -- Obsolete matching records in interface table with status N / I
8332                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8333                   WHERE record_status = 'N' AND appno = l_appno  ;
8334 
8335                   -- copy hercules record into interface table with record status N
8336                   INSERT INTO igs_uc_istarn_ints (  appno,
8337                                                     checkdigit,
8338                                                     personalid,
8339                                                     namechangedate,
8340                                                     title,
8341                                                     forenames,
8342                                                     surname,
8343                                                     birthdate,
8344                                                     sex,
8345                                                     ad_batch_id,
8346                                                     ad_interface_id,
8347                                                     ad_api_id,
8348                                                     record_status,
8349                                                     error_code
8350                                                      )
8351                                          VALUES (   l_appno,
8352                                                     l_checkdigit,
8353                                                     c_ivstarn_rec.personalid,
8354                                                     c_ivstarn_rec.namechangedate,
8355                                                     c_ivstarn_rec.title,
8356                                                     c_ivstarn_rec.forenames,
8357                                                     c_ivstarn_rec.surname,
8358                                                     c_ivstarn_rec.birthdate,
8359                                                     c_ivstarn_rec.sex,
8360                                                     NULL,
8361                                                     NULL,
8362                                                     NULL,
8363                                                     'N',
8364                                                     NULL
8365                                                      ) ;
8366                   -- increment count of records
8367                   l_count := l_count + 1;
8368 
8369               END IF;
8370 
8371        END LOOP ;
8372 
8373       IF g_sync_reqd THEN
8374               -- get the max timestamp of this hercules view
8375               OPEN c_max_timestamp ;
8376               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8377               CLOSE c_max_timestamp ;
8378 
8379                -- update /insert the timestamp record with new max timestamp
8380                ins_upd_timestamp ('IVSTARN', l_new_max_timestamp) ;
8381 
8382               -- log message that this view has been loaded
8383                log_complete('IVSTARN', l_count ) ;
8384       ELSE
8385                 -- log message that this view is already in sync and need not be loaded
8386                log_already_insync('IVSTARN') ;
8387       END IF ;
8388       COMMIT;
8389 
8390   EXCEPTION
8391       WHEN OTHERS THEN
8392                ROLLBACK;
8393                write_to_log(SQLERRM);
8394                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8395                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARN_2007');
8396                igs_ge_msg_stack.add;
8397                app_exception.raise_exception ;
8398   END   load_ivstarn_2007  ;
8399 
8400 
8401   PROCEDURE load_ivgstarn_2006 IS
8402     /******************************************************************
8403      Created By      :  jbaber
8404      Date Created By :  16-Aug-05
8405      Purpose         :  loads each record in the hercules view ivgstarn into the interface table
8406                         igs_uc_istarn_ints with record status N
8407      Known limitations,enhancements,remarks:
8408      Change History
8409      Who       When         What
8410     ***************************************************************** */
8411 
8412      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8413       -- or get all the records in hercules view if the timestamp passed is null
8414       CURSOR c_ivgstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8415       SELECT  appno
8416             ,timestamp
8417             ,UPPER(RTRIM(title)) title
8418             ,RTRIM(forenames) forenames
8419             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8420             ,birthdate
8421             ,sex
8422       FROM  igs_uc_ivgstarn_2006_v
8423       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8424 
8425       -- get the max timestamp value of the hercules view
8426       CURSOR c_max_timestamp IS
8427       SELECT MAX(timestamp)
8428       FROM igs_uc_ivgstarn_2006_v  ;
8429 
8430       -- Variables
8431       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8432       l_new_max_timestamp igs_uc_ivgstarn_2006_v.timestamp%TYPE ;
8433       l_count NUMBER ;
8434 
8435       l_appno      igs_uc_istarn_ints.appno%TYPE;
8436       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8437 
8438   BEGIN
8439        -- set syncronization required to false
8440        g_sync_reqd := FALSE;
8441        l_count := 0 ;
8442 
8443       -- log message that this view is being loaded
8444        log_start('IVGSTARN ON ' ) ;
8445 
8446       -- Get the old timestamp for this view in the configured cycle
8447       Herc_timestamp_exists('IVGSTARN',  p_old_timestamp) ;
8448 
8449        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8450        FOR c_ivgstarn_rec IN c_ivgstarn(p_old_timestamp) LOOP
8451               -- set x_sync_read to true if the loop is entered even once
8452               g_sync_reqd := TRUE;
8453 
8454               IF  is_valid(c_ivgstarn_rec.appno,'IVGSTARN','APPNO','NUMBER') THEN
8455 
8456                   -- Determine actual appno and checkdigit
8457                   get_appno(c_ivgstarn_rec.appno, NULL, l_appno, l_checkdigit);
8458 
8459                   -- Obsolete matching records in interface table with status N / I
8460                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8461                   WHERE record_status = 'N' AND appno = l_appno  ;
8462 
8463                   -- copy hercules record into interface table with record status N
8464                   INSERT INTO igs_uc_istarn_ints (  appno,
8465                                                     checkdigit,
8466                                                     title,
8467                                                     forenames,
8468                                                     surname,
8469                                                     birthdate,
8470                                                     sex,
8471                                                     ad_batch_id,
8472                                                     ad_interface_id,
8473                                                     ad_api_id,
8474                                                     record_status,
8475                                                     error_code
8476                                                      )
8477                                          VALUES (   l_appno,
8478                                                     l_checkdigit,
8479                                                     c_ivgstarn_rec.title,
8480                                                     c_ivgstarn_rec.forenames,
8481                                                     c_ivgstarn_rec.surname,
8482                                                     c_ivgstarn_rec.birthdate,
8483                                                     c_ivgstarn_rec.sex,
8484                                                     NULL,
8485                                                     NULL,
8486                                                     NULL,
8487                                                     'N',
8488                                                     NULL
8489                                                      ) ;
8490                   -- increment count of records
8491                   l_count := l_count + 1;
8492 
8493               END IF;
8494 
8495        END LOOP ;
8496 
8497       IF g_sync_reqd THEN
8498               -- get the max timestamp of this hercules view
8499               OPEN c_max_timestamp ;
8500               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8501               CLOSE c_max_timestamp ;
8502 
8503                -- update /insert the timestamp record with new max timestamp
8504                ins_upd_timestamp ('IVGSTARN', l_new_max_timestamp) ;
8505 
8506               -- log message that this view has been loaded
8507                log_complete('IVGSTARN', l_count ) ;
8508       ELSE
8509                 -- log message that this view is already in sync and need not be loaded
8510                log_already_insync('IVGSTARN') ;
8511       END IF ;
8512       COMMIT;
8513 
8514   EXCEPTION
8515       WHEN OTHERS THEN
8516                ROLLBACK;
8517                write_to_log(SQLERRM);
8518                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8519                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARN_2006');
8520                igs_ge_msg_stack.add;
8521                app_exception.raise_exception ;
8522   END   load_ivgstarn_2006  ;
8523 
8524   PROCEDURE load_ivgstarn_2007 IS
8525     /******************************************************************
8526      Created By      :  jbaber
8527      Date Created By :  11-Jul-06
8528      Purpose         :  loads each record in the hercules view ivgstarn into the interface table
8529                         igs_uc_istarn_ints with record status N
8530      Known limitations,enhancements,remarks:
8531      Change History
8532      Who       When         What
8533     ***************************************************************** */
8534 
8535      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8536       -- or get all the records in hercules view if the timestamp passed is null
8537       CURSOR c_ivgstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8538       SELECT  appno
8539             ,personalid
8540             ,timestamp
8541             ,UPPER(RTRIM(title)) title
8542             ,RTRIM(forenames) forenames
8543             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8544             ,birthdate
8545             ,sex
8546       FROM  igs_uc_ivgstarn_2007_v
8547       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8548 
8549       -- get the max timestamp value of the hercules view
8550       CURSOR c_max_timestamp IS
8551       SELECT MAX(timestamp)
8552       FROM igs_uc_ivgstarn_2007_v  ;
8553 
8554       -- Variables
8555       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8556       l_new_max_timestamp igs_uc_ivgstarn_2007_v.timestamp%TYPE ;
8557       l_count NUMBER ;
8558 
8559       l_appno      igs_uc_istarn_ints.appno%TYPE;
8560       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8561 
8562   BEGIN
8563        -- set syncronization required to false
8564        g_sync_reqd := FALSE;
8565        l_count := 0 ;
8566 
8567       -- log message that this view is being loaded
8568        log_start('IVGSTARN ON ' ) ;
8569 
8570       -- Get the old timestamp for this view in the configured cycle
8571       Herc_timestamp_exists('IVGSTARN',  p_old_timestamp) ;
8572 
8573        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8574        FOR c_ivgstarn_rec IN c_ivgstarn(p_old_timestamp) LOOP
8575               -- set x_sync_read to true if the loop is entered even once
8576               g_sync_reqd := TRUE;
8577 
8578               IF  is_valid(c_ivgstarn_rec.appno,'IVGSTARN','APPNO','NUMBER') THEN
8579 
8580                   -- Determine actual appno and checkdigit
8581                   get_appno(c_ivgstarn_rec.appno, NULL, l_appno, l_checkdigit);
8582 
8583                   -- Obsolete matching records in interface table with status N / I
8584                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8585                   WHERE record_status = 'N' AND appno = l_appno  ;
8586 
8587                   -- copy hercules record into interface table with record status N
8588                   INSERT INTO igs_uc_istarn_ints (  appno,
8589                                                     checkdigit,
8590                                                     personalid,
8591                                                     title,
8592                                                     forenames,
8593                                                     surname,
8594                                                     birthdate,
8595                                                     sex,
8596                                                     ad_batch_id,
8597                                                     ad_interface_id,
8598                                                     ad_api_id,
8599                                                     record_status,
8600                                                     error_code
8601                                                      )
8602                                          VALUES (   l_appno,
8603                                                     l_checkdigit,
8604                                                     c_ivgstarn_rec.personalid,
8605                                                     c_ivgstarn_rec.title,
8606                                                     c_ivgstarn_rec.forenames,
8607                                                     c_ivgstarn_rec.surname,
8608                                                     c_ivgstarn_rec.birthdate,
8609                                                     c_ivgstarn_rec.sex,
8610                                                     NULL,
8611                                                     NULL,
8612                                                     NULL,
8613                                                     'N',
8614                                                     NULL
8615                                                      ) ;
8616                   -- increment count of records
8617                   l_count := l_count + 1;
8618 
8619               END IF;
8620 
8621        END LOOP ;
8622 
8623       IF g_sync_reqd THEN
8624               -- get the max timestamp of this hercules view
8625               OPEN c_max_timestamp ;
8626               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8627               CLOSE c_max_timestamp ;
8628 
8629                -- update /insert the timestamp record with new max timestamp
8630                ins_upd_timestamp ('IVGSTARN', l_new_max_timestamp) ;
8631 
8632               -- log message that this view has been loaded
8633                log_complete('IVGSTARN', l_count ) ;
8634       ELSE
8635                 -- log message that this view is already in sync and need not be loaded
8636                log_already_insync('IVGSTARN') ;
8637       END IF ;
8638       COMMIT;
8639 
8640   EXCEPTION
8641       WHEN OTHERS THEN
8642                ROLLBACK;
8643                write_to_log(SQLERRM);
8644                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8645                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARN_2007');
8646                igs_ge_msg_stack.add;
8647                app_exception.raise_exception ;
8648   END   load_ivgstarn_2007  ;
8649 
8650 
8651   PROCEDURE load_ivnstarn_2006 IS
8652     /******************************************************************
8653      Created By      :  jbaber
8654      Date Created By :  16-Aug-05
8655      Purpose         :  loads each record in the hercules view ivnstarn into the interface table
8656                         igs_uc_istarn_ints with record status N
8657      Known limitations,enhancements,remarks:
8658      Change History
8659      Who       When         What
8660     ***************************************************************** */
8661 
8662      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8663       -- or get all the records in hercules view if the timestamp passed is null
8664       CURSOR c_ivnstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8665       SELECT  appno
8666             ,timestamp
8667             ,UPPER(RTRIM(title)) title
8668             ,RTRIM(forenames) forenames
8669             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8670             ,birthdate
8671             ,sex
8672       FROM  igs_uc_ivnstarn_2006_v
8673       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8674 
8675       -- get the max timestamp value of the hercules view
8676       CURSOR c_max_timestamp IS
8677       SELECT MAX(timestamp)
8678       FROM igs_uc_ivnstarn_2006_v  ;
8679 
8680       -- Variables
8681       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8682       l_new_max_timestamp igs_uc_ivnstarn_2006_v.timestamp%TYPE ;
8683       l_count NUMBER ;
8684 
8685       l_appno      igs_uc_istarn_ints.appno%TYPE;
8686       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8687 
8688   BEGIN
8689        -- set syncronization required to false
8690        g_sync_reqd := FALSE;
8691        l_count := 0 ;
8692 
8693       -- log message that this view is being loaded
8694        log_start('IVNSTARN ON ' ) ;
8695 
8696       -- Get the old timestamp for this view in the configured cycle
8697       Herc_timestamp_exists('IVNSTARN',  p_old_timestamp) ;
8698 
8699        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8700        FOR c_ivnstarn_rec IN c_ivnstarn(p_old_timestamp) LOOP
8701               -- set x_sync_read to true if the loop is entered even once
8702               g_sync_reqd := TRUE;
8703 
8704               IF  is_valid(c_ivnstarn_rec.appno,'IVNSTARN','APPNO','NUMBER') THEN
8705 
8706                   -- Determine actual appno and checkdigit
8707                   get_appno(c_ivnstarn_rec.appno, NULL, l_appno, l_checkdigit);
8708 
8709                   -- Obsolete matching records in interface table with status N / I
8710                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8711                   WHERE record_status = 'N' AND appno = l_appno  ;
8712 
8713                   -- copy hercules record into interface table with record status N
8714                   INSERT INTO igs_uc_istarn_ints (  appno,
8715                                                     checkdigit,
8716                                                     title,
8717                                                     forenames,
8718                                                     surname,
8719                                                     birthdate,
8720                                                     sex,
8721                                                     ad_batch_id,
8722                                                     ad_interface_id,
8723                                                     ad_api_id,
8724                                                     record_status,
8725                                                     error_code
8726                                                      )
8727                                          VALUES (   l_appno,
8728                                                     l_checkdigit,
8729                                                     c_ivnstarn_rec.title,
8730                                                     c_ivnstarn_rec.forenames,
8731                                                     c_ivnstarn_rec.surname,
8732                                                     c_ivnstarn_rec.birthdate,
8733                                                     c_ivnstarn_rec.sex,
8734                                                     NULL,
8735                                                     NULL,
8736                                                     NULL,
8737                                                     'N',
8738                                                     NULL
8739                                                      ) ;
8740                   -- increment count of records
8741                   l_count := l_count + 1;
8742 
8743               END IF;
8744 
8745        END LOOP ;
8746 
8747       IF g_sync_reqd THEN
8748               -- get the max timestamp of this hercules view
8749               OPEN c_max_timestamp ;
8750               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8751               CLOSE c_max_timestamp ;
8752 
8753                -- update /insert the timestamp record with new max timestamp
8754                ins_upd_timestamp ('IVNSTARN', l_new_max_timestamp) ;
8755 
8756               -- log message that this view has been loaded
8757                log_complete('IVNSTARN', l_count ) ;
8758       ELSE
8759                 -- log message that this view is already in sync and need not be loaded
8760                log_already_insync('IVNSTARN') ;
8761       END IF ;
8762       COMMIT;
8763 
8764   EXCEPTION
8765       WHEN OTHERS THEN
8766                ROLLBACK;
8767                write_to_log(SQLERRM);
8768                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8769                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARN_2006');
8770                igs_ge_msg_stack.add;
8771                app_exception.raise_exception ;
8772   END   load_ivnstarn_2006  ;
8773 
8774   PROCEDURE load_ivnstarn_2007 IS
8775     /******************************************************************
8776      Created By      :  jbaber
8777      Date Created By :  11-Jul-06
8778      Purpose         :  loads each record in the hercules view ivnstarn into the interface table
8779                         igs_uc_istarn_ints with record status N
8780      Known limitations,enhancements,remarks:
8781      Change History
8782      Who       When         What
8783     ***************************************************************** */
8784 
8785      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8786       -- or get all the records in hercules view if the timestamp passed is null
8787       CURSOR c_ivnstarn ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8788       SELECT  appno
8789             ,personalid
8790             ,timestamp
8791             ,UPPER(RTRIM(title)) title
8792             ,RTRIM(forenames) forenames
8793             ,DECODE(RTRIM(surname),NULL, RPAD('*',LENGTH(surname),'*'), RTRIM(surname)) surname
8794             ,birthdate
8795             ,sex
8796       FROM  igs_uc_ivnstarn_2007_v
8797       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8798 
8799       -- get the max timestamp value of the hercules view
8800       CURSOR c_max_timestamp IS
8801       SELECT MAX(timestamp)
8802       FROM igs_uc_ivnstarn_2007_v  ;
8803 
8804       -- Variables
8805       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8806       l_new_max_timestamp igs_uc_ivnstarn_2007_v.timestamp%TYPE ;
8807       l_count NUMBER ;
8808 
8809       l_appno      igs_uc_istarn_ints.appno%TYPE;
8810       l_checkdigit igs_uc_istarn_ints.checkdigit%TYPE;
8811 
8812   BEGIN
8813        -- set syncronization required to false
8814        g_sync_reqd := FALSE;
8815        l_count := 0 ;
8816 
8817       -- log message that this view is being loaded
8818        log_start('IVNSTARN ON ' ) ;
8819 
8820       -- Get the old timestamp for this view in the configured cycle
8821       Herc_timestamp_exists('IVNSTARN',  p_old_timestamp) ;
8822 
8823        -- create interface records for each record in the hercules view whose timestamp > old timestamp
8824        FOR c_ivnstarn_rec IN c_ivnstarn(p_old_timestamp) LOOP
8825               -- set x_sync_read to true if the loop is entered even once
8826               g_sync_reqd := TRUE;
8827 
8828               IF  is_valid(c_ivnstarn_rec.appno,'IVNSTARN','APPNO','NUMBER') THEN
8829 
8830                   -- Determine actual appno and checkdigit
8831                   get_appno(c_ivnstarn_rec.appno, NULL, l_appno, l_checkdigit);
8832 
8833                   -- Obsolete matching records in interface table with status N / I
8834                   UPDATE igs_uc_istarn_ints SET record_status = 'O'
8835                   WHERE record_status = 'N' AND appno = l_appno  ;
8836 
8837                   -- copy hercules record into interface table with record status N
8838                   INSERT INTO igs_uc_istarn_ints (  appno,
8839                                                     checkdigit,
8840                                                     personalid,
8841                                                     title,
8842                                                     forenames,
8843                                                     surname,
8844                                                     birthdate,
8845                                                     sex,
8846                                                     ad_batch_id,
8847                                                     ad_interface_id,
8848                                                     ad_api_id,
8849                                                     record_status,
8850                                                     error_code
8851                                                      )
8852                                          VALUES (   l_appno,
8853                                                     l_checkdigit,
8854                                                     c_ivnstarn_rec.personalid,
8855                                                     c_ivnstarn_rec.title,
8856                                                     c_ivnstarn_rec.forenames,
8857                                                     c_ivnstarn_rec.surname,
8858                                                     c_ivnstarn_rec.birthdate,
8859                                                     c_ivnstarn_rec.sex,
8860                                                     NULL,
8861                                                     NULL,
8862                                                     NULL,
8863                                                     'N',
8864                                                     NULL
8865                                                      ) ;
8866                   -- increment count of records
8867                   l_count := l_count + 1;
8868 
8869               END IF;
8870 
8871        END LOOP ;
8872 
8873       IF g_sync_reqd THEN
8874               -- get the max timestamp of this hercules view
8875               OPEN c_max_timestamp ;
8876               FETCH c_max_timestamp INTO l_new_max_timestamp ;
8877               CLOSE c_max_timestamp ;
8878 
8879                -- update /insert the timestamp record with new max timestamp
8880                ins_upd_timestamp ('IVNSTARN', l_new_max_timestamp) ;
8881 
8882               -- log message that this view has been loaded
8883                log_complete('IVNSTARN', l_count ) ;
8884       ELSE
8885                 -- log message that this view is already in sync and need not be loaded
8886                log_already_insync('IVNSTARN') ;
8887       END IF ;
8888       COMMIT;
8889 
8890   EXCEPTION
8891       WHEN OTHERS THEN
8892                ROLLBACK;
8893                write_to_log(SQLERRM);
8894                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
8895                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARN_2007');
8896                igs_ge_msg_stack.add;
8897                app_exception.raise_exception ;
8898   END   load_ivnstarn_2007  ;
8899 
8900 
8901   PROCEDURE load_ivstarpqr_2003  IS
8902     /******************************************************************
8903      Created By      :  smaddali
8904      Date Created By :   11-Jun-03
8905      Purpose         :     loads each record in the hercules view ivstarpqr into the interface table
8906                            igs_uc_istrpqr_ints with record status N
8907      Known limitations,enhancements,remarks:
8908      Change History
8909      Who       When         What
8910      smaddali  4-sep-03   Modified logic to base loading on ivqualification.timestamp and
8911                           to obsolete New records in Interface table, for bug#3122898
8912     ***************************************************************** */
8913 
8914       -- Get all the records from hercules  view whose timestamp is > passed timestamp
8915       -- or get all the records in hercules view if the timestamp passed is null
8916       CURSOR c_ivqual ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
8917       SELECT appno
8918       FROM igs_uc_ivqualification_2003_v
8919       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
8920 
8921      -- Get all the records from hercules  view whose timestamp is > passed timestamp
8922       -- or get all the records in hercules view if the timestamp passed is null
8923       CURSOR c_ivstarpqr (cp_appno igs_uc_ivstarpqr_2003_v.appno%TYPE )  IS
8924       SELECT  appno
8925         ,timestamp
8926         ,subjectid
8927         ,RTRIM(eblresult) eblresult
8928         ,RTRIM(eblamended) eblamended
8929         ,RTRIM(claimedresult) claimedresult
8930       FROM  igs_uc_ivstarpqr_2003_v
8931       WHERE appno = cp_appno ;
8932 
8933       -- Variables
8934       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
8935       l_count NUMBER ;
8936 
8937       l_appno_qual      igs_uc_ivqualification_2003_v.appno%TYPE;
8938       l_checkdigit_qual NUMBER;
8939       l_appno           igs_uc_istrpqr_ints.appno%TYPE;
8940       l_checkdigit      NUMBER;
8941 
8942   BEGIN
8943        -- set syncronization required to false
8944        g_sync_reqd := FALSE;
8945        l_count := 0 ;
8946 
8947       -- log message that this view is being loaded
8948        log_start( 'IVSTARPQR ON ') ;
8949 
8950       -- smaddali modified logic to load ivstarpqr records based on ivqualification timestamp
8951       -- instead of ivstarpqr timestamp , for bug#3122898
8952       -- Get the old timestamp for this view in the configured cycle
8953       Herc_timestamp_exists('IVQUALIFICATION', p_old_timestamp) ;
8954 
8955        -- for each record in the IVQUALIFICATION hercules view whose timestamp > old timestamp of ivqualification
8956        -- load the StarPQR records belonging to this applicant irrespective of the ivstarpqr timestamp
8957        FOR c_ivqual_rec IN c_ivqual(p_old_timestamp) LOOP
8958 
8959              IF  is_valid(c_ivqual_rec.appno,'IVQUALIFICATION','APPNO','NUMBER') THEN
8960 
8961                  -- Determine actual appno
8962                  get_appno(c_ivqual_rec.appno, NULL, l_appno_qual, l_checkdigit_qual);
8963 
8964                   -- smaddali added code to obsolete existing records in starpqr interface table with status N for this applicant, for bug#3122898
8965                   -- Obsolete all records in interface table for this applicant with status N
8966                   UPDATE igs_uc_istrpqr_ints SET record_status = 'O' , error_code = NULL
8967                   WHERE record_status = 'N'  AND appno = l_appno_qual ;
8968 
8969                   -- set all records in interface table for this applicant with status L to processed status
8970                   UPDATE igs_uc_istrpqr_ints SET record_status = 'D' , error_code = NULL
8971                   WHERE record_status = 'L'  AND appno = l_appno_qual ;
8972 
8973                    -- create interface records for each record in the hercules view whose timestamp > old timestamp
8974                    FOR c_ivstarpqr_rec IN c_ivstarpqr(c_ivqual_rec.appno) LOOP
8975                           -- set x_sync_read to true if the loop is entered even once
8976                           g_sync_reqd := TRUE;
8977 
8978                           IF  is_valid(c_ivstarpqr_rec.appno,'IVSTARPQR','APPNO','NUMBER') THEN
8979 
8980                               -- Determine actual appno
8981                               get_appno(c_ivstarpqr_rec.appno, NULL, l_appno, l_checkdigit);
8982 
8983                               -- copy hercules record into interface table with record status N
8984                               INSERT INTO igs_uc_istrpqr_ints ( appno,
8985                                                                 subjectid,
8986                                                                 eblresult,
8987                                                                 eblamended,
8988                                                                 claimedresult,
8989                                                                 yearofexam,
8990                                                                 sitting,
8991                                                                 examboard,
8992                                                                 eblsubject,
8993                                                                 grade,
8994                                                                 grade1,
8995                                                                 grade2,
8996                                                                 lendingboard,
8997                                                                 matchind,
8998                                                                 marvin_type,
8999                                                                 record_status,
9000                                                                 error_code
9001                                                                  )
9002                                                      VALUES (   l_appno,
9003                                                                 c_ivstarpqr_rec.subjectid,
9004                                                                 c_ivstarpqr_rec.eblresult,
9005                                                                 c_ivstarpqr_rec.eblamended,
9006                                                                 c_ivstarpqr_rec.claimedresult,
9007                                                                 NULL,
9008                                                                 NULL,
9009                                                                 NULL,
9010                                                                 NULL,
9011                                                                 NULL,
9012                                                                 NULL,
9013                                                                 NULL,
9014                                                                 NULL,
9015                                                                 NULL,
9016                                                                 NULL,
9017                                                                 'N',
9018                                                                 NULL
9019                                                                  ) ;
9020                                 -- increment count of records
9021                                 l_count := l_count + 1;
9022 
9023                           END IF;
9024 
9025                    END LOOP ; -- ivstarpqr loop
9026 
9027              END IF;
9028 
9029       END LOOP; -- ivqualifcation applicants loop
9030 
9031       IF g_sync_reqd THEN
9032               -- log message that this view has been loaded
9033                log_complete( 'IVSTARPQR', l_count) ;
9034       ELSE
9035                 -- log message that this view is already in sync and need not be loaded
9036                log_already_insync('IVSTARPQR') ;
9037       END IF;
9038       COMMIT;
9039 
9040   EXCEPTION
9041       WHEN OTHERS THEN
9042                ROLLBACK;
9043                write_to_log(SQLERRM);
9044                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9045                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARPQR_2003');
9046                igs_ge_msg_stack.add;
9047                app_exception.raise_exception ;
9048   END  load_ivstarpqr_2003   ;
9049 
9050 
9051   PROCEDURE load_ivstarpqr_2006  IS
9052     /******************************************************************
9053      Created By      :  anwest
9054      Date Created By :  25-MAY-2006
9055      Purpose         :  Bug #5190520 UCTD320 - UCAS 2006 CLEARING ISSUES
9056                         Loads each record in the hercules view
9057                         ivstarpqr into the interface table
9058                         igs_uc_istrpqr_ints with record status N
9059 
9060      Known limitations,enhancements,remarks:
9061      Change History
9062      Who       When         What
9063 
9064     ***************************************************************** */
9065 
9066       -- Get all the records from hercules  view whose timestamp is > passed timestamp
9067       -- or get all the records in hercules view if the timestamp passed is null
9068       CURSOR c_ivqual ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9069       SELECT appno
9070       FROM igs_uc_ivqualification_2003_v
9071       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9072 
9073      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9074       -- or get all the records in hercules view if the timestamp passed is null
9075       CURSOR c_ivstarpqr (cp_appno igs_uc_ivstarpqr_2003_v.appno%TYPE )  IS
9076       SELECT  appno
9077         ,timestamp
9078         ,subjectid
9079         ,RTRIM(eblresult) eblresult
9080       FROM  igs_uc_ivstarpqr_2003_v
9081       WHERE appno = cp_appno ;
9082 
9083       -- Variables
9084       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9085       l_count NUMBER ;
9086 
9087       l_appno_qual      igs_uc_ivqualification_2003_v.appno%TYPE;
9088       l_checkdigit_qual NUMBER;
9089       l_appno           igs_uc_istrpqr_ints.appno%TYPE;
9090       l_checkdigit      NUMBER;
9091 
9092   BEGIN
9093        -- set syncronization required to false
9094        g_sync_reqd := FALSE;
9095        l_count := 0 ;
9096 
9097       -- log message that this view is being loaded
9098        log_start( 'IVSTARPQR ON ') ;
9099 
9100       -- smaddali modified logic to load ivstarpqr records based on ivqualification timestamp
9101       -- instead of ivstarpqr timestamp , for bug#3122898
9102       -- Get the old timestamp for this view in the configured cycle
9103       Herc_timestamp_exists('IVQUALIFICATION', p_old_timestamp) ;
9104 
9105        -- for each record in the IVQUALIFICATION hercules view whose timestamp > old timestamp of ivqualification
9106        -- load the StarPQR records belonging to this applicant irrespective of the ivstarpqr timestamp
9107        FOR c_ivqual_rec IN c_ivqual(p_old_timestamp) LOOP
9108 
9109              IF  is_valid(c_ivqual_rec.appno,'IVQUALIFICATION','APPNO','NUMBER') THEN
9110 
9111                  -- Determine actual appno
9112                  get_appno(c_ivqual_rec.appno, NULL, l_appno_qual, l_checkdigit_qual);
9113 
9114                   -- smaddali added code to obsolete existing records in starpqr interface table with status N for this applicant, for bug#3122898
9115                   -- Obsolete all records in interface table for this applicant with status N
9116                   UPDATE igs_uc_istrpqr_ints SET record_status = 'O' , error_code = NULL
9117                   WHERE record_status = 'N'  AND appno = l_appno_qual ;
9118 
9119                   -- set all records in interface table for this applicant with status L to processed status
9120                   UPDATE igs_uc_istrpqr_ints SET record_status = 'D' , error_code = NULL
9121                   WHERE record_status = 'L'  AND appno = l_appno_qual ;
9122 
9123                    -- create interface records for each record in the hercules view whose timestamp > old timestamp
9124                    FOR c_ivstarpqr_rec IN c_ivstarpqr(c_ivqual_rec.appno) LOOP
9125                           -- set x_sync_read to true if the loop is entered even once
9126                           g_sync_reqd := TRUE;
9127 
9128                           IF  is_valid(c_ivstarpqr_rec.appno,'IVSTARPQR','APPNO','NUMBER') THEN
9129 
9130                               -- Determine actual appno
9131                               get_appno(c_ivstarpqr_rec.appno, NULL, l_appno, l_checkdigit);
9132 
9133                               -- copy hercules record into interface table with record status N
9134                               INSERT INTO igs_uc_istrpqr_ints ( appno,
9135                                                                 subjectid,
9136                                                                 eblresult,
9137                                                                 eblamended,
9138                                                                 claimedresult,
9139                                                                 yearofexam,
9140                                                                 sitting,
9141                                                                 examboard,
9142                                                                 eblsubject,
9143                                                                 grade,
9144                                                                 grade1,
9145                                                                 grade2,
9146                                                                 lendingboard,
9147                                                                 matchind,
9148                                                                 marvin_type,
9149                                                                 record_status,
9150                                                                 error_code
9151                                                                  )
9152                                                      VALUES (   l_appno,
9153                                                                 c_ivstarpqr_rec.subjectid,
9154                                                                 c_ivstarpqr_rec.eblresult,
9155                                                                 NULL,
9156                                                                 NULL,
9157                                                                 NULL,
9158                                                                 NULL,
9159                                                                 NULL,
9160                                                                 NULL,
9161                                                                 NULL,
9162                                                                 NULL,
9163                                                                 NULL,
9164                                                                 NULL,
9165                                                                 NULL,
9166                                                                 NULL,
9167                                                                 'N',
9168                                                                 NULL
9169                                                                  ) ;
9170                                 -- increment count of records
9171                                 l_count := l_count + 1;
9172 
9173                           END IF;
9174 
9175                    END LOOP ; -- ivstarpqr loop
9176 
9177              END IF;
9178 
9179       END LOOP; -- ivqualifcation applicants loop
9180 
9181       IF g_sync_reqd THEN
9182               -- log message that this view has been loaded
9183                log_complete( 'IVSTARPQR', l_count) ;
9184       ELSE
9185                 -- log message that this view is already in sync and need not be loaded
9186                log_already_insync('IVSTARPQR') ;
9187       END IF;
9188       COMMIT;
9189 
9190   EXCEPTION
9191       WHEN OTHERS THEN
9192                ROLLBACK;
9193                write_to_log(SQLERRM);
9194                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9195                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARPQR_2006');
9196                igs_ge_msg_stack.add;
9197                app_exception.raise_exception ;
9198   END  load_ivstarpqr_2006;
9199 
9200 
9201   PROCEDURE load_ivstarw_2003 IS
9202     /******************************************************************
9203      Created By      :  smaddali
9204      Date Created By :   11-Jun-03
9205      Purpose         :     loads each record in the hercules view ivstarw into the interface table
9206                            igs_uc_istarw_ints with record status N
9207      Known limitations,enhancements,remarks:
9208      Change History
9209      Who       When         What
9210     ***************************************************************** */
9211 
9212      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9213       -- or get all the records in hercules view if the timestamp passed is null
9214       CURSOR c_ivstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9215       SELECT  appno
9216        , timestamp
9217        , RTRIM(miscoded) miscoded
9218        , RTRIM(cancelled) cancelled
9219        , canceldate
9220        , RTRIM(remark) remark
9221        , RTRIM(jointadmission) jointadmission
9222       FROM  igs_uc_ivstarw_2003_v
9223       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9224 
9225       -- get the max timestamp value of the hercules view
9226       CURSOR c_max_timestamp IS
9227       SELECT MAX(timestamp)
9228       FROM igs_uc_ivstarw_2003_v  ;
9229 
9230       -- Variables
9231       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9232       l_new_max_timestamp igs_uc_ivstarw_2003_v.timestamp%TYPE ;
9233       l_count NUMBER ;
9234 
9235   BEGIN
9236        -- set syncronization required to false
9237        g_sync_reqd := FALSE;
9238        l_count := 0 ;
9239 
9240       -- log message that this view is being loaded
9241        log_start('IVSTARW ON ') ;
9242 
9243       -- Get the old timestamp for this view in the configured cycle
9244       Herc_timestamp_exists('IVSTARW', p_old_timestamp) ;
9245 
9246        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9247        FOR c_ivstarw_rec IN c_ivstarw(p_old_timestamp) LOOP
9248               -- set x_sync_read to true if the loop is entered even once
9249               g_sync_reqd := TRUE;
9250 
9251               -- Obsolete matching records in interface table with status N
9252               UPDATE igs_uc_istarw_ints SET record_status = 'O'
9253               WHERE record_status = 'N' AND appno = c_ivstarw_rec.appno ;
9254 
9255               -- copy hercules record into interface table with record status N
9256               INSERT INTO igs_uc_istarw_ints (   appno,
9257                                                  miscoded,
9258                                                  cancelled,
9259                                                  jointadmission,
9260                                                  choice1lost,
9261                                                  choice2lost,
9262                                                  choice3lost,
9263                                                  choice4lost,
9264                                                  choice5lost,
9265                                                  choice6lost,
9266                                                  choice7lost,
9267                                                  canceldate,
9268                                                  remark,
9269                                                 record_status,
9270                                                 error_code
9271                                                  )
9272                                      VALUES (    c_ivstarw_rec.appno,
9273                                                  c_ivstarw_rec.miscoded,
9274                                                  c_ivstarw_rec.cancelled,
9275                                                  c_ivstarw_rec.jointadmission,
9276                                                  'N',
9277                                                  'N',
9278                                                  'N',
9279                                                  'N',
9280                                                  'N',
9281                                                  'N',
9282                                                  'N',
9283                                                  c_ivstarw_rec.canceldate,
9284                                                  c_ivstarw_rec.remark,
9285                                                 'N',
9286                                                 NULL
9287                                                  ) ;
9288         -- increment count of records
9289         l_count := l_count + 1;
9290 
9291        END LOOP ;
9292 
9293       IF g_sync_reqd THEN
9294               -- get the max timestamp of this hercules view
9295               OPEN c_max_timestamp ;
9296               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9297               CLOSE c_max_timestamp ;
9298 
9299                -- update /insert the timestamp record with new max timestamp
9300                ins_upd_timestamp ('IVSTARW',  l_new_max_timestamp) ;
9301 
9302               -- log message that this view has been loaded
9303                log_complete('IVSTARW', l_count) ;
9304       ELSE
9305                 -- log message that this view is already in sync and need not be loaded
9306                log_already_insync('IVSTARW') ;
9307       END IF ;
9308       COMMIT;
9309 
9310   EXCEPTION
9311       WHEN OTHERS THEN
9312                ROLLBACK;
9313                write_to_log(SQLERRM);
9314                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9315                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARW_2003');
9316                igs_ge_msg_stack.add;
9317                app_exception.raise_exception ;
9318   END   load_ivstarw_2003  ;
9319 
9320   PROCEDURE load_ivstarx_2003 IS
9321     /******************************************************************
9322      Created By      :  smaddali
9323      Date Created By :   11-Jun-03
9324      Purpose         :     loads each record in the hercules view ivstarx into the interface table
9325                            igs_uc_istarx_ints with record status N
9326      Known limitations,enhancements,remarks:
9327      Change History
9328      Who       When         What
9329     ***************************************************************** */
9330 
9331      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9332       -- or get all the records in hercules view if the timestamp passed is null
9333       CURSOR c_ivstarx ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9334       SELECT  appno
9335            ,timestamp
9336            ,ethnic
9337            ,pocceduchangedate
9338            ,socialclass
9339            ,RTRIM(pocc) pocc
9340            ,RTRIM(pocctext) pocctext
9341            ,RTRIM(socioeconomic) socioeconomic
9342            ,RTRIM(occbackground) occbackground
9343       FROM  igs_uc_ivstarx_2003_v
9344       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9345 
9346       -- get the max timestamp value of the hercules view
9347       CURSOR c_max_timestamp IS
9348       SELECT MAX(timestamp)
9349       FROM igs_uc_ivstarx_2003_v  ;
9350 
9351       -- Variables
9352       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9353       l_new_max_timestamp igs_uc_ivstarx_2003_v.timestamp%TYPE ;
9354       l_count NUMBER ;
9355 
9356       l_appno      igs_uc_istarx_ints.appno%TYPE;
9357       l_checkdigit NUMBER;
9358 
9359   BEGIN
9360        -- set syncronization required to false
9361        g_sync_reqd := FALSE;
9362        l_count := 0 ;
9363 
9364       -- log message that this view is being loaded
9365        log_start('IVSTARX ON ' ) ;
9366 
9367       -- Get the old timestamp for this view in the configured cycle
9368       Herc_timestamp_exists('IVSTARX',  p_old_timestamp) ;
9369 
9370        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9371        FOR c_ivstarx_rec IN c_ivstarx(p_old_timestamp) LOOP
9372               -- set x_sync_read to true if the loop is entered even once
9373               g_sync_reqd := TRUE;
9374 
9375              --Validate varchar to number conversion
9376              IF  is_valid(c_ivstarx_rec.appno,'IVSTARX','APPNO','NUMBER') AND
9377                  is_valid(c_ivstarx_rec.ethnic,'IVSTARX','Ethnic','NUMBER') THEN
9378 
9379                   -- Determine actual appno
9380                   get_appno(c_ivstarx_rec.appno, NULL, l_appno, l_checkdigit);
9381 
9382                   -- Obsolete matching records in interface table with status N
9383                   UPDATE igs_uc_istarx_ints SET record_status = 'O'
9384                   WHERE record_status = 'N' AND appno = l_appno ;
9385 
9386                   -- copy hercules record into interface table with record status N
9387                   INSERT INTO igs_uc_istarx_ints (  appno,
9388                                                     ethnic,
9389                                                     pocceduchangedate,
9390                                                     socialclass,
9391                                                     pocc,
9392                                                     pocctext,
9393                                                     socioeconomic,
9394                                                     occbackground,
9395                                                     religion,
9396                                                     dependants,
9397                                                     married,
9398                                                     record_status,
9399                                                     error_code
9400                                                      )
9401                                          VALUES (   l_appno,
9402                                                     c_ivstarx_rec.ethnic,
9403                                                     c_ivstarx_rec.pocceduchangedate,
9404                                                     c_ivstarx_rec.socialclass,
9405                                                     c_ivstarx_rec.pocc,
9406                                                     c_ivstarx_rec.pocctext,
9407                                                     c_ivstarx_rec.socioeconomic,
9408                                                     c_ivstarx_rec.occbackground,
9409                                                     NULL,
9410                                                     NULL,
9411                                                     NULL,
9412                                                     'N',
9413                                                     NULL
9414                                                      ) ;
9415                   -- increment count of records
9416                   l_count := l_count + 1;
9417 
9418               END IF;
9419 
9420        END LOOP ;
9421 
9422       IF g_sync_reqd THEN
9423               -- get the max timestamp of this hercules view
9424               OPEN c_max_timestamp ;
9425               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9426               CLOSE c_max_timestamp ;
9427 
9428                -- update /insert the timestamp record with new max timestamp
9429                ins_upd_timestamp ('IVSTARX',  l_new_max_timestamp) ;
9430 
9431               -- log message that this view has been loaded
9432                log_complete('IVSTARX' , l_count) ;
9433       ELSE
9434                 -- log message that this view is already in sync and need not be loaded
9435                log_already_insync('IVSTARX') ;
9436       END IF ;
9437       COMMIT;
9438 
9439   EXCEPTION
9440       WHEN OTHERS THEN
9441                ROLLBACK;
9442                write_to_log(SQLERRM);
9443                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9444                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARX_2003');
9445                igs_ge_msg_stack.add;
9446                app_exception.raise_exception ;
9447   END    load_ivstarx_2003 ;
9448 
9449 
9450   PROCEDURE load_ivgstarx_2006 IS
9451     /******************************************************************
9452      Created By      :  jbaber
9453      Date Created By :  16-Aug-05
9454      Purpose         :  loads each record in the hercules view ivgstarx into the interface table
9455                         igs_uc_istarx_ints with record status N
9456      Known limitations,enhancements,remarks:
9457      Change History
9458      Who       When         What
9459     ***************************************************************** */
9460 
9461      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9462       -- or get all the records in hercules view if the timestamp passed is null
9463       CURSOR c_ivgstarx ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9464       SELECT  appno
9465            ,timestamp
9466            ,ethnic
9467       FROM  igs_uc_ivgstarx_2006_v
9468       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9469 
9470       -- get the max timestamp value of the hercules view
9471       CURSOR c_max_timestamp IS
9472       SELECT MAX(timestamp)
9473       FROM igs_uc_ivgstarx_2006_v  ;
9474 
9475       -- Variables
9476       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9477       l_new_max_timestamp igs_uc_ivgstarx_2006_v.timestamp%TYPE ;
9478       l_count NUMBER ;
9479 
9480       l_appno      igs_uc_istarx_ints.appno%TYPE;
9481       l_checkdigit NUMBER;
9482 
9483   BEGIN
9484        -- set syncronization required to false
9485        g_sync_reqd := FALSE;
9486        l_count := 0 ;
9487 
9488       -- log message that this view is being loaded
9489        log_start('IVGSTARX ON ' ) ;
9490 
9491       -- Get the old timestamp for this view in the configured cycle
9492       Herc_timestamp_exists('IVGSTARX',  p_old_timestamp) ;
9493 
9494        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9495        FOR c_ivgstarx_rec IN c_ivgstarx(p_old_timestamp) LOOP
9496               -- set x_sync_read to true if the loop is entered even once
9497               g_sync_reqd := TRUE;
9498 
9499              --Validate varchar to number conversion
9500              IF  is_valid(c_ivgstarx_rec.appno,'IVGSTARX','APPNO','NUMBER') AND
9501                  is_valid(c_ivgstarx_rec.ethnic,'IVGSTARX','Ethnic','NUMBER') THEN
9502 
9503                   -- Determine actual appno
9504                   get_appno(c_ivgstarx_rec.appno, NULL, l_appno, l_checkdigit);
9505 
9506                   -- Obsolete matching records in interface table with status N
9507                   UPDATE igs_uc_istarx_ints SET record_status = 'O'
9508                   WHERE record_status = 'N' AND appno = l_appno ;
9509 
9510                   -- copy hercules record into interface table with record status N
9511                   INSERT INTO igs_uc_istarx_ints (  appno,
9512                                                     ethnic,
9513                                                     record_status,
9514                                                     error_code
9515                                                      )
9516                                          VALUES (   l_appno,
9517                                                     c_ivgstarx_rec.ethnic,
9518                                                     'N',
9519                                                     NULL
9520                                                      ) ;
9521                   -- increment count of records
9522                   l_count := l_count + 1;
9523 
9524               END IF;
9525 
9526        END LOOP ;
9527 
9528       IF g_sync_reqd THEN
9529               -- get the max timestamp of this hercules view
9530               OPEN c_max_timestamp ;
9531               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9532               CLOSE c_max_timestamp ;
9533 
9534                -- update /insert the timestamp record with new max timestamp
9535                ins_upd_timestamp ('IVGSTARX',  l_new_max_timestamp) ;
9536 
9537               -- log message that this view has been loaded
9538                log_complete('IVGSTARX' , l_count) ;
9539       ELSE
9540                 -- log message that this view is already in sync and need not be loaded
9541                log_already_insync('IVGSTARX') ;
9542       END IF ;
9543       COMMIT;
9544 
9545   EXCEPTION
9546       WHEN OTHERS THEN
9547                ROLLBACK;
9548                write_to_log(SQLERRM);
9549                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9550                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARX_2006');
9551                igs_ge_msg_stack.add;
9552                app_exception.raise_exception ;
9553   END    load_ivgstarx_2006 ;
9554 
9555 
9556   PROCEDURE load_ivnstarx_2006 IS
9557     /******************************************************************
9558      Created By      :  jbaber
9559      Date Created By :  16-Aug-05
9560      Purpose         :  loads each record in the hercules view ivnstarx into the interface table
9561                         igs_uc_istarx_ints with record status N
9562      Known limitations,enhancements,remarks:
9563      Change History
9564      Who       When         What
9565     ***************************************************************** */
9566 
9567      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9568       -- or get all the records in hercules view if the timestamp passed is null
9569       CURSOR c_ivnstarx ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9570       SELECT  appno
9571            ,timestamp
9572            ,ethnic
9573            ,numberdependants
9574            ,RTRIM(maritalstatus) maritalstatus
9575       FROM  igs_uc_ivnstarx_2006_v
9576       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9577 
9578       -- get the max timestamp value of the hercules view
9579       CURSOR c_max_timestamp IS
9580       SELECT MAX(timestamp)
9581       FROM igs_uc_ivnstarx_2006_v  ;
9582 
9583       -- Variables
9584       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9585       l_new_max_timestamp igs_uc_ivnstarx_2006_v.timestamp%TYPE ;
9586       l_count NUMBER ;
9587 
9588       l_appno      igs_uc_istarx_ints.appno%TYPE;
9589       l_checkdigit NUMBER;
9590 
9591   BEGIN
9592        -- set syncronization required to false
9593        g_sync_reqd := FALSE;
9594        l_count := 0 ;
9595 
9596       -- log message that this view is being loaded
9597        log_start('IVNSTARX ON ' ) ;
9598 
9599       -- Get the old timestamp for this view in the configured cycle
9600       Herc_timestamp_exists('IVNSTARX',  p_old_timestamp) ;
9601 
9602        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9603        FOR c_ivnstarx_rec IN c_ivnstarx(p_old_timestamp) LOOP
9604               -- set x_sync_read to true if the loop is entered even once
9605               g_sync_reqd := TRUE;
9606 
9607              --Validate varchar to number conversion
9608              IF  is_valid(c_ivnstarx_rec.appno,'IVNSTARX','APPNO','NUMBER') AND
9609                  is_valid(c_ivnstarx_rec.ethnic,'IVNSTARX','Ethnic','NUMBER') THEN
9610 
9611                   -- Determine actual appno
9612                   get_appno(c_ivnstarx_rec.appno, NULL, l_appno, l_checkdigit);
9613 
9614                   -- Obsolete matching records in interface table with status N
9615                   UPDATE igs_uc_istarx_ints SET record_status = 'O'
9616                   WHERE record_status = 'N' AND appno = l_appno ;
9617 
9618                   -- copy hercules record into interface table with record status N
9619                   INSERT INTO igs_uc_istarx_ints (  appno,
9620                                                     ethnic,
9621                                                     dependants,
9622                                                     married,
9623                                                     record_status,
9624                                                     error_code
9625                                                      )
9626                                          VALUES (   l_appno,
9627                                                     c_ivnstarx_rec.ethnic,
9628                                                     c_ivnstarx_rec.numberdependants,
9629                                                     c_ivnstarx_rec.maritalstatus,
9630                                                     'N',
9631                                                     NULL
9632                                                      ) ;
9633                   -- increment count of records
9634                   l_count := l_count + 1;
9635 
9636               END IF;
9637 
9638        END LOOP ;
9639 
9640       IF g_sync_reqd THEN
9641               -- get the max timestamp of this hercules view
9642               OPEN c_max_timestamp ;
9643               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9644               CLOSE c_max_timestamp ;
9645 
9646                -- update /insert the timestamp record with new max timestamp
9647                ins_upd_timestamp ('IVNSTARX',  l_new_max_timestamp) ;
9648 
9649               -- log message that this view has been loaded
9650                log_complete('IVNSTARX' , l_count) ;
9651       ELSE
9652                 -- log message that this view is already in sync and need not be loaded
9653                log_already_insync('IVNSTARX') ;
9654       END IF ;
9655       COMMIT;
9656 
9657   EXCEPTION
9658       WHEN OTHERS THEN
9659                ROLLBACK;
9660                write_to_log(SQLERRM);
9661                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9662                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARX_2006');
9663                igs_ge_msg_stack.add;
9664                app_exception.raise_exception ;
9665   END    load_ivnstarx_2006 ;
9666 
9667 
9668   PROCEDURE load_ivstarz1_2003 IS
9669     /******************************************************************
9670      Created By      :  smaddali
9671      Date Created By :   11-Jun-03
9672      Purpose         :    loads each record in the hercules view ivstarz1 into the interface table
9673                            igs_uc_istarz1_ints with record status N
9674      Known limitations,enhancements,remarks:
9675      Change History
9676      Who       When         What
9677      jbaber    15-Sep-05    Force 2-digit entry year for bug 4589994
9678      anwest    02-AUG-06    Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
9679     ***************************************************************** */
9680 
9681 
9682      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9683       -- or get all the records in hercules view if the timestamp passed is null
9684       CURSOR c_ivstarz1 ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9685       SELECT  appno
9686         ,timestamp
9687         ,datecefsent
9688         ,cefno
9689         ,RTRIM(centralclearing) centralclearing
9690         ,DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
9691         ,DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
9692         ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus -- 02-AUG-2006 anwest Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
9693         ,faculty
9694         ,SUBSTR(LPAD(entryyear,4,0),3,2) entryyear
9695         ,entrymonth
9696         ,RTRIM(entrypoint) entrypoint
9697         ,RTRIM(result) result
9698       FROM  igs_uc_ivstarz1_2003_v
9699       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9700 
9701       -- get the max timestamp value of the hercules view
9702       CURSOR c_max_timestamp IS
9703       SELECT MAX(timestamp)
9704       FROM igs_uc_ivstarz1_2003_v  ;
9705 
9706       -- Variables
9707       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9708       l_new_max_timestamp igs_uc_ivstarz1_2003_v.timestamp%TYPE ;
9709       l_count NUMBER ;
9710 
9711       l_appno      igs_uc_istarz1_ints.appno%TYPE;
9712       l_checkdigit NUMBER;
9713 
9714   BEGIN
9715        -- set syncronization required to false
9716        g_sync_reqd := FALSE;
9717        l_count := 0 ;
9718 
9719       -- log message that this view is being loaded
9720        log_start('IVSTARZ1 ON ') ;
9721 
9722       -- Get the old timestamp for this view in the configured cycle
9723       Herc_timestamp_exists('IVSTARZ1', p_old_timestamp) ;
9724 
9725        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9726        FOR c_ivstarz1_rec IN c_ivstarz1(p_old_timestamp) LOOP
9727               -- set x_sync_read to true if the loop is entered even once
9728               g_sync_reqd := TRUE;
9729 
9730               IF  is_valid(c_ivstarz1_rec.appno,'IVSTARZ1','APPNO','NUMBER') THEN
9731 
9732                   -- Determine actual appno
9733                   get_appno(c_ivstarz1_rec.appno, NULL, l_appno, l_checkdigit);
9734 
9735                   -- Obsolete matching records in interface table with status N
9736                   UPDATE igs_uc_istarz1_ints SET record_status = 'O'
9737                   WHERE record_status = 'N' AND appno = l_appno ;
9738 
9739                   -- copy hercules record into interface table with record status N
9740                   INSERT INTO igs_uc_istarz1_ints ( appno,
9741                                                     datecefsent,
9742                                                     cefno,
9743                                                     centralclearing,
9744                                                     inst,
9745                                                     course,
9746                                                     campus,
9747                                                     faculty,
9748                                                     entryyear,
9749                                                     entrymonth,
9750                                                     entrypoint,
9751                                                     result,
9752                                                     record_status,
9753                                                     error_code
9754                                                      )
9755                                          VALUES (   l_appno,
9756                                                     c_ivstarz1_rec.datecefsent,
9757                                                     c_ivstarz1_rec.cefno,
9758                                                     c_ivstarz1_rec.centralclearing,
9759                                                     c_ivstarz1_rec.inst,
9760                                                     c_ivstarz1_rec.course,
9761                                                     c_ivstarz1_rec.campus,
9762                                                     c_ivstarz1_rec.faculty,
9763                                                     c_ivstarz1_rec.entryyear,
9764                                                     c_ivstarz1_rec.entrymonth,
9765                                                     c_ivstarz1_rec.entrypoint,
9766                                                     c_ivstarz1_rec.result,
9767                                                     'N',
9768                                                     NULL
9769                                                      ) ;
9770                   -- increment count of records
9771                   l_count := l_count + 1;
9772 
9773               END IF;
9774 
9775        END LOOP ;
9776 
9777       IF g_sync_reqd THEN
9778               -- get the max timestamp of this hercules view
9779               OPEN c_max_timestamp ;
9780               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9781               CLOSE c_max_timestamp ;
9782 
9783                -- update /insert the timestamp record with new max timestamp
9784                ins_upd_timestamp ('IVSTARZ1', l_new_max_timestamp) ;
9785 
9786               -- log message that this view has been loaded
9787                log_complete('IVSTARZ1', l_count) ;
9788       ELSE
9789                 -- log message that this view is already in sync and need not be loaded
9790                log_already_insync('IVSTARZ1') ;
9791       END IF ;
9792       COMMIT;
9793 
9794   EXCEPTION
9795       WHEN OTHERS THEN
9796                ROLLBACK;
9797                write_to_log(SQLERRM);
9798                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9799                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARZ1_2003');
9800                igs_ge_msg_stack.add;
9801                app_exception.raise_exception ;
9802   END    load_ivstarz1_2003 ;
9803 
9804 
9805   PROCEDURE load_ivnstarz1_2006 IS
9806     /******************************************************************
9807      Created By      :  jbaber
9808      Date Created By :  16-Aug-05
9809      Purpose         :  loads each record in the hercules view ivnstarz1 into the interface table
9810                         igs_uc_istarz1_ints with record status N
9811      Known limitations,enhancements,remarks:
9812      Change History
9813      Who       When         What
9814      jbaber    29-Sep-05    Force 2-digit entry year for bug 4638126
9815     ***************************************************************** */
9816 
9817 
9818      -- Get all the records from hercules  view whose timestamp is > passed timestamp
9819       -- or get all the records in hercules view if the timestamp passed is null
9820       CURSOR c_ivnstarz1 ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9821       SELECT  appno
9822         ,timestamp
9823         ,cefno
9824         ,DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
9825         ,DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
9826         ,NVL(DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)),'*') campus -- 02-AUG-2006 anwest Bug #5440216 URGENT - UCAS CLEARING 2006 - PART 2 - CLEARING CHOICE NUMBER NULL
9827         ,SUBSTR(LPAD(entryyear,4,0),3,2) entryyear
9828         ,entrymonth
9829         ,RTRIM(result) result
9830       FROM  igs_uc_ivnstarz1_2006_v
9831       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9832 
9833       -- get the max timestamp value of the hercules view
9834       CURSOR c_max_timestamp IS
9835       SELECT MAX(timestamp)
9836       FROM igs_uc_ivnstarz1_2006_v  ;
9837 
9838       -- Variables
9839       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9840       l_new_max_timestamp igs_uc_ivnstarz1_2006_v.timestamp%TYPE ;
9841       l_count NUMBER ;
9842 
9843       l_appno      igs_uc_istarz1_ints.appno%TYPE;
9844       l_checkdigit NUMBER;
9845 
9846   BEGIN
9847        -- set syncronization required to false
9848        g_sync_reqd := FALSE;
9849        l_count := 0 ;
9850 
9851       -- log message that this view is being loaded
9852        log_start('IVNSTARZ1 ON ') ;
9853 
9854       -- Get the old timestamp for this view in the configured cycle
9855       Herc_timestamp_exists('IVNSTARZ1', p_old_timestamp) ;
9856 
9857        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9858        FOR c_ivnstarz1_rec IN c_ivnstarz1(p_old_timestamp) LOOP
9859               -- set x_sync_read to true if the loop is entered even once
9860               g_sync_reqd := TRUE;
9861 
9862               IF  is_valid(c_ivnstarz1_rec.appno,'IVNSTARZ1','APPNO','NUMBER') THEN
9863 
9864                   -- Determine actual appno
9865                   get_appno(c_ivnstarz1_rec.appno, NULL, l_appno, l_checkdigit);
9866 
9867                   -- Obsolete matching records in interface table with status N
9868                   UPDATE igs_uc_istarz1_ints SET record_status = 'O'
9869                   WHERE record_status = 'N' AND appno = l_appno ;
9870 
9871                   -- copy hercules record into interface table with record status N
9872                   INSERT INTO igs_uc_istarz1_ints ( appno,
9873                                                     cefno,
9874                                                     inst,
9875                                                     course,
9876                                                     campus,
9877                                                     entryyear,
9878                                                     entrymonth,
9879                                                     result,
9880                                                     record_status,
9881                                                     error_code
9882                                                      )
9883                                          VALUES (   l_appno,
9884                                                     c_ivnstarz1_rec.cefno,
9885                                                     c_ivnstarz1_rec.inst,
9886                                                     c_ivnstarz1_rec.course,
9887                                                     c_ivnstarz1_rec.campus,
9888                                                     c_ivnstarz1_rec.entryyear,
9889                                                     c_ivnstarz1_rec.entrymonth,
9890                                                     c_ivnstarz1_rec.result,
9891                                                     'N',
9892                                                     NULL
9893                                                      ) ;
9894                   -- increment count of records
9895                   l_count := l_count + 1;
9896 
9897               END IF;
9898 
9899        END LOOP ;
9900 
9901       IF g_sync_reqd THEN
9902               -- get the max timestamp of this hercules view
9903               OPEN c_max_timestamp ;
9904               FETCH c_max_timestamp INTO l_new_max_timestamp ;
9905               CLOSE c_max_timestamp ;
9906 
9907                -- update /insert the timestamp record with new max timestamp
9908                ins_upd_timestamp ('IVNSTARZ1', l_new_max_timestamp) ;
9909 
9910               -- log message that this view has been loaded
9911                log_complete('IVNSTARZ1', l_count) ;
9912       ELSE
9913                 -- log message that this view is already in sync and need not be loaded
9914                log_already_insync('IVNSTARZ1') ;
9915       END IF ;
9916       COMMIT;
9917 
9918   EXCEPTION
9919       WHEN OTHERS THEN
9920                ROLLBACK;
9921                write_to_log(SQLERRM);
9922                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
9926   END    load_ivnstarz1_2006 ;
9923                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARZ1_2006');
9924                igs_ge_msg_stack.add;
9925                app_exception.raise_exception ;
9927 
9928 
9929   PROCEDURE load_ivstarz2_2003 IS
9930     /******************************************************************
9931      Created By      :  smaddali
9932      Date Created By :   11-Jun-03
9933      Purpose         :    loads each record in the hercules view ivstarz2 into the interface table
9934                            igs_uc_istarz2_ints with record status N
9935      Known limitations,enhancements,remarks:
9936      Change History
9937      Who       When         What
9938     ***************************************************************** */
9939 
9940     -- Get all the records from hercules  view whose timestamp is > passed timestamp
9941       -- or get all the records in hercules view if the timestamp passed is null
9942       CURSOR c_ivstarz2 ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
9943       SELECT  appno
9944         , roundno
9945         , timestamp
9946         , DECODE(RTRIM(inst),NULL, RPAD('*',LENGTH(inst),'*'), RTRIM(inst)) inst
9947         , DECODE(RTRIM(course),NULL, RPAD('*',LENGTH(course),'*'), RTRIM(course)) course
9948         , DECODE(RTRIM(campus),NULL, RPAD('*',LENGTH(campus),'*'), RTRIM(campus)) campus
9949         , RTRIM(faculty) faculty
9950         , RTRIM(roundtype) roundtype
9951         , RTRIM(result) result
9952       FROM  igs_uc_ivstarz2_2003_v
9953       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
9954 
9955       -- get the max timestamp value of the hercules view
9956       CURSOR c_max_timestamp IS
9957       SELECT MAX(timestamp)
9958       FROM igs_uc_ivstarz2_2003_v  ;
9959 
9960       -- Variables
9961       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
9962       l_new_max_timestamp igs_uc_ivstarz2_2003_v.timestamp%TYPE ;
9963       l_count NUMBER ;
9964 
9965   BEGIN
9966        -- set syncronization required to false
9967        g_sync_reqd := FALSE;
9968        l_count := 0 ;
9969 
9970       -- log message that this view is being loaded
9971         log_start('IVSTARZ2 ON ' ) ;
9972 
9973       -- Get the old timestamp for this view in the configured cycle
9974       Herc_timestamp_exists('IVSTARZ2', p_old_timestamp) ;
9975 
9976        -- create interface records for each record in the hercules view whose timestamp > old timestamp
9977        FOR c_ivstarz2_rec IN c_ivstarz2(p_old_timestamp) LOOP
9978               -- set x_sync_read to true if the loop is entered even once
9979               g_sync_reqd := TRUE;
9980 
9981               -- Obsolete matching records in interface table with status N
9982              UPDATE igs_uc_istarz2_ints SET record_status = 'O'
9983              WHERE record_status = 'N' AND appno = c_ivstarz2_rec.appno
9984              AND inst = c_ivstarz2_rec.inst AND course = c_ivstarz2_rec.course
9985              AND campus = c_ivstarz2_rec.campus;
9986 
9987               -- copy hercules record into interface table with record status N
9988               INSERT INTO igs_uc_istarz2_ints ( appno,
9989                                                 roundno,
9990                                                 inst,
9991                                                 course,
9992                                                 campus,
9993                                                 faculty,
9994                                                 roundtype,
9995                                                 result,
9996                                                 record_status,
9997                                                 error_code
10001                                                 c_ivstarz2_rec.inst,
9998                                                  )
9999                                      VALUES (   c_ivstarz2_rec.appno,
10000                                                 c_ivstarz2_rec.roundno,
10002                                                 c_ivstarz2_rec.course,
10003                                                 c_ivstarz2_rec.campus,
10004                                                 c_ivstarz2_rec.faculty,
10005                                                 c_ivstarz2_rec.roundtype,
10006                                                 c_ivstarz2_rec.result,
10007                                                 'N',
10008                                                 NULL
10009                                                  ) ;
10010         -- increment count of records
10011         l_count := l_count + 1;
10012 
10013        END LOOP ;
10014 
10015        IF g_sync_reqd THEN
10016               -- get the max timestamp of this hercules view
10017               OPEN c_max_timestamp ;
10018               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10019               CLOSE c_max_timestamp ;
10020 
10021                -- update /insert the timestamp record with new max timestamp
10022                ins_upd_timestamp ('IVSTARZ2', l_new_max_timestamp) ;
10023 
10024               -- log message that this view has been loaded
10025                log_complete('IVSTARZ2', l_count ) ;
10026        ELSE
10027                 -- log message that this view is already in sync and need not be loaded
10028                log_already_insync('IVSTARZ2') ;
10029        END IF ;
10030       COMMIT;
10031 
10032   EXCEPTION
10033       WHEN OTHERS THEN
10034                ROLLBACK;
10035                write_to_log(SQLERRM);
10036                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10037                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARZ2_2003');
10038                igs_ge_msg_stack.add;
10039                app_exception.raise_exception ;
10040   END   load_ivstarz2_2003  ;
10041 
10042 
10043   PROCEDURE load_ivstatement_2003 IS
10044     /******************************************************************
10045      Created By      :  smaddali
10046      Date Created By :   11-Jun-03
10047      Purpose         :    loads each record in the hercules view ivstatement into the interface table
10048                            igs_uc_istmnt_ints with record status N
10049      Known limitations,enhancements,remarks:
10050      Change History
10051      Who       When         What
10052     ***************************************************************** */
10053         -- Get all the applicants whose personal statement is null
10054         CURSOR c_stmt_appno IS
10055         SELECT a.appno
10056         FROM   igs_uc_ivstatement_2003_v a
10057         WHERE  NOT EXISTS ( SELECT b.app_no
10058                             FROM IGS_UC_APPLICANTS b
10059                             WHERE b.app_no = a.appno
10060                             AND b.personal_statement IS NOT NULL );
10061 
10062         -- Get statement for passed appno
10063         CURSOR c_stmt (p_appno igs_uc_ivstatement_2003_v.appno%TYPE ) IS
10064         SELECT appno,statement
10065         FROM igs_uc_ivstatement_2003_v
10066         WHERE appno = p_appno ;
10067         c_stmt_rec  c_stmt%ROWTYPE ;
10068       l_count NUMBER ;
10069 
10070   BEGIN
10071        -- set syncronization required to false
10072        g_sync_reqd := FALSE;
10073        l_count := 0 ;
10074 
10075       -- log message that this view is being loaded
10076         log_start('IVSTATEMENT ON ') ;
10077 
10078 
10079        -- create interface records for each record in the hercules view which hasn't been imported earlier
10080        FOR c_stmt_appno_rec IN c_stmt_appno LOOP
10081               -- set x_sync_read to true if the loop is entered even once
10082               g_sync_reqd := TRUE;
10083 
10084               -- Obsolete matching records in interface table with status N
10085               UPDATE igs_uc_istmnt_ints  SET record_status = 'O'
10086               WHERE record_status = 'N' AND appno =  c_stmt_appno_rec.appno;
10087 
10088               -- copy hercules record into interface table with record status N
10089               c_stmt_rec   := NULL ;
10090               OPEN c_stmt( c_stmt_appno_rec.appno);
10091               FETCH c_stmt INTO c_stmt_rec ;
10092               CLOSE c_stmt ;
10093               INSERT INTO igs_uc_istmnt_ints (  appno,
10094                                                 statement,
10095                                                 record_status,
10096                                                 error_code
10097                                                  )
10098                                      VALUES (   c_stmt_rec.appno,
10099                                                 c_stmt_rec.statement,
10100                                                 'N',
10101                                                 NULL
10102                                                  ) ;
10103         -- increment count of records
10104         l_count := l_count + 1;
10105 
10106        END LOOP ;
10107 
10108       IF g_sync_reqd THEN
10109               -- log message that this view has been loaded
10110                log_complete('IVSTATEMENT', l_count) ;
10111       ELSE
10112                 -- log message that this view is already in sync and need not be loaded
10113                log_already_insync('IVSTATEMENT') ;
10114       END IF ;
10115       COMMIT;
10116 
10117   EXCEPTION
10118       WHEN OTHERS THEN
10119                ROLLBACK;
10120                write_to_log(SQLERRM);
10121                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10122                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTATEMENT_2003');
10123                igs_ge_msg_stack.add;
10124                app_exception.raise_exception ;
10125   END   load_ivstatement_2003  ;
10126 
10127   PROCEDURE load_ivstatement_2004 IS
10128     /******************************************************************
10129      Created By      :  smaddali
10130      Date Created By :   18-Aug-03
10131      Purpose         :    loads each record in the hercules view ivstatement into the interface table
10132                            igs_uc_istmnt_ints with record status N
10133      Known limitations,enhancements,remarks:
10134      Change History
10135      Who       When         What
10136      smaddali  18-aug-03   Modified to load based on the timestamp field in hercules vew for bug#3098810
10137     ***************************************************************** */
10138 
10139       -- Get all the records from hercules  view whose timestamp is > passed timestamp
10140       -- or get all the records in hercules view if the timestamp passed is null
10141       CURSOR c_stmt (p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10142       SELECT appno,statement
10143       FROM igs_uc_ivstatement_2004_v
10144       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10145 
10146       -- get the max timestamp value of the hercules view
10147       CURSOR c_max_timestamp IS
10148       SELECT MAX(timestamp)
10149       FROM igs_uc_ivstatement_2004_v  ;
10150 
10151       -- Variables
10152       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10153       l_new_max_timestamp igs_uc_ivstatement_2004_v.timestamp%TYPE ;
10154       l_count NUMBER ;
10155 
10156       l_appno      igs_uc_istmnt_ints.appno%TYPE;
10157       l_checkdigit NUMBER;
10158 
10159   BEGIN
10160        -- set syncronization required to false
10161        g_sync_reqd := FALSE;
10162        l_count := 0 ;
10163 
10164       -- log message that this view is being loaded
10165         log_start('IVSTATEMENT ON ') ;
10166 
10167       -- Get the old timestamp for this view in the configured cycle
10168       Herc_timestamp_exists('IVSTATEMENT',p_old_timestamp) ;
10169 
10170        -- create interface records for each record in the hercules view which hasn't been imported earlier
10171        FOR c_stmt_rec IN c_stmt(p_old_timestamp) LOOP
10172               -- set x_sync_read to true if the loop is entered even once
10173               g_sync_reqd := TRUE;
10174 
10175               IF  is_valid(c_stmt_rec.appno,'IVSTATEMENT','APPNO','NUMBER') THEN
10176 
10177                   -- Determine actual appno
10178                   get_appno(c_stmt_rec.appno, NULL, l_appno, l_checkdigit);
10179 
10180                   -- Obsolete matching records in interface table with status N
10181                   UPDATE igs_uc_istmnt_ints  SET record_status = 'O'
10182                   WHERE record_status = 'N' AND appno =  l_appno;
10183 
10184 
10185                   -- copy hercules record into interface table with record status N
10186                   INSERT INTO igs_uc_istmnt_ints (  appno,
10187                                                     statement,
10188                                                     record_status,
10189                                                     error_code
10190                                                      )
10191                                          VALUES (   l_appno,
10192                                                     c_stmt_rec.statement,
10193                                                     'N',
10194                                                     NULL
10195                                                      ) ;
10196                   -- increment count of records
10197                   l_count := l_count + 1;
10198 
10199               END IF;
10200 
10201        END LOOP ;
10202 
10203       IF g_sync_reqd THEN
10204               -- get the max timestamp of this hercules view
10205               OPEN c_max_timestamp ;
10206               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10207               CLOSE c_max_timestamp ;
10208 
10209                -- update /insert the timestamp record with new max timestamp
10210                ins_upd_timestamp ('IVSTATEMENT', l_new_max_timestamp) ;
10211 
10212               -- log message that this view has been loaded
10213                log_complete('IVSTATEMENT', l_count) ;
10214       ELSE
10215                 -- log message that this view is already in sync and need not be loaded
10216                log_already_insync('IVSTATEMENT') ;
10217       END IF ;
10218       COMMIT;
10219 
10220   EXCEPTION
10221       WHEN OTHERS THEN
10222                ROLLBACK;
10223                write_to_log(SQLERRM);
10224                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10225                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTATEMENT_2004');
10226                igs_ge_msg_stack.add;
10227                app_exception.raise_exception ;
10228   END   load_ivstatement_2004  ;
10229 
10230 
10231   PROCEDURE load_ivgstatement_2006 IS
10232     /******************************************************************
10233      Created By      :  jbaber
10234      Date Created By :  16-Aug-05
10235      Purpose         :  loads each record in the hercules view ivgstatement into the interface table
10236                         igs_uc_istmnt_ints with record status N
10237      Known limitations,enhancements,remarks:
10238      Change History
10239      Who       When         What
10240     ***************************************************************** */
10241 
10242       -- Get all the records from hercules  view whose timestamp is > passed timestamp
10243       -- or get all the records in hercules view if the timestamp passed is null
10244       CURSOR c_stmt (p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10245       SELECT appno,statement
10246       FROM igs_uc_ivgstatement_2006_v
10247       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10248 
10249       -- get the max timestamp value of the hercules view
10250       CURSOR c_max_timestamp IS
10251       SELECT MAX(timestamp)
10252       FROM igs_uc_ivgstatement_2006_v  ;
10253 
10254       -- Variables
10255       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10256       l_new_max_timestamp igs_uc_ivgstatement_2006_v.timestamp%TYPE ;
10257       l_count NUMBER ;
10258 
10259       l_appno      igs_uc_istmnt_ints.appno%TYPE;
10260       l_checkdigit NUMBER;
10261 
10262   BEGIN
10263        -- set syncronization required to false
10264        g_sync_reqd := FALSE;
10265        l_count := 0 ;
10266 
10267       -- log message that this view is being loaded
10268         log_start('IVGSTATEMENT ON ') ;
10269 
10270       -- Get the old timestamp for this view in the configured cycle
10271       Herc_timestamp_exists('IVGSTATEMENT',p_old_timestamp) ;
10272 
10273        -- create interface records for each record in the hercules view which hasn't been imported earlier
10274        FOR c_stmt_rec IN c_stmt(p_old_timestamp) LOOP
10275               -- set x_sync_read to true if the loop is entered even once
10276               g_sync_reqd := TRUE;
10277 
10278               IF  is_valid(c_stmt_rec.appno,'IVGSTATEMENT','APPNO','NUMBER') THEN
10279 
10280                   -- Determine actual appno
10281                   get_appno(c_stmt_rec.appno, NULL, l_appno, l_checkdigit);
10282 
10283                   -- Obsolete matching records in interface table with status N
10284                   UPDATE igs_uc_istmnt_ints  SET record_status = 'O'
10285                   WHERE record_status = 'N' AND appno =  l_appno;
10286 
10287 
10288                   -- copy hercules record into interface table with record status N
10289                   INSERT INTO igs_uc_istmnt_ints (  appno,
10290                                                     statement,
10291                                                     record_status,
10292                                                     error_code
10293                                                      )
10294                                          VALUES (   l_appno,
10295                                                     c_stmt_rec.statement,
10296                                                     'N',
10297                                                     NULL
10298                                                      ) ;
10299                   -- increment count of records
10300                   l_count := l_count + 1;
10301 
10302               END IF;
10303 
10304        END LOOP ;
10305 
10306       IF g_sync_reqd THEN
10307               -- get the max timestamp of this hercules view
10308               OPEN c_max_timestamp ;
10309               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10310               CLOSE c_max_timestamp ;
10311 
10312                -- update /insert the timestamp record with new max timestamp
10313                ins_upd_timestamp ('IVGSTATEMENT', l_new_max_timestamp) ;
10314 
10315               -- log message that this view has been loaded
10316                log_complete('IVGSTATEMENT', l_count) ;
10317       ELSE
10318                 -- log message that this view is already in sync and need not be loaded
10319                log_already_insync('IVGSTATEMENT') ;
10320       END IF ;
10321       COMMIT;
10322 
10323   EXCEPTION
10324       WHEN OTHERS THEN
10325                ROLLBACK;
10326                write_to_log(SQLERRM);
10327                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10328                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTATEMENT_2006');
10329                igs_ge_msg_stack.add;
10330                app_exception.raise_exception ;
10331   END   load_ivgstatement_2006  ;
10332 
10333 
10334   PROCEDURE load_ivnstatement_2006 IS
10335     /******************************************************************
10336      Created By      :  jbaber
10337      Date Created By :  16-Aug-05
10338      Purpose         :  loads each record in the hercules view ivnstatement into the interface table
10339                         igs_uc_istmnt_ints with record status N
10340      Known limitations,enhancements,remarks:
10341      Change History
10342      Who       When         What
10343     ***************************************************************** */
10344 
10345       -- Get all the records from hercules  view whose timestamp is > passed timestamp
10346       -- or get all the records in hercules view if the timestamp passed is null
10347       CURSOR c_stmt (p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10348       SELECT appno,statement
10349       FROM igs_uc_ivnstatement_2006_v
10350       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10351 
10352       -- get the max timestamp value of the hercules view
10353       CURSOR c_max_timestamp IS
10354       SELECT MAX(timestamp)
10355       FROM igs_uc_ivnstatement_2006_v  ;
10356 
10357       -- Variables
10358       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10359       l_new_max_timestamp igs_uc_ivnstatement_2006_v.timestamp%TYPE ;
10360       l_count NUMBER ;
10361 
10362       l_appno      igs_uc_istmnt_ints.appno%TYPE;
10363       l_checkdigit NUMBER;
10364 
10365   BEGIN
10366        -- set syncronization required to false
10367        g_sync_reqd := FALSE;
10368        l_count := 0 ;
10369 
10370       -- log message that this view is being loaded
10371         log_start('IVNSTATEMENT ON ') ;
10372 
10373       -- Get the old timestamp for this view in the configured cycle
10374       Herc_timestamp_exists('IVNSTATEMENT',p_old_timestamp) ;
10375 
10376        -- create interface records for each record in the hercules view which hasn't been imported earlier
10377        FOR c_stmt_rec IN c_stmt(p_old_timestamp) LOOP
10378               -- set x_sync_read to true if the loop is entered even once
10379               g_sync_reqd := TRUE;
10380 
10381               IF  is_valid(c_stmt_rec.appno,'IVNSTATEMENT','APPNO','NUMBER') THEN
10382 
10383                   -- Determine actual appno
10384                   get_appno(c_stmt_rec.appno, NULL, l_appno, l_checkdigit);
10385 
10386                   -- Obsolete matching records in interface table with status N
10387                   UPDATE igs_uc_istmnt_ints  SET record_status = 'O'
10388                   WHERE record_status = 'N' AND appno =  l_appno;
10389 
10390 
10391                   -- copy hercules record into interface table with record status N
10392                   INSERT INTO igs_uc_istmnt_ints (  appno,
10393                                                     statement,
10394                                                     record_status,
10395                                                     error_code
10396                                                      )
10397                                          VALUES (   l_appno,
10398                                                     c_stmt_rec.statement,
10399                                                     'N',
10400                                                     NULL
10401                                                      ) ;
10402                   -- increment count of records
10403                   l_count := l_count + 1;
10404 
10405               END IF;
10406 
10407        END LOOP ;
10408 
10409       IF g_sync_reqd THEN
10410               -- get the max timestamp of this hercules view
10411               OPEN c_max_timestamp ;
10412               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10413               CLOSE c_max_timestamp ;
10414 
10415                -- update /insert the timestamp record with new max timestamp
10416                ins_upd_timestamp ('IVNSTATEMENT', l_new_max_timestamp) ;
10417 
10418               -- log message that this view has been loaded
10419                log_complete('IVNSTATEMENT', l_count) ;
10420       ELSE
10421                 -- log message that this view is already in sync and need not be loaded
10422                log_already_insync('IVNSTATEMENT') ;
10423       END IF ;
10424       COMMIT;
10425 
10426   EXCEPTION
10427       WHEN OTHERS THEN
10428                ROLLBACK;
10429                write_to_log(SQLERRM);
10430                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10431                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTATEMENT_2006');
10432                igs_ge_msg_stack.add;
10433                app_exception.raise_exception ;
10434   END   load_ivnstatement_2006  ;
10435 
10436 
10437   PROCEDURE load_uvinstitution_2004 IS
10438     /******************************************************************
10439      Created By      :  smaddali
10440      Date Created By :   11-Jun-03
10441      Purpose         :   loads each record in the hercules view uvinstitution into the interface table
10442                            igs_uc_uinst_ints with record status N
10443      Known limitations,enhancements,remarks:
10444      Change History
10445      Who       When         What
10446     ***************************************************************** */
10447 
10448      -- Get all the records from hercules  view whose timestamp is > passed timestamp
10449       -- or get all the records in hercules view if the timestamp passed is null
10450       CURSOR c_uinst ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10451       SELECT  timestamp
10452          ,DECODE(RTRIM(updater),NULL, RPAD('*',LENGTH(updater),'*'), RTRIM(updater)) updater
10453          ,DECODE(RTRIM(insttype),NULL, RPAD('*',LENGTH(insttype),'*'), RTRIM(insttype)) insttype
10454          ,RTRIM(instshortname) instshortname
10455          ,RTRIM(instname) instname
10456          ,RTRIM(instfullname) instfullname
10457          ,RTRIM(switchboardtelno) switchboardtelno
10458          ,RTRIM(decisioncards) decisioncards
10459          ,RTRIM(recordcards) recordcards
10460          ,RTRIM(labels) labels
10461          ,RTRIM(weeklymovlistseq) weeklymovlistseq
10462          ,RTRIM(weeklymovpaging) weeklymovpaging
10463          ,RTRIM(formseq) formseq
10464          ,RTRIM(eblrequired) eblrequired
10465          ,RTRIM(eblmedia1or2) eblmedia1or2
10466          ,RTRIM(eblmedia3) eblmedia3
10467          ,RTRIM(ebl1or2merged) ebl1or2merged
10468          ,RTRIM(ebl1or2boardgroup) ebl1or2boardgroup
10469          ,RTRIM(ebl3boardgroup) ebl3boardgroup
10470          ,RTRIM(eblncapp) eblncapp
10471          ,RTRIM(eblmajorkey1) eblmajorkey1
10472          ,RTRIM(eblmajorkey2) eblmajorkey2
10473          ,RTRIM(eblmajorkey3) eblmajorkey3
10474          ,RTRIM(eblminorkey1) eblminorkey1
10475          ,RTRIM(eblminorkey2) eblminorkey2
10476          ,RTRIM(eblminorkey3) eblminorkey3
10477          ,RTRIM(eblfinalkey) eblfinalkey
10478          ,RTRIM(odl1) odl1
10479          ,RTRIM(odl1a) odl1a
10480          ,RTRIM(odl2) odl2
10481          ,RTRIM(odl3) odl3
10482          ,RTRIM(odlsummer) odlsummer
10483          ,RTRIM(odlrouteb) odlrouteb
10484          ,RTRIM(monthlyseq) monthlyseq
10485          ,RTRIM(monthlypaper) monthlypaper
10486          ,RTRIM(monthlypage) monthlypage
10487          ,RTRIM(monthlytype) monthlytype
10488          ,RTRIM(junelistseq) junelistseq
10489          ,RTRIM(junelabels) junelabels
10490          ,RTRIM(junenumlabels) junenumlabels
10491          ,RTRIM(courseanalysis) courseanalysis
10492          ,RTRIM(campusused) campusused
10493          ,RTRIM(d3docsrequired) d3docsrequired
10494          ,RTRIM(clearingacceptcopyform) clearingacceptcopyform
10495          ,RTRIM(onlinemessage) onlinemessage
10496          ,RTRIM(ethniclistseq) ethniclistseq
10497          ,NVL(RTRIM(starx),'N') starx
10498       FROM igs_uc_u_uvinstitution_2004
10499       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10500 
10501       -- get the max timestamp value of the hercules view
10502       CURSOR c_max_timestamp IS
10503       SELECT MAX(timestamp)
10504       FROM igs_uc_u_uvinstitution_2004  ;
10505 
10506       -- Variables
10507       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10508       l_new_max_timestamp igs_uc_u_uvinstitution_2004.timestamp%TYPE ;
10509       l_count NUMBER ;
10510 
10511   BEGIN
10512        -- set syncronization required to false
10513        g_sync_reqd := FALSE;
10514        l_count := 0 ;
10515 
10516       -- log message that this view is being loaded
10517        log_start('UVINSTITUTION ON ' ) ;
10518 
10519       -- Get the old timestamp for this view in the configured cycle
10520       Herc_timestamp_exists('UVINSTITUTION',p_old_timestamp) ;
10521 
10522        -- create interface records for each record in the hercules view whose timestamp > old timestamp
10523        FOR c_uinst_rec IN c_uinst(p_old_timestamp) LOOP
10524               -- set x_sync_read to true if the loop is entered even once
10525               g_sync_reqd := TRUE;
10526 
10527               -- Obsolete all records in interface table with status N
10528               UPDATE igs_uc_uinst_ints SET record_status = 'O' WHERE record_status = 'N' ;
10529 
10530               -- copy hercules record into interface table with record status N
10531               INSERT INTO igs_uc_uinst_ints (   updater,
10532                                                 insttype,
10533                                                 instshortname,
10534                                                 instname,
10535                                                 instfullname,
10536                                                 switchboardtelno,
10537                                                 decisioncards,
10538                                                 recordcards,
10539                                                 labels,
10540                                                 weeklymovlistseq,
10541                                                 weeklymovpaging,
10542                                                 formseq,
10543                                                 eblrequired,
10544                                                 eblmedia1or2,
10545                                                 eblmedia3,
10546                                                 ebl1or2merged,
10547                                                 ebl1or2boardgroup,
10548                                                 ebl3boardgroup,
10549                                                 eblncapp,
10550                                                 eblmajorkey1,
10551                                                 eblmajorkey2,
10552                                                 eblmajorkey3,
10553                                                 eblminorkey1,
10554                                                 eblminorkey2,
10555                                                 eblminorkey3,
10556                                                 eblfinalkey,
10557                                                 odl1,
10558                                                 odl1a,
10559                                                 odl2,
10560                                                 odl3,
10561                                                 odlsummer,
10562                                                 odlrouteb,
10563                                                 monthlyseq,
10564                                                 monthlypaper,
10565                                                 monthlypage,
10566                                                 monthlytype,
10567                                                 junelistseq,
10568                                                 junelabels,
10569                                                 junenumlabels,
10570                                                 courseanalysis,
10571                                                 campusused,
10572                                                 d3docsrequired,
10573                                                 clearingacceptcopyform,
10574                                                 onlinemessage,
10575                                                 ethniclistseq,
10576                                                 starx,
10577                                                 record_status,
10578                                                 error_code
10579                                                  )
10580                                      VALUES (   c_uinst_rec.updater,
10581                                                 c_uinst_rec.insttype,
10582                                                 c_uinst_rec.instshortname,
10583                                                 c_uinst_rec.instname,
10584                                                 c_uinst_rec.instfullname,
10585                                                 c_uinst_rec.switchboardtelno,
10586                                                 c_uinst_rec.decisioncards,
10587                                                 c_uinst_rec.recordcards,
10588                                                 c_uinst_rec.labels,
10589                                                 c_uinst_rec.weeklymovlistseq,
10590                                                 c_uinst_rec.weeklymovpaging,
10591                                                 c_uinst_rec.formseq,
10592                                                 c_uinst_rec.eblrequired,
10593                                                 c_uinst_rec.eblmedia1or2,
10594                                                 c_uinst_rec.eblmedia3,
10595                                                 c_uinst_rec.ebl1or2merged,
10596                                                 c_uinst_rec.ebl1or2boardgroup,
10597                                                 c_uinst_rec.ebl3boardgroup,
10598                                                 c_uinst_rec.eblncapp,
10599                                                 c_uinst_rec.eblmajorkey1,
10600                                                 c_uinst_rec.eblmajorkey2,
10601                                                 c_uinst_rec.eblmajorkey3,
10602                                                 c_uinst_rec.eblminorkey1,
10603                                                 c_uinst_rec.eblminorkey2,
10604                                                 c_uinst_rec.eblminorkey3,
10605                                                 c_uinst_rec.eblfinalkey,
10606                                                 c_uinst_rec.odl1,
10607                                                 c_uinst_rec.odl1a,
10608                                                 c_uinst_rec.odl2,
10609                                                 c_uinst_rec.odl3,
10610                                                 c_uinst_rec.odlsummer,
10611                                                 c_uinst_rec.odlrouteb,
10612                                                 c_uinst_rec.monthlyseq,
10613                                                 c_uinst_rec.monthlypaper,
10614                                                 c_uinst_rec.monthlypage,
10615                                                 c_uinst_rec.monthlytype,
10616                                                 c_uinst_rec.junelistseq,
10617                                                 c_uinst_rec.junelabels,
10618                                                 c_uinst_rec.junenumlabels,
10619                                                 c_uinst_rec.courseanalysis,
10620                                                 c_uinst_rec.campusused,
10621                                                 c_uinst_rec.d3docsrequired,
10622                                                 c_uinst_rec.clearingacceptcopyform,
10623                                                 c_uinst_rec.onlinemessage,
10624                                                 c_uinst_rec.ethniclistseq,
10625                                                 c_uinst_rec.starx,
10626                                                  'N',
10627                                                  NULL) ;
10628         -- increment count of records
10629         l_count := l_count + 1;
10630 
10631        END LOOP ;
10632 
10633       IF g_sync_reqd THEN
10634               -- get the max timestamp of this hercules view
10635               OPEN c_max_timestamp ;
10636               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10637               CLOSE c_max_timestamp ;
10638 
10639                -- update /insert the timestamp record with new max timestamp
10640                ins_upd_timestamp ('UVINSTITUTION', l_new_max_timestamp) ;
10641 
10642               -- log message that this view has been loaded
10643                log_complete('UVINSTITUTION', l_count ) ;
10644       ELSE
10645                 -- log message that this view is already in sync and need not be loaded
10646                log_already_insync('UVINSTITUTION') ;
10647       END IF ;
10648       COMMIT;
10649 
10650   EXCEPTION
10651       WHEN OTHERS THEN
10652                ROLLBACK;
10653                write_to_log(SQLERRM);
10654                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10655                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_UVINSTITUTION_2004');
10656                igs_ge_msg_stack.add;
10657                app_exception.raise_exception ;
10658   END   load_uvinstitution_2004  ;
10659 
10660 
10661   PROCEDURE load_ivstarw_2004 IS
10662     /******************************************************************
10663      Created By      :  smaddali
10664      Date Created By :   11-Jun-03
10665      Purpose         :       loads each record in the hercules view ivstarw into the interface table
10666                            igs_uc_istarw_ints with record status N
10667      Known limitations,enhancements,remarks:
10668      Change History
10669      Who       When         What
10670     ***************************************************************** */
10671 
10672 
10673      -- Get all the records from hercules  view whose timestamp is > passed timestamp
10674       -- or get all the records in hercules view if the timestamp passed is null
10675       CURSOR c_ivstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10676       SELECT  appno
10677        , timestamp
10678        , RTRIM(miscoded) miscoded
10679        , RTRIM(cancelled) cancelled
10680        , canceldate
10681        , RTRIM(remark) remark
10682        , RTRIM(jointadmission) jointadmission
10683        , NVL(choice1lost,'N') choice1lost
10684         , NVL( choice2lost,'N') choice2lost
10685         , NVL( choice3lost,'N') choice3lost
10686         , NVL( choice4lost,'N') choice4lost
10687         , NVL( choice5lost,'N') choice5lost
10688         , NVL( choice6lost,'N') choice6lost
10689         , NVL( choice7lost,'N') choice7lost
10690       FROM  igs_uc_ivstarw_2004_v
10691       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10692 
10693       -- get the max timestamp value of the hercules view
10694       CURSOR c_max_timestamp IS
10695       SELECT MAX(timestamp)
10696       FROM igs_uc_ivstarw_2004_v  ;
10697 
10698       -- Variables
10699       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10700       l_new_max_timestamp igs_uc_ivstarw_2004_v.timestamp%TYPE ;
10701       l_count NUMBER ;
10702 
10703       l_appno      igs_uc_istarw_ints.appno%TYPE;
10704       l_checkdigit NUMBER;
10705 
10706   BEGIN
10707        -- set syncronization required to false
10708        g_sync_reqd := FALSE;
10709        l_count := 0 ;
10710 
10711       -- log message that this view is being loaded
10712        log_start('IVSTARW ON ' ) ;
10713 
10714       -- Get the old timestamp for this view in the configured cycle
10715       Herc_timestamp_exists('IVSTARW',  p_old_timestamp) ;
10716 
10717        -- create interface records for each record in the hercules view whose timestamp > old timestamp
10718        FOR c_ivstarw_rec IN c_ivstarw(p_old_timestamp) LOOP
10719               -- set x_sync_read to true if the loop is entered even once
10720               g_sync_reqd := TRUE;
10721 
10722               IF  is_valid(c_ivstarw_rec.appno,'IVSTARW','APPNO','NUMBER') THEN
10723 
10724                   -- Determine actual appno
10725                   get_appno(c_ivstarw_rec.appno, NULL, l_appno, l_checkdigit);
10726 
10727                   -- Obsolete matching records in interface table with status N
10728                   UPDATE igs_uc_istarw_ints SET record_status = 'O'
10729                   WHERE record_status = 'N' AND appno =  l_appno ;
10730 
10731                   -- copy hercules record into interface table with record status N
10732                   INSERT INTO igs_uc_istarw_ints (   appno,
10733                                                      miscoded,
10734                                                      cancelled,
10735                                                      jointadmission,
10736                                                      choice1lost,
10737                                                      choice2lost,
10738                                                      choice3lost,
10739                                                      choice4lost,
10740                                                      choice5lost,
10741                                                      choice6lost,
10742                                                      choice7lost,
10743                                                      canceldate,
10744                                                      remark,
10745                                                     record_status,
10746                                                     error_code
10747                                                      )
10748                                          VALUES (    l_appno,
10749                                                      c_ivstarw_rec.miscoded,
10750                                                      c_ivstarw_rec.cancelled,
10751                                                      c_ivstarw_rec.jointadmission,
10752                                                      c_ivstarw_rec.choice1lost,
10753                                                      c_ivstarw_rec.choice2lost,
10754                                                      c_ivstarw_rec.choice3lost,
10755                                                      c_ivstarw_rec.choice4lost,
10756                                                      c_ivstarw_rec.choice5lost,
10757                                                      c_ivstarw_rec.choice6lost,
10758                                                      c_ivstarw_rec.choice7lost,
10759                                                      c_ivstarw_rec.canceldate,
10760                                                      c_ivstarw_rec.remark,
10761                                                     'N',
10762                                                     NULL
10763                                                      ) ;
10764                   -- increment count of records
10765                   l_count := l_count + 1;
10766 
10767               END IF;
10768 
10769        END LOOP ;
10770 
10771       IF g_sync_reqd THEN
10772               -- get the max timestamp of this hercules view
10773               OPEN c_max_timestamp ;
10774               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10775               CLOSE c_max_timestamp ;
10776 
10777                -- update /insert the timestamp record with new max timestamp
10778                ins_upd_timestamp ('IVSTARW',  l_new_max_timestamp) ;
10779 
10780               -- log message that this view has been loaded
10781                log_complete('IVSTARW', l_count ) ;
10782       ELSE
10783                 -- log message that this view is already in sync and need not be loaded
10784                log_already_insync('IVSTARW') ;
10785       END IF ;
10786       COMMIT;
10787 
10788   EXCEPTION
10789       WHEN OTHERS THEN
10790                ROLLBACK;
10791                write_to_log(SQLERRM);
10792                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10793                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVSTARW_2004');
10794                igs_ge_msg_stack.add;
10795                app_exception.raise_exception ;
10796   END   load_ivstarw_2004  ;
10797 
10798 
10799   PROCEDURE load_ivgstarw_2006 IS
10800     /******************************************************************
10801      Created By      :  jbaber
10802      Date Created By :  16-Aug-05
10803      Purpose         :  loads each record in the hercules view ivgstarw into the interface table
10804                         igs_uc_istarw_ints with record status N
10805      Known limitations,enhancements,remarks:
10806      Change History
10807      Who       When         What
10808     ***************************************************************** */
10809 
10810 
10811      -- Get all the records from hercules  view whose timestamp is > passed timestamp
10812       -- or get all the records in hercules view if the timestamp passed is null
10813       CURSOR c_ivgstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10814       SELECT  appno
10815        , timestamp
10816        , RTRIM(miscoded) miscoded
10817        , RTRIM(cancelled) cancelled
10818        , canceldate
10819       FROM  igs_uc_ivgstarw_2006_v
10820       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10821 
10822       -- get the max timestamp value of the hercules view
10823       CURSOR c_max_timestamp IS
10824       SELECT MAX(timestamp)
10825       FROM igs_uc_ivgstarw_2006_v  ;
10826 
10827       -- Variables
10828       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10829       l_new_max_timestamp igs_uc_ivgstarw_2006_v.timestamp%TYPE ;
10830       l_count NUMBER ;
10831 
10832       l_appno      igs_uc_istarw_ints.appno%TYPE;
10833       l_checkdigit NUMBER;
10834 
10835   BEGIN
10836        -- set syncronization required to false
10837        g_sync_reqd := FALSE;
10838        l_count := 0 ;
10839 
10840       -- log message that this view is being loaded
10841        log_start('IVGSTARW ON ' ) ;
10842 
10843       -- Get the old timestamp for this view in the configured cycle
10844       Herc_timestamp_exists('IVGSTARW',  p_old_timestamp) ;
10845 
10846        -- create interface records for each record in the hercules view whose timestamp > old timestamp
10847        FOR c_ivgstarw_rec IN c_ivgstarw(p_old_timestamp) LOOP
10848               -- set x_sync_read to true if the loop is entered even once
10849               g_sync_reqd := TRUE;
10850 
10851               IF  is_valid(c_ivgstarw_rec.appno,'IVGSTARW','APPNO','NUMBER') THEN
10852 
10853                   -- Determine actual appno
10854                   get_appno(c_ivgstarw_rec.appno, NULL, l_appno, l_checkdigit);
10855 
10856                   -- Obsolete matching records in interface table with status N
10857                   UPDATE igs_uc_istarw_ints SET record_status = 'O'
10858                   WHERE record_status = 'N' AND appno =  l_appno ;
10859 
10860                   -- copy hercules record into interface table with record status N
10861                   INSERT INTO igs_uc_istarw_ints (   appno,
10862                                                      miscoded,
10863                                                      cancelled,
10864                                                      canceldate,
10865                                                      record_status,
10866                                                      error_code
10867                                                      )
10868                                          VALUES (    l_appno,
10869                                                      c_ivgstarw_rec.miscoded,
10870                                                      c_ivgstarw_rec.cancelled,
10871                                                      c_ivgstarw_rec.canceldate,
10872                                                     'N',
10873                                                     NULL
10874                                                      ) ;
10875                   -- increment count of records
10876                   l_count := l_count + 1;
10877 
10878               END IF;
10879 
10880        END LOOP ;
10881 
10882       IF g_sync_reqd THEN
10883               -- get the max timestamp of this hercules view
10884               OPEN c_max_timestamp ;
10885               FETCH c_max_timestamp INTO l_new_max_timestamp ;
10886               CLOSE c_max_timestamp ;
10887 
10888                -- update /insert the timestamp record with new max timestamp
10889                ins_upd_timestamp ('IVGSTARW',  l_new_max_timestamp) ;
10890 
10891               -- log message that this view has been loaded
10892                log_complete('IVGSTARW', l_count ) ;
10893       ELSE
10894                 -- log message that this view is already in sync and need not be loaded
10895                log_already_insync('IVGSTARW') ;
10896       END IF ;
10897       COMMIT;
10898 
10899   EXCEPTION
10900       WHEN OTHERS THEN
10901                ROLLBACK;
10902                write_to_log(SQLERRM);
10903                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
10904                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARW_2006');
10905                igs_ge_msg_stack.add;
10906                app_exception.raise_exception ;
10907   END   load_ivgstarw_2006  ;
10908 
10909 
10910   PROCEDURE load_ivgstarw_2007 IS
10911     /******************************************************************
10912      Created By      :  jbaber
10913      Date Created By :  11-Jul-06
10914      Purpose         :  loads each record in the hercules view ivgstarw into the interface table
10915                         igs_uc_istarw_ints with record status N
10916      Known limitations,enhancements,remarks:
10917      Change History
10918      Who       When         What
10919     ***************************************************************** */
10920 
10921 
10922      -- Get all the records from hercules  view whose timestamp is > passed timestamp
10923       -- or get all the records in hercules view if the timestamp passed is null
10924       CURSOR c_ivgstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
10925       SELECT  appno
10926        , timestamp
10927        , RTRIM(miscoded) miscoded
10928        , RTRIM(cancelled) cancelled
10929        , canceldate
10930        , remark
10931       FROM  igs_uc_ivgstarw_2007_v
10932       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
10933 
10934       -- get the max timestamp value of the hercules view
10935       CURSOR c_max_timestamp IS
10936       SELECT MAX(timestamp)
10937       FROM igs_uc_ivgstarw_2007_v  ;
10938 
10939       -- Variables
10940       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
10941       l_new_max_timestamp igs_uc_ivgstarw_2007_v.timestamp%TYPE ;
10942       l_count NUMBER ;
10943 
10944       l_appno      igs_uc_istarw_ints.appno%TYPE;
10945       l_checkdigit NUMBER;
10946 
10947   BEGIN
10948        -- set syncronization required to false
10949        g_sync_reqd := FALSE;
10950        l_count := 0 ;
10951 
10952       -- log message that this view is being loaded
10953        log_start('IVGSTARW ON ' ) ;
10954 
10955       -- Get the old timestamp for this view in the configured cycle
10956       Herc_timestamp_exists('IVGSTARW',  p_old_timestamp) ;
10957 
10958        -- create interface records for each record in the hercules view whose timestamp > old timestamp
10959        FOR c_ivgstarw_rec IN c_ivgstarw(p_old_timestamp) LOOP
10960               -- set x_sync_read to true if the loop is entered even once
10961               g_sync_reqd := TRUE;
10962 
10963               IF  is_valid(c_ivgstarw_rec.appno,'IVGSTARW','APPNO','NUMBER') THEN
10964 
10965                   -- Determine actual appno
10966                   get_appno(c_ivgstarw_rec.appno, NULL, l_appno, l_checkdigit);
10967 
10968                   -- Obsolete matching records in interface table with status N
10969                   UPDATE igs_uc_istarw_ints SET record_status = 'O'
10970                   WHERE record_status = 'N' AND appno =  l_appno ;
10971 
10972                   -- copy hercules record into interface table with record status N
10973                   INSERT INTO igs_uc_istarw_ints (   appno,
10974                                                      miscoded,
10975                                                      cancelled,
10976                                                      canceldate,
10977                                                      remark,
10978                                                      record_status,
10979                                                      error_code
10980                                                      )
10981                                          VALUES (    l_appno,
10982                                                      c_ivgstarw_rec.miscoded,
10983                                                      c_ivgstarw_rec.cancelled,
10984                                                      c_ivgstarw_rec.canceldate,
10985                                                      c_ivgstarw_rec.remark,
10986                                                     'N',
10987                                                     NULL
10988                                                      ) ;
10989                   -- increment count of records
10990                   l_count := l_count + 1;
10991 
10992               END IF;
10993 
10994        END LOOP ;
10995 
10996       IF g_sync_reqd THEN
10997               -- get the max timestamp of this hercules view
10998               OPEN c_max_timestamp ;
10999               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11000               CLOSE c_max_timestamp ;
11001 
11002                -- update /insert the timestamp record with new max timestamp
11003                ins_upd_timestamp ('IVGSTARW',  l_new_max_timestamp) ;
11004 
11005               -- log message that this view has been loaded
11006                log_complete('IVGSTARW', l_count ) ;
11007       ELSE
11008                 -- log message that this view is already in sync and need not be loaded
11009                log_already_insync('IVGSTARW') ;
11010       END IF ;
11011       COMMIT;
11012 
11013   EXCEPTION
11014       WHEN OTHERS THEN
11015                ROLLBACK;
11016                write_to_log(SQLERRM);
11017                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11018                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGSTARW_2007');
11019                igs_ge_msg_stack.add;
11020                app_exception.raise_exception ;
11021   END   load_ivgstarw_2007  ;
11022 
11023 
11024   PROCEDURE load_ivnstarw_2006 IS
11025     /******************************************************************
11026      Created By      :  jbaber
11027      Date Created By :  16-Aug-05
11028      Purpose         :  loads each record in the hercules view ivnstarw into the interface table
11029                         igs_uc_istarw_ints with record status N
11030      Known limitations,enhancements,remarks:
11031      Change History
11032      Who       When         What
11033     ***************************************************************** */
11034 
11035 
11036      -- Get all the records from hercules  view whose timestamp is > passed timestamp
11037       -- or get all the records in hercules view if the timestamp passed is null
11038       CURSOR c_ivnstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11039       SELECT  appno
11040        , timestamp
11041        , RTRIM(miscoded) miscoded
11042        , RTRIM(cancelled) cancelled
11043        , canceldate
11044       FROM  igs_uc_ivnstarw_2006_v
11045       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11046 
11047       -- get the max timestamp value of the hercules view
11048       CURSOR c_max_timestamp IS
11049       SELECT MAX(timestamp)
11050       FROM igs_uc_ivnstarw_2006_v  ;
11051 
11052       -- Variables
11053       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11054       l_new_max_timestamp igs_uc_ivnstarw_2006_v.timestamp%TYPE ;
11055       l_count NUMBER ;
11056 
11057       l_appno      igs_uc_istarw_ints.appno%TYPE;
11058       l_checkdigit NUMBER;
11059 
11060   BEGIN
11061        -- set syncronization required to false
11062        g_sync_reqd := FALSE;
11063        l_count := 0 ;
11064 
11065       -- log message that this view is being loaded
11066        log_start('IVNSTARW ON ' ) ;
11067 
11068       -- Get the old timestamp for this view in the configured cycle
11069       Herc_timestamp_exists('IVNSTARW',  p_old_timestamp) ;
11070 
11071        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11072        FOR c_ivnstarw_rec IN c_ivnstarw(p_old_timestamp) LOOP
11073               -- set x_sync_read to true if the loop is entered even once
11074               g_sync_reqd := TRUE;
11075 
11076               IF  is_valid(c_ivnstarw_rec.appno,'IVNSTARW','APPNO','NUMBER') THEN
11077 
11078                   -- Determine actual appno
11079                   get_appno(c_ivnstarw_rec.appno, NULL, l_appno, l_checkdigit);
11080 
11081                   -- Obsolete matching records in interface table with status N
11082                   UPDATE igs_uc_istarw_ints SET record_status = 'O'
11083                   WHERE record_status = 'N' AND appno =  l_appno ;
11084 
11085                   -- copy hercules record into interface table with record status N
11086                   INSERT INTO igs_uc_istarw_ints (   appno,
11087                                                      miscoded,
11088                                                      cancelled,
11089                                                      canceldate,
11090                                                      record_status,
11091                                                      error_code
11092                                                      )
11093                                          VALUES (    l_appno,
11094                                                      c_ivnstarw_rec.miscoded,
11095                                                      c_ivnstarw_rec.cancelled,
11096                                                      c_ivnstarw_rec.canceldate,
11097                                                     'N',
11098                                                     NULL
11099                                                      ) ;
11100                   -- increment count of records
11101                   l_count := l_count + 1;
11102 
11103               END IF;
11104 
11105        END LOOP ;
11106 
11107       IF g_sync_reqd THEN
11108               -- get the max timestamp of this hercules view
11109               OPEN c_max_timestamp ;
11110               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11111               CLOSE c_max_timestamp ;
11112 
11113                -- update /insert the timestamp record with new max timestamp
11114                ins_upd_timestamp ('IVNSTARW',  l_new_max_timestamp) ;
11115 
11116               -- log message that this view has been loaded
11117                log_complete('IVNSTARW', l_count ) ;
11118       ELSE
11119                 -- log message that this view is already in sync and need not be loaded
11120                log_already_insync('IVNSTARW') ;
11121       END IF ;
11122       COMMIT;
11123 
11124   EXCEPTION
11125       WHEN OTHERS THEN
11126                ROLLBACK;
11127                write_to_log(SQLERRM);
11128                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11129                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARW_2006');
11130                igs_ge_msg_stack.add;
11131                app_exception.raise_exception ;
11132   END   load_ivnstarw_2006  ;
11133 
11134 
11135   PROCEDURE load_ivnstarw_2007 IS
11136     /******************************************************************
11137      Created By      :  jbaber
11138      Date Created By :  11-Jul-06
11139      Purpose         :  loads each record in the hercules view ivnstarw into the interface table
11140                         igs_uc_istarw_ints with record status N
11141      Known limitations,enhancements,remarks:
11142      Change History
11143      Who       When         What
11144     ***************************************************************** */
11145 
11146 
11147      -- Get all the records from hercules  view whose timestamp is > passed timestamp
11148       -- or get all the records in hercules view if the timestamp passed is null
11149       CURSOR c_ivnstarw ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11150       SELECT  appno
11151        , timestamp
11152        , RTRIM(miscoded) miscoded
11153        , RTRIM(cancelled) cancelled
11154        , canceldate
11155        , remark
11156       FROM  igs_uc_ivnstarw_2007_v
11157       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11158 
11159       -- get the max timestamp value of the hercules view
11160       CURSOR c_max_timestamp IS
11161       SELECT MAX(timestamp)
11162       FROM igs_uc_ivnstarw_2007_v  ;
11163 
11164       -- Variables
11165       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11166       l_new_max_timestamp igs_uc_ivnstarw_2007_v.timestamp%TYPE ;
11167       l_count NUMBER ;
11168 
11169       l_appno      igs_uc_istarw_ints.appno%TYPE;
11170       l_checkdigit NUMBER;
11171 
11172   BEGIN
11173        -- set syncronization required to false
11174        g_sync_reqd := FALSE;
11175        l_count := 0 ;
11176 
11177       -- log message that this view is being loaded
11178        log_start('IVNSTARW ON ' ) ;
11179 
11180       -- Get the old timestamp for this view in the configured cycle
11181       Herc_timestamp_exists('IVNSTARW',  p_old_timestamp) ;
11182 
11183        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11184        FOR c_ivnstarw_rec IN c_ivnstarw(p_old_timestamp) LOOP
11185               -- set x_sync_read to true if the loop is entered even once
11186               g_sync_reqd := TRUE;
11187 
11188               IF  is_valid(c_ivnstarw_rec.appno,'IVNSTARW','APPNO','NUMBER') THEN
11189 
11190                   -- Determine actual appno
11191                   get_appno(c_ivnstarw_rec.appno, NULL, l_appno, l_checkdigit);
11192 
11193                   -- Obsolete matching records in interface table with status N
11194                   UPDATE igs_uc_istarw_ints SET record_status = 'O'
11195                   WHERE record_status = 'N' AND appno =  l_appno ;
11196 
11197                   -- copy hercules record into interface table with record status N
11198                   INSERT INTO igs_uc_istarw_ints (   appno,
11199                                                      miscoded,
11200                                                      cancelled,
11201                                                      canceldate,
11202                                                      remark,
11203                                                      record_status,
11204                                                      error_code
11205                                                      )
11206                                          VALUES (    l_appno,
11207                                                      c_ivnstarw_rec.miscoded,
11208                                                      c_ivnstarw_rec.cancelled,
11209                                                      c_ivnstarw_rec.canceldate,
11210                                                      c_ivnstarw_rec.remark,
11211                                                     'N',
11212                                                     NULL
11213                                                      ) ;
11214                   -- increment count of records
11215                   l_count := l_count + 1;
11216 
11217               END IF;
11218 
11219        END LOOP ;
11220 
11221       IF g_sync_reqd THEN
11222               -- get the max timestamp of this hercules view
11223               OPEN c_max_timestamp ;
11224               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11225               CLOSE c_max_timestamp ;
11226 
11227                -- update /insert the timestamp record with new max timestamp
11228                ins_upd_timestamp ('IVNSTARW',  l_new_max_timestamp) ;
11229 
11230               -- log message that this view has been loaded
11231                log_complete('IVNSTARW', l_count ) ;
11232       ELSE
11233                 -- log message that this view is already in sync and need not be loaded
11234                log_already_insync('IVNSTARW') ;
11235       END IF ;
11236       COMMIT;
11237 
11238   EXCEPTION
11239       WHEN OTHERS THEN
11240                ROLLBACK;
11241                write_to_log(SQLERRM);
11242                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11243                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNSTARW_2007');
11244                igs_ge_msg_stack.add;
11245                app_exception.raise_exception ;
11246   END   load_ivnstarw_2007  ;
11247 
11248 
11249   PROCEDURE load_ivformquals_2004 IS
11250     /******************************************************************
11251      Created By      :  smaddali
11252      Date Created By :   11-Jun-03
11253      Purpose         :   loads each record in the hercules view ivformquals into the interface table
11254                            igs_uc_ifrmqul_ints with record status N
11255      Known limitations,enhancements,remarks:
11256      Change History
11257      Who       When         What
11258     ***************************************************************** */
11259 
11260     -- Get all the records from hercules  view whose timestamp is > passed timestamp
11261       -- or get all the records in hercules view if the timestamp passed is null
11262       CURSOR c_ivformqual ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11263       SELECT     appno
11264                  ,timestamp
11265                  ,qualid
11266                  ,RTRIM(qualtype) qualtype
11267                  ,RTRIM(awardbody) awardbody
11268                  ,RTRIM(title) title
11269                  ,RTRIM(grade) grade
11270                  ,qualdate
11271       FROM  igs_uc_ivformquals_2004_v
11272       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11273 
11274       -- get the max timestamp value of the hercules view
11275       CURSOR c_max_timestamp IS
11276       SELECT MAX(timestamp)
11277       FROM igs_uc_ivformquals_2004_v  ;
11278 
11279       -- Variables
11280       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11281       l_new_max_timestamp igs_uc_ivformquals_2004_v.timestamp%TYPE ;
11282       l_count NUMBER ;
11283 
11284       l_appno      igs_uc_ifrmqul_ints.appno%TYPE;
11285       l_checkdigit NUMBER;
11286 
11287   BEGIN
11288        -- set syncronization required to false
11289        g_sync_reqd := FALSE;
11290        l_count := 0 ;
11291 
11292       -- log message that this view is being loaded
11293        log_start('IVFORMQUALS ON ') ;
11294 
11295       -- Get the old timestamp for this view in the configured cycle
11296       Herc_timestamp_exists('IVFORMQUALS', p_old_timestamp) ;
11297 
11298        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11299        FOR c_ivformqual_rec IN c_ivformqual(p_old_timestamp) LOOP
11300               -- set x_sync_read to true if the loop is entered even once
11301               g_sync_reqd := TRUE;
11302 
11303               IF  is_valid(c_ivformqual_rec.appno,'IVFORMQUALS','APPNO','NUMBER') THEN
11304 
11305                   -- Determine actual appno
11306                   get_appno(c_ivformqual_rec.appno, NULL, l_appno, l_checkdigit);
11307 
11308                   -- Obsolete matching records in interface table with status N
11309                   UPDATE igs_uc_ifrmqul_ints SET record_status = 'O'
11310                   WHERE record_status = 'N' AND appno = l_appno
11311                   AND qualid = c_ivformqual_rec.qualid ;
11312 
11313                   -- copy hercules record into interface table with record status N
11314                   INSERT INTO igs_uc_ifrmqul_ints (  appno,
11315                                                      qualid,
11316                                                      qualtype,
11317                                                      awardbody,
11318                                                      title,
11319                                                      grade,
11320                                                      qualdate,
11321                                                      record_status,
11322                                                      error_code
11323                                                      )
11324                                          VALUES (    l_appno,
11325                                                      c_ivformqual_rec.qualid,
11326                                                      c_ivformqual_rec.qualtype,
11327                                                      c_ivformqual_rec.awardbody,
11328                                                      c_ivformqual_rec.title,
11329                                                      c_ivformqual_rec.grade,
11330                                                      c_ivformqual_rec.qualdate,
11331                                                     'N',
11332                                                     NULL
11333                                                      ) ;
11334                   -- increment count of records
11335                   l_count := l_count + 1;
11336 
11337               END IF;
11338 
11339        END LOOP ;
11340 
11341 
11342        IF g_sync_reqd THEN
11343               -- get the max timestamp of this hercules view
11344               OPEN c_max_timestamp ;
11345               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11346               CLOSE c_max_timestamp ;
11347 
11348                -- update /insert the timestamp record with new max timestamp
11349                ins_upd_timestamp ('IVFORMQUALS', l_new_max_timestamp) ;
11350 
11351               -- log message that this view has been loaded
11352                log_complete('IVFORMQUALS', l_count) ;
11353        ELSE
11354                 -- log message that this view is already in sync and need not be loaded
11355                log_already_insync('IVFORMQUALS') ;
11356        END IF ;
11357       COMMIT;
11358 
11359   EXCEPTION
11360       WHEN OTHERS THEN
11361                ROLLBACK;
11362                write_to_log(SQLERRM);
11363                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11364                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVFORMQUALS_2004');
11365                igs_ge_msg_stack.add;
11366                app_exception.raise_exception ;
11367   END  load_ivformquals_2004   ;
11368 
11369 
11370   PROCEDURE load_ivformquals_2006 IS
11371     /******************************************************************
11372      Created By      :  jbaber
11373      Date Created By :   15-Sep-05
11374      Purpose         :   loads each record in the hercules view ivformquals into the interface table
11375                            igs_uc_ifrmqul_ints with record status N
11376      Known limitations,enhancements,remarks:
11377      Change History
11378      Who       When         What
11379      jbaber    11-Jul-06    Truncate qualtype to 30 chars for UCAS 2007 Support
11380     ***************************************************************** */
11381 
11382     -- Get all the records from hercules  view whose timestamp is > passed timestamp
11383       -- or get all the records in hercules view if the timestamp passed is null
11384       CURSOR c_ivformqual ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11385       SELECT     appno
11386                  ,timestamp
11387                  ,qualid
11388                  ,RTRIM(SUBSTR(qualtype,1,30)) qualtype
11389                  ,RTRIM(awardbody) awardbody
11390                  ,RTRIM(title) title
11391                  ,RTRIM(grade) grade
11392                  ,qualdateyear
11393                  ,qualdatemonth
11394       FROM  igs_uc_ivformquals_2006_v
11395       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11396 
11397       -- get the max timestamp value of the hercules view
11398       CURSOR c_max_timestamp IS
11399       SELECT MAX(timestamp)
11400       FROM igs_uc_ivformquals_2006_v  ;
11401 
11402       -- Variables
11403       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11404       l_new_max_timestamp igs_uc_ivformquals_2006_v.timestamp%TYPE ;
11405       l_count NUMBER ;
11406 
11407       l_qualdate   igs_uc_ifrmqul_ints.qualdate%TYPE;
11408       l_appno      igs_uc_ifrmqul_ints.appno%TYPE;
11409       l_checkdigit NUMBER;
11410 
11411   BEGIN
11412        -- set syncronization required to false
11413        g_sync_reqd := FALSE;
11414        l_count := 0 ;
11415 
11416       -- log message that this view is being loaded
11417        log_start('IVFORMQUALS ON ') ;
11418 
11419       -- Get the old timestamp for this view in the configured cycle
11420       Herc_timestamp_exists('IVFORMQUALS', p_old_timestamp) ;
11421 
11422        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11423        FOR c_ivformqual_rec IN c_ivformqual(p_old_timestamp) LOOP
11424               -- set x_sync_read to true if the loop is entered even once
11425               g_sync_reqd := TRUE;
11426 
11427               IF  is_valid(c_ivformqual_rec.appno,'IVFORMQUALS','APPNO','NUMBER') THEN
11428 
11429                   -- Determine actual appno
11430                   get_appno(c_ivformqual_rec.appno, NULL, l_appno, l_checkdigit);
11431 
11432                   -- Obsolete matching records in interface table with status N
11433                   UPDATE igs_uc_ifrmqul_ints SET record_status = 'O'
11434                   WHERE record_status = 'N' AND appno = l_appno
11435                   AND qualid = c_ivformqual_rec.qualid ;
11436 
11437                   -- Construct qualdate from qualdatemonth and qualdateyear
11438                   IF c_ivformqual_rec.qualdatemonth IS NOT NULL AND
11439                      c_ivformqual_rec.qualdateyear IS NOT NULL THEN
11440                       l_qualdate := TO_DATE(LPAD(c_ivformqual_rec.qualdatemonth,2,0) || c_ivformqual_rec.qualdateyear, 'mmyyyy');
11441                   ELSE
11442                       l_qualdate := NULL;
11443                   END IF;
11444 
11445                   -- copy hercules record into interface table with record status N
11446                   INSERT INTO igs_uc_ifrmqul_ints (  appno,
11447                                                      qualid,
11448                                                      qualtype,
11449                                                      awardbody,
11450                                                      title,
11451                                                      grade,
11452                                                      qualdate,
11453                                                      record_status,
11454                                                      error_code
11455                                                      )
11456                                          VALUES (    l_appno,
11457                                                      c_ivformqual_rec.qualid,
11458                                                      c_ivformqual_rec.qualtype,
11459                                                      c_ivformqual_rec.awardbody,
11460                                                      c_ivformqual_rec.title,
11461                                                      c_ivformqual_rec.grade,
11462                                                      l_qualdate,
11463                                                      'N',
11464                                                      NULL
11465                                                      ) ;
11466                   -- increment count of records
11467                   l_count := l_count + 1;
11468 
11469               END IF;
11470 
11471        END LOOP ;
11472 
11473 
11474        IF g_sync_reqd THEN
11475               -- get the max timestamp of this hercules view
11476               OPEN c_max_timestamp ;
11477               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11478               CLOSE c_max_timestamp ;
11479 
11480                -- update /insert the timestamp record with new max timestamp
11481                ins_upd_timestamp ('IVFORMQUALS', l_new_max_timestamp) ;
11482 
11483               -- log message that this view has been loaded
11484                log_complete('IVFORMQUALS', l_count) ;
11485        ELSE
11486                 -- log message that this view is already in sync and need not be loaded
11487                log_already_insync('IVFORMQUALS') ;
11488        END IF ;
11489       COMMIT;
11490 
11491   EXCEPTION
11492       WHEN OTHERS THEN
11493                ROLLBACK;
11494                write_to_log(SQLERRM);
11495                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11496                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVFORMQUALS_2006');
11497                igs_ge_msg_stack.add;
11498                app_exception.raise_exception ;
11499   END  load_ivformquals_2006   ;
11500 
11501 
11502   PROCEDURE load_ivreference_2004 IS
11503     /******************************************************************
11504      Created By      :  smaddali
11505      Date Created By :   11-Jun-03
11506      Purpose         :   loads each record in the hercules view ivreference into the interface table
11507                            igs_uc_irefrnc_ints with record status N
11508      Known limitations,enhancements,remarks:
11509      Change History
11510      Who       When         What
11511     ***************************************************************** */
11512 
11513       -- Get all the records from hercules  view whose timestamp is > passed timestamp
11514       -- or get all the records in hercules view if the timestamp passed is null
11515       CURSOR c_ivreference ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11516       SELECT     appno
11517                  ,timestamp
11518                  ,DECODE(RTRIM(refereename),NULL, RPAD('*',LENGTH(refereename),'*'), RTRIM(refereename)) refereename
11519                  ,RTRIM(refereepost) refereepost
11520                  ,RTRIM(estabname) estabname
11521                  ,RTRIM(address1) address1
11522                  ,RTRIM(address2) address2
11523                  ,RTRIM(address3) address3
11524                  ,RTRIM(address4) address4
11525                  ,RTRIM(telephone) telephone
11526                  ,RTRIM(fax) fax
11527                  ,RTRIM(email) email
11528                  ,statement statement
11529       FROM  igs_uc_ivreference_2004_v
11530       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11531 
11532       -- get the max timestamp value of the hercules view
11533       CURSOR c_max_timestamp IS
11534       SELECT MAX(timestamp)
11535       FROM igs_uc_ivreference_2004_v  ;
11536 
11537       -- Variables
11538       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11539       l_new_max_timestamp igs_uc_ivreference_2004_v.timestamp%TYPE ;
11540       l_count NUMBER ;
11541 
11542   BEGIN
11543        -- set syncronization required to false
11544        g_sync_reqd := FALSE;
11545        l_count := 0 ;
11546 
11547       -- log message that this view is being loaded
11548       log_start( 'IVREFERENCE ON ') ;
11549 
11550       -- Get the old timestamp for this view in the configured cycle
11551       Herc_timestamp_exists('IVREFERENCE', p_old_timestamp) ;
11552 
11553        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11554       FOR c_ivreference_rec IN c_ivreference(p_old_timestamp) LOOP
11555               -- set x_sync_read to true if the loop is entered even once
11556               g_sync_reqd := TRUE;
11557 
11558               -- Obsolete matching records in interface table with status N
11559               UPDATE igs_uc_irefrnc_ints SET record_status = 'O'
11560               WHERE record_status = 'N' AND appno = c_ivreference_rec.appno
11561               AND refereename = c_ivreference_rec.refereename ;
11562 
11563               -- copy hercules record into interface table with record status N
11564               INSERT INTO igs_uc_irefrnc_ints ( appno,
11565                                                 refereename,
11566                                                 refereepost,
11567                                                 estabname,
11568                                                 address1,
11569                                                 address2,
11570                                                 address3,
11571                                                 address4,
11572                                                 telephone,
11573                                                 fax,
11574                                                 email,
11575                                                 statement,
11576                                                 record_status,
11577                                                 error_code
11578                                                  )
11579                 VALUES (        c_ivreference_rec.appno,
11580                                                 c_ivreference_rec.refereename,
11581                                                 c_ivreference_rec.refereepost,
11582                                                 c_ivreference_rec.estabname,
11583                                                 c_ivreference_rec.address1,
11584                                                 c_ivreference_rec.address2,
11585                                                 c_ivreference_rec.address3,
11586                                                 c_ivreference_rec.address4,
11587                                                 c_ivreference_rec.telephone,
11588                                                 c_ivreference_rec.fax,
11589                                                 c_ivreference_rec.email,
11590                                                 c_ivreference_rec.statement,
11591                                                 'N',
11592                                                 NULL
11593                                                  ) ;
11594         -- increment count of records
11595         l_count := l_count + 1;
11596 
11597       END LOOP ;
11598 
11599       IF g_sync_reqd THEN
11600               -- get the max timestamp of this hercules view
11601               OPEN c_max_timestamp ;
11602               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11603               CLOSE c_max_timestamp ;
11604 
11605                -- update /insert the timestamp record with new max timestamp
11606                ins_upd_timestamp ('IVREFERENCE', l_new_max_timestamp) ;
11607 
11608               -- log message that this view has been loaded
11609                log_complete( 'IVREFERENCE', l_count) ;
11610       ELSE
11611                 -- log message that this view is already in sync and need not be loaded
11612                log_already_insync('IVREFERENCE') ;
11613       END IF ;
11614       COMMIT;
11615 
11616   EXCEPTION
11617       WHEN OTHERS THEN
11618                ROLLBACK;
11619                write_to_log(SQLERRM);
11620                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11621                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVREFERENCE_2004');
11622                igs_ge_msg_stack.add;
11623                app_exception.raise_exception ;
11624   END   load_ivreference_2004  ;
11625 
11626 
11627   PROCEDURE load_ivreference_2006 IS
11628     /******************************************************************
11629      Created By      :  jbaber
11630      Date Created By :  07-Jul-05
11631      Purpose         :  loads each record in the hercules view ivreference into the interface table
11632                         igs_uc_irefrnc_ints with record status N
11633      Known limitations,enhancements,remarks:
11634      Change History
11635      Who       When         What
11636     ***************************************************************** */
11637 
11638       -- Get all the records from hercules  view whose timestamp is > passed timestamp
11639       -- or get all the records in hercules view if the timestamp passed is null
11640       CURSOR c_ivreference ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11641       SELECT     appno
11642                  ,timestamp
11643                  ,DECODE(RTRIM(refereename),NULL, RPAD('*',LENGTH(refereename),'*'), RTRIM(refereename)) refereename
11644                  ,RTRIM(refereepost) refereepost
11645                  ,RTRIM(estabname) estabname
11646                  ,RTRIM(address1) address1
11647                  ,RTRIM(address2) address2
11648                  ,RTRIM(address3) address3
11649                  ,RTRIM(address4) address4
11650                  ,RTRIM(telephone) telephone
11651                  ,RTRIM(fax) fax
11652                  ,RTRIM(email) email
11653                  ,statement statement
11654                  ,RTRIM(predictedgrades) predictedgrades
11655       FROM  igs_uc_ivreference_2006_v
11656       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11657 
11658       -- get the max timestamp value of the hercules view
11659       CURSOR c_max_timestamp IS
11660       SELECT MAX(timestamp)
11661       FROM igs_uc_ivreference_2006_v  ;
11662 
11663       -- Variables
11664       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11665       l_new_max_timestamp igs_uc_ivreference_2006_v.timestamp%TYPE ;
11666       l_count NUMBER ;
11667 
11668       l_appno      igs_uc_irefrnc_ints.appno%TYPE;
11669       l_checkdigit NUMBER;
11670 
11671   BEGIN
11672        -- set syncronization required to false
11673        g_sync_reqd := FALSE;
11674        l_count := 0 ;
11675 
11676       -- log message that this view is being loaded
11677       log_start( 'IVREFERENCE ON ') ;
11678 
11679       -- Get the old timestamp for this view in the configured cycle
11680       Herc_timestamp_exists('IVREFERENCE', p_old_timestamp) ;
11681 
11682        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11683       FOR c_ivreference_rec IN c_ivreference(p_old_timestamp) LOOP
11684               -- set x_sync_read to true if the loop is entered even once
11685               g_sync_reqd := TRUE;
11686 
11687               IF  is_valid(c_ivreference_rec.appno,'IVREFERENCE','APPNO','NUMBER') THEN
11688 
11689                   get_appno(c_ivreference_rec.appno, NULL, l_appno, l_checkdigit);
11690 
11691                   -- Obsolete matching records in interface table with status N
11692                   UPDATE igs_uc_irefrnc_ints SET record_status = 'O'
11693                   WHERE record_status = 'N' AND appno = l_appno
11694                   AND refereename = c_ivreference_rec.refereename ;
11695 
11696                   -- copy hercules record into interface table with record status N
11697                   INSERT INTO igs_uc_irefrnc_ints ( appno,
11698                                                     refereename,
11699                                                     refereepost,
11700                                                     estabname,
11701                                                     address1,
11702                                                     address2,
11703                                                     address3,
11704                                                     address4,
11705                                                     telephone,
11706                                                     fax,
11707                                                     email,
11708                                                     statement,
11709                                                     predictedgrades,
11710                                                     record_status,
11711                                                     error_code
11712                                                      )
11713                     VALUES (                        l_appno,
11714                                                     c_ivreference_rec.refereename,
11715                                                     c_ivreference_rec.refereepost,
11716                                                     c_ivreference_rec.estabname,
11717                                                     c_ivreference_rec.address1,
11718                                                     c_ivreference_rec.address2,
11719                                                     c_ivreference_rec.address3,
11720                                                     c_ivreference_rec.address4,
11721                                                     c_ivreference_rec.telephone,
11722                                                     c_ivreference_rec.fax,
11723                                                     c_ivreference_rec.email,
11724                                                     c_ivreference_rec.statement,
11725                                                     c_ivreference_rec.predictedgrades,
11726                                                     'N',
11727                                                     NULL
11728                                                      ) ;
11729                   -- increment count of records
11730                   l_count := l_count + 1;
11731 
11732               END IF;
11733 
11734       END LOOP ;
11735 
11736       IF g_sync_reqd THEN
11737               -- get the max timestamp of this hercules view
11738               OPEN c_max_timestamp ;
11739               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11740               CLOSE c_max_timestamp ;
11741 
11742                -- update /insert the timestamp record with new max timestamp
11743                ins_upd_timestamp ('IVREFERENCE', l_new_max_timestamp) ;
11744 
11745               -- log message that this view has been loaded
11746                log_complete( 'IVREFERENCE', l_count) ;
11747       ELSE
11748                 -- log message that this view is already in sync and need not be loaded
11749                log_already_insync('IVREFERENCE') ;
11750       END IF ;
11751       COMMIT;
11752 
11753   EXCEPTION
11754       WHEN OTHERS THEN
11755                ROLLBACK;
11756                write_to_log(SQLERRM);
11757                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11758                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVREFERENCE_2006');
11759                igs_ge_msg_stack.add;
11760                app_exception.raise_exception ;
11761   END   load_ivreference_2006  ;
11762 
11763 
11764   PROCEDURE load_ivgreference_2006 IS
11765     /******************************************************************
11766      Created By      :  jbaber
11767      Date Created By :  16-Aug-05
11768      Purpose         :  loads each record in the hercules view ivgreference into the interface table
11769                         igs_uc_irefrnc_ints with record status N
11770      Known limitations,enhancements,remarks:
11771      Change History
11772      Who       When         What
11773     ***************************************************************** */
11774 
11775       -- Get all the records from hercules  view whose timestamp is > passed timestamp
11776       -- or get all the records in hercules view if the timestamp passed is null
11777       CURSOR c_ivgreference ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11778       SELECT     appno
11779                  ,timestamp
11780                  ,DECODE(RTRIM(refereename),NULL, RPAD('*',LENGTH(refereename),'*'), RTRIM(refereename)) refereename
11781                  ,RTRIM(refereepost) refereepost
11782                  ,RTRIM(estabname) estabname
11783                  ,RTRIM(address1) address1
11784                  ,RTRIM(address2) address2
11785                  ,RTRIM(address3) address3
11786                  ,RTRIM(address4) address4
11787                  ,RTRIM(telephone) telephone
11788                  ,RTRIM(fax) fax
11789                  ,RTRIM(email) email
11790                  ,statement statement
11791       FROM  igs_uc_ivgreference_2006_v
11792       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11793 
11794       -- get the max timestamp value of the hercules view
11795       CURSOR c_max_timestamp IS
11796       SELECT MAX(timestamp)
11797       FROM igs_uc_ivgreference_2006_v  ;
11798 
11799       -- Variables
11800       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11801       l_new_max_timestamp igs_uc_ivgreference_2006_v.timestamp%TYPE ;
11802       l_count NUMBER ;
11803 
11804       l_appno      igs_uc_irefrnc_ints.appno%TYPE;
11805       l_checkdigit NUMBER;
11806 
11807   BEGIN
11808        -- set syncronization required to false
11809        g_sync_reqd := FALSE;
11810        l_count := 0 ;
11811 
11812       -- log message that this view is being loaded
11813       log_start( 'IVGREFERENCE ON ') ;
11814 
11815       -- Get the old timestamp for this view in the configured cycle
11816       Herc_timestamp_exists('IVGREFERENCE', p_old_timestamp) ;
11817 
11818        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11819       FOR c_ivgreference_rec IN c_ivgreference(p_old_timestamp) LOOP
11820               -- set x_sync_read to true if the loop is entered even once
11821               g_sync_reqd := TRUE;
11822 
11823               IF  is_valid(c_ivgreference_rec.appno,'IVGREFERENCE','APPNO','NUMBER') THEN
11824 
11825                   get_appno(c_ivgreference_rec.appno, NULL, l_appno, l_checkdigit);
11826 
11827                   -- Obsolete matching records in interface table with status N
11828                   UPDATE igs_uc_irefrnc_ints SET record_status = 'O'
11829                   WHERE record_status = 'N' AND appno = l_appno
11830                   AND refereename = c_ivgreference_rec.refereename ;
11831 
11832                   -- copy hercules record into interface table with record status N
11833                   INSERT INTO igs_uc_irefrnc_ints ( appno,
11834                                                     refereename,
11835                                                     refereepost,
11836                                                     estabname,
11837                                                     address1,
11838                                                     address2,
11839                                                     address3,
11840                                                     address4,
11841                                                     telephone,
11842                                                     fax,
11843                                                     email,
11844                                                     statement,
11845                                                     record_status,
11846                                                     error_code
11847                                                      )
11848                     VALUES (                        l_appno,
11849                                                     c_ivgreference_rec.refereename,
11850                                                     c_ivgreference_rec.refereepost,
11851                                                     c_ivgreference_rec.estabname,
11852                                                     c_ivgreference_rec.address1,
11853                                                     c_ivgreference_rec.address2,
11854                                                     c_ivgreference_rec.address3,
11855                                                     c_ivgreference_rec.address4,
11856                                                     c_ivgreference_rec.telephone,
11857                                                     c_ivgreference_rec.fax,
11858                                                     c_ivgreference_rec.email,
11859                                                     c_ivgreference_rec.statement,
11860                                                     'N',
11861                                                     NULL
11862                                                      ) ;
11863                   -- increment count of records
11864                   l_count := l_count + 1;
11865 
11866               END IF;
11867 
11868       END LOOP ;
11869 
11870       IF g_sync_reqd THEN
11871               -- get the max timestamp of this hercules view
11872               OPEN c_max_timestamp ;
11873               FETCH c_max_timestamp INTO l_new_max_timestamp ;
11874               CLOSE c_max_timestamp ;
11875 
11876                -- update /insert the timestamp record with new max timestamp
11877                ins_upd_timestamp ('IVGREFERENCE', l_new_max_timestamp) ;
11878 
11879               -- log message that this view has been loaded
11880                log_complete( 'IVGREFERENCE', l_count) ;
11881       ELSE
11882                 -- log message that this view is already in sync and need not be loaded
11883                log_already_insync('IVGREFERENCE') ;
11884       END IF ;
11885       COMMIT;
11886 
11887   EXCEPTION
11888       WHEN OTHERS THEN
11889                ROLLBACK;
11890                write_to_log(SQLERRM);
11891                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
11892                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVGREFERENCE_2006');
11893                igs_ge_msg_stack.add;
11894                app_exception.raise_exception ;
11895   END   load_ivgreference_2006  ;
11896 
11897 
11898   PROCEDURE load_ivnreference_2006 IS
11899     /******************************************************************
11900      Created By      :  jbaber
11901      Date Created By :  16-Aug-05
11902      Purpose         :  loads each record in the hercules view ivnreference into the interface table
11903                         igs_uc_irefrnc_ints with record status N
11904      Known limitations,enhancements,remarks:
11905      Change History
11906      Who       When         What
11907     ***************************************************************** */
11908 
11909       -- Get all the records from hercules  view whose timestamp is > passed timestamp
11910       -- or get all the records in hercules view if the timestamp passed is null
11911       CURSOR c_ivnreference ( p_timestamp igs_uc_hrc_timstmps.timestamp%TYPE ) IS
11912       SELECT     appno
11913                  ,timestamp
11914                  ,DECODE(RTRIM(refereename),NULL, RPAD('*',LENGTH(refereename),'*'), RTRIM(refereename)) refereename
11915                  ,RTRIM(refereepost) refereepost
11916                  ,RTRIM(estabname) estabname
11917                  ,RTRIM(address1) address1
11918                  ,RTRIM(address2) address2
11919                  ,RTRIM(address3) address3
11920                  ,RTRIM(address4) address4
11921                  ,RTRIM(telephone) telephone
11922                  ,RTRIM(fax) fax
11923                  ,RTRIM(email) email
11924                  ,statement statement
11925       FROM  igs_uc_ivnreference_2006_v
11926       WHERE ( timestamp > p_timestamp OR p_timestamp IS NULL ) ;
11927 
11928       -- get the max timestamp value of the hercules view
11929       CURSOR c_max_timestamp IS
11930       SELECT MAX(timestamp)
11931       FROM igs_uc_ivnreference_2006_v  ;
11932 
11933       -- Variables
11934       p_old_timestamp igs_uc_hrc_timstmps.timestamp%TYPE  ;
11935       l_new_max_timestamp igs_uc_ivnreference_2006_v.timestamp%TYPE ;
11936       l_count NUMBER ;
11937 
11938       l_appno      igs_uc_irefrnc_ints.appno%TYPE;
11939       l_checkdigit NUMBER;
11940 
11941   BEGIN
11942        -- set syncronization required to false
11943        g_sync_reqd := FALSE;
11944        l_count := 0 ;
11945 
11946       -- log message that this view is being loaded
11947       log_start( 'IVNREFERENCE ON ') ;
11948 
11949       -- Get the old timestamp for this view in the configured cycle
11950       Herc_timestamp_exists('IVNREFERENCE', p_old_timestamp) ;
11951 
11952        -- create interface records for each record in the hercules view whose timestamp > old timestamp
11953       FOR c_ivnreference_rec IN c_ivnreference(p_old_timestamp) LOOP
11954               -- set x_sync_read to true if the loop is entered even once
11955               g_sync_reqd := TRUE;
11956 
11957               IF  is_valid(c_ivnreference_rec.appno,'IVNREFERENCE','APPNO','NUMBER') THEN
11958 
11959                   get_appno(c_ivnreference_rec.appno, NULL, l_appno, l_checkdigit);
11960 
11961                   -- Obsolete matching records in interface table with status N
11962                   UPDATE igs_uc_irefrnc_ints SET record_status = 'O'
11963                   WHERE record_status = 'N' AND appno = l_appno
11964                   AND refereename = c_ivnreference_rec.refereename ;
11965 
11966                   -- copy hercules record into interface table with record status N
11967                   INSERT INTO igs_uc_irefrnc_ints ( appno,
11968                                                     refereename,
11969                                                     refereepost,
11970                                                     estabname,
11971                                                     address1,
11972                                                     address2,
11973                                                     address3,
11974                                                     address4,
11975                                                     telephone,
11976                                                     fax,
11977                                                     email,
11978                                                     statement,
11979                                                     record_status,
11980                                                     error_code
11981                                                      )
11982                     VALUES (                        l_appno,
11983                                                     c_ivnreference_rec.refereename,
11984                                                     c_ivnreference_rec.refereepost,
11985                                                     c_ivnreference_rec.estabname,
11986                                                     c_ivnreference_rec.address1,
11987                                                     c_ivnreference_rec.address2,
11988                                                     c_ivnreference_rec.address3,
11989                                                     c_ivnreference_rec.address4,
11990                                                     c_ivnreference_rec.telephone,
11991                                                     c_ivnreference_rec.fax,
11992                                                     c_ivnreference_rec.email,
11993                                                     c_ivnreference_rec.statement,
11994                                                     'N',
11995                                                     NULL
11996                                                      ) ;
11997                   -- increment count of records
11998                   l_count := l_count + 1;
11999 
12000               END IF;
12001 
12002       END LOOP ;
12003 
12004       IF g_sync_reqd THEN
12005               -- get the max timestamp of this hercules view
12006               OPEN c_max_timestamp ;
12007               FETCH c_max_timestamp INTO l_new_max_timestamp ;
12008               CLOSE c_max_timestamp ;
12009 
12010                -- update /insert the timestamp record with new max timestamp
12011                ins_upd_timestamp ('IVNREFERENCE', l_new_max_timestamp) ;
12012 
12013               -- log message that this view has been loaded
12014                log_complete( 'IVNREFERENCE', l_count) ;
12015       ELSE
12016                 -- log message that this view is already in sync and need not be loaded
12017                log_already_insync('IVNREFERENCE') ;
12018       END IF ;
12019       COMMIT;
12020 
12021   EXCEPTION
12022       WHEN OTHERS THEN
12023                ROLLBACK;
12024                write_to_log(SQLERRM);
12025                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
12026                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_IVNREFERENCE_2006');
12027                igs_ge_msg_stack.add;
12028                app_exception.raise_exception ;
12029   END   load_ivnreference_2006  ;
12030 
12031 
12032   PROCEDURE load_main (
12033      errbuf                     OUT NOCOPY     VARCHAR2
12034     ,retcode                    OUT NOCOPY     NUMBER
12035     ,p_load_ref                 IN      VARCHAR2
12036     ,P_load_ext_ref             IN      VARCHAR2
12037     ,P_load_ucas_app            IN      VARCHAR2
12038     ,P_load_gttr_app            IN      VARCHAR2
12039     ,P_load_nmas_app            IN      VARCHAR2
12040      ) IS
12041 
12042     /******************************************************************
12043      Created By      :  smaddali
12044      Date Created By :   11-Jun-03
12045      Purpose         :   calls subprocedures to load each hercules view
12046      Known limitations,enhancements,remarks:
12047      Change History
12048      Who       When         What
12049      smaddali   18-Aug-03   Calling procedure load_ivstatement_2004 instead of 2003 for bug#3098810
12050      smaddali   04-Sep-03   Modified order of load_ivstarpqr_2003 call for bug#3122898
12051      jchakrab   27-Jul-04   Modified for UCFD308 - UCAS - 2005 Regulatory Changes
12052      jbaber     12-Aug-05   Modified for UC307 - HERCULES Small Systems Support
12053      anwest     18-JAN-06   Bug# 4950285 R12 Disable OSS Mandate
12054     ***************************************************************** */
12055 
12056       validate_cycle     BOOLEAN := TRUE;
12057 
12058   BEGIN
12059 
12060       --anwest 18-JAN-2006 Bug# 4950285 R12 Disable OSS Mandate
12061       IGS_GE_GEN_003.SET_ORG_ID;
12062 
12063       -- Get the configured and current cycle information and exit process if not found
12064       g_cyc_info_rec := NULL ;
12065       OPEN c_cyc_info ;
12066       FETCH c_cyc_info INTO g_cyc_info_rec ;
12067       CLOSE c_cyc_info ;
12068       IF g_cyc_info_rec.configured_cycle IS NULL OR g_cyc_info_rec.current_cycle IS NULL THEN
12069             fnd_message.set_name('IGS','IGS_UC_CYCLE_NOT_FOUND');
12070             errbuf  := fnd_message.get;
12071             fnd_file.put_line(fnd_file.log, errbuf);
12072             retcode := 2 ;
12073             RETURN ;
12074       END IF;
12075 
12076       -- Validate configured cycle for UCAS system
12077       IF p_load_ref = 'Y' OR P_load_ext_ref = 'Y' OR P_load_ucas_app = 'Y' THEN
12078           c_ucas_cycle_rec := NULL ;
12079           OPEN c_ucas_cycle('U');
12080           FETCH c_ucas_cycle INTO c_ucas_cycle_rec ;
12081           CLOSE c_ucas_cycle ;
12082           -- If hercules and our oss system are not configured to the same cycle then report error
12083           IF NVL(c_ucas_cycle_rec.entry_year,0) <> Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) THEN
12084               fnd_message.set_name('IGS','IGS_UC_CYCLES_NOT_SYNC');
12085               fnd_message.set_token('UCAS_CYCLE',Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) );
12086               fnd_message.set_token('HERC_CYCLE',NVL(c_ucas_cycle_rec.entry_year,0 ) );
12087               fnd_message.set_token('SYSTEM_CODE','UCAS');
12088               errbuf := fnd_message.get ;
12089               fnd_file.put_line(fnd_file.log,errbuf );
12090               validate_cycle := FALSE;
12091           END IF ;
12092       END IF;
12093 
12094       -- Validate configured cycle for GTTR system
12095       IF P_load_gttr_app = 'Y' THEN
12096           c_ucas_cycle_rec := NULL ;
12097           OPEN c_ucas_cycle('G');
12098           FETCH c_ucas_cycle INTO c_ucas_cycle_rec ;
12099           CLOSE c_ucas_cycle ;
12100           -- If hercules and our oss system are not configured to the same cycle then report error
12101           IF NVL(c_ucas_cycle_rec.entry_year,0) <> Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) THEN
12102               fnd_message.set_name('IGS','IGS_UC_CYCLES_NOT_SYNC');
12103               fnd_message.set_token('UCAS_CYCLE',Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) );
12104               fnd_message.set_token('HERC_CYCLE',NVL(c_ucas_cycle_rec.entry_year,0 ) );
12105               fnd_message.set_token('SYSTEM_CODE','GTTR');
12106               errbuf := fnd_message.get ;
12107               fnd_file.put_line(fnd_file.log,errbuf );
12108               validate_cycle := FALSE;
12109           END IF ;
12110       END IF;
12111 
12112       -- Validate configured cycle for NMAS system
12113       IF P_load_nmas_app = 'Y' THEN
12114           c_ucas_cycle_rec := NULL ;
12115           OPEN c_ucas_cycle('N');
12116           FETCH c_ucas_cycle INTO c_ucas_cycle_rec ;
12117           CLOSE c_ucas_cycle ;
12118           -- If hercules and our oss system are not configured to the same cycle then report error
12119           IF NVL(c_ucas_cycle_rec.entry_year,0) <> Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) THEN
12120               fnd_message.set_name('IGS','IGS_UC_CYCLES_NOT_SYNC');
12121               fnd_message.set_token('UCAS_CYCLE',Ltrim(Substr(g_cyc_info_rec.configured_cycle,3,2) ) );
12122               fnd_message.set_token('HERC_CYCLE',NVL(c_ucas_cycle_rec.entry_year,0 ) );
12123               fnd_message.set_token('SYSTEM_CODE','NMAS');
12124               errbuf := fnd_message.get ;
12125               fnd_file.put_line(fnd_file.log,errbuf );
12126               validate_cycle := FALSE;
12127           END IF ;
12128       END IF;
12129 
12130       -- If any of the configured cycle validations failed then exit process
12131       IF NOT validate_cycle THEN
12132           retcode := 2;
12133           RETURN;
12134       END IF;
12135 
12136       -- get the timestamps of hercules views from cvrefamendment
12137       g_refamend_timestamp := NULL ;
12138       IF g_cyc_info_rec.configured_cycle < '2007' THEN
12139           OPEN c_refamend_timestamp ;
12140           FETCH c_refamend_timestamp INTO g_refamend_timestamp ;
12141           IF c_refamend_timestamp%NOTFOUND THEN
12142               CLOSE c_refamend_timestamp ;
12143               fnd_message.set_name('IGS','IGS_UC_REFTIME_NOT_FOUND');
12144               errbuf  := fnd_message.get;
12145               fnd_file.put_line(fnd_file.log, errbuf);
12146               retcode := 2 ;
12147               RETURN ;
12148           ELSE
12149               CLOSE c_refamend_timestamp ;
12150           END IF ;
12151       ELSE
12152           OPEN c_refamend_timestamp_2007 ;
12153           FETCH c_refamend_timestamp_2007 INTO g_refamend_timestamp ;
12154           IF c_refamend_timestamp_2007%NOTFOUND THEN
12155               CLOSE c_refamend_timestamp_2007 ;
12156               fnd_message.set_name('IGS','IGS_UC_REFTIME_NOT_FOUND');
12157               errbuf  := fnd_message.get;
12158               fnd_file.put_line(fnd_file.log, errbuf);
12159               retcode := 2 ;
12160               RETURN ;
12161           ELSE
12162               CLOSE c_refamend_timestamp_2007 ;
12163           END IF ;
12164       END IF;
12165 
12166       -- get the timestamps of hercules views from cvgrefamendment
12167       -- for GTTR as per bug 4638126
12168       -- Only required if GTTR is set to Hercules
12169       OPEN c_ucas_interface('G');
12170       FETCH c_ucas_interface INTO c_ucas_interface_rec;
12171       CLOSE c_ucas_interface;
12172       IF c_ucas_interface_rec = 'H' THEN
12173           g_grefamend_timestamp := NULL ;
12174           OPEN c_grefamend_timestamp ;
12175           FETCH c_grefamend_timestamp INTO g_grefamend_timestamp ;
12176           IF c_grefamend_timestamp%NOTFOUND THEN
12177                 CLOSE c_grefamend_timestamp ;
12178                 fnd_message.set_name('IGS','IGS_UC_REFTIME_NOT_FOUND');
12179                 fnd_message.set_token('VIEW_NAME','CvGRefAmendments');
12180                 errbuf  := fnd_message.get;
12181                 fnd_file.put_line(fnd_file.log, errbuf);
12182                 retcode := 2 ;
12183                 RETURN ;
12184           ELSE
12185                 CLOSE c_grefamend_timestamp ;
12186           END IF ;
12187       END IF;
12188 
12189 
12190       -- Loading clearing Reference data if  P_load_ref is Y
12191       -- and the configured cycle is same as the current cycle
12192       IF (P_load_ref  = 'Y')  AND
12193          (g_cyc_info_rec.configured_cycle = g_cyc_info_rec.current_cycle) THEN
12194 
12195             -- when configuration cycle is 2003 then call respective sub procedures
12196             IF g_cyc_info_rec.configured_cycle = '2003'  THEN
12197                 load_cvcourse_2003 ;
12198                 load_cveblsubject_2003 ;
12199                 load_cvinstitution_2003 ;
12200                 load_cvjointadmissions_2003 ;
12201                 load_cvrefapr_2003 ;
12202                 load_cvrefawardbody_2003 ;
12203                 load_cvrefdis_2003 ;
12204                 load_cvreferror_2003 ;
12205                 load_cvrefestgroup_2003 ;
12206                 load_cvrefethnic_2003 ;
12207                 load_cvrefexam_2003 ;
12208                 load_cvreffee_2003 ;
12209                 load_cvrefkeyword_2003 ;
12210                 load_cvrefoeq_2003 ;
12211                 load_cvrefofferabbrev_2003 ;
12212                 load_cvrefoffersubj_2003 ;
12213                 load_cvrefpocc_2003 ;
12214                 load_cvrefrescat_2003 ;
12215                 load_cvrefschooltype_2003 ;
12216                 load_cvrefstatus_2003 ;
12217                 load_cvreftariff_2003 ;
12218                 load_cvrefucasgroup_2003 ;
12219                 load_cvschool_2003 ;
12220                 load_cvschoolcontact_2003 ;
12221                 load_uvcontact_2003 ;
12222                 load_uvcontgrp_2003 ;
12223                 load_uvcourse_2003 ;
12224                 load_uvcoursekeyword_2003 ;
12225                 load_uvcoursevacancies_2003 ;
12226                 load_uvcoursevacoptions_2003 ;
12227                 load_uvofferabbrev_2003 ;
12228                 -- this view is different for 2003 and 2004
12229                 load_uvinstitution_2003 ;
12230 
12231             -- when configuration cycle is 2004 or 2005 then call respective sub procedures
12232             ELSIF  g_cyc_info_rec.configured_cycle = '2004' OR g_cyc_info_rec.configured_cycle = '2005' THEN
12233                 load_cvcourse_2003 ;
12234                 load_cveblsubject_2003 ;
12235                 load_cvinstitution_2003 ;
12236                 load_cvjointadmissions_2003 ;
12237                 load_cvrefapr_2003 ;
12238                 load_cvrefawardbody_2003 ;
12239                 load_cvrefdis_2003 ;
12240                 load_cvreferror_2003 ;
12241                 load_cvrefestgroup_2003 ;
12242                 load_cvrefethnic_2003 ;
12243                 load_cvrefexam_2003 ;
12244                 load_cvreffee_2003 ;
12245                 load_cvrefkeyword_2003 ;
12246                 load_cvrefoeq_2003 ;
12247                 load_cvrefofferabbrev_2003 ;
12248                 load_cvrefoffersubj_2003 ;
12249                 load_cvrefpocc_2003 ;
12250                 load_cvrefrescat_2003 ;
12251                 load_cvrefschooltype_2003 ;
12252                 load_cvrefstatus_2003 ;
12253                 load_cvreftariff_2003 ;
12254                 load_cvrefucasgroup_2003 ;
12255                 load_cvschool_2003 ;
12256                 load_cvschoolcontact_2003 ;
12257                 load_uvcontact_2003 ;
12258                 load_uvcontgrp_2003 ;
12259                 load_uvcourse_2003 ;
12260                 load_uvcoursekeyword_2003 ;
12261                 load_uvcoursevacancies_2003 ;
12262                 load_uvcoursevacoptions_2003 ;
12263                 load_uvofferabbrev_2003 ;
12264                 -- 2004 specific views processing
12265                 load_uvinstitution_2004 ;
12266 
12267              -- when configuration cycle is 2006 then call respective sub procedures
12268             ELSIF  g_cyc_info_rec.configured_cycle = '2006' THEN
12269                 load_cvcourse_2003 ;
12270                 load_cveblsubject_2003 ;
12271                 load_cvinstitution_2003 ;
12272                 load_cvjointadmissions_2003 ;
12273                 load_cvrefapr_2003 ;
12274                 load_cvrefawardbody_2003 ;
12275                 load_cvrefdis_2003 ;
12276                 load_cvreferror_2003 ;
12277                 load_cvrefestgroup_2003 ;
12278                 load_cvrefethnic_2003 ;
12279                 load_cvrefexam_2003 ;
12280                 load_cvreffee_2003 ;
12281                 load_cvrefkeyword_2003 ;
12282                 load_cvrefoeq_2003 ;
12283                 load_cvrefofferabbrev_2003 ;
12284                 load_cvrefoffersubj_2003 ;
12285                 load_cvrefpocc_2003 ;
12286                 load_cvrefrescat_2003 ;
12287                 load_cvrefschooltype_2003 ;
12288                 load_cvrefstatus_2003 ;
12289                 load_cvreftariff_2003 ;
12290                 load_cvschool_2003 ;
12291                 load_cvschoolcontact_2003 ;
12292                 load_uvcourse_2003 ;
12293                 load_uvcoursekeyword_2003 ;
12294                 load_uvofferabbrev_2003 ;
12295                 load_uvinstitution_2004 ;
12296 
12297              -- when configuration cycle is 2007 then call respective sub procedures
12298             ELSIF  g_cyc_info_rec.configured_cycle = '2007' THEN
12299                 load_cvcourse_2003 ;
12300                 load_cveblsubject_2003 ;
12301                 load_cvinstitution_2003 ;
12302                 load_cvjointadmissions_2003 ;
12303                 load_cvrefapr_2003 ;
12304                 load_cvrefawardbody_2003 ;
12305                 load_cvrefdis_2003 ;
12306                 load_cvreferror_2003 ;
12307                 load_cvrefestgroup_2003 ;
12308                 load_cvrefethnic_2003 ;
12309                 load_cvrefexam_2003 ;
12310                 load_cvreffee_2003 ;
12311                 load_cvrefkeyword_2003 ;
12312                 load_cvrefoeq_2003 ;
12313                 load_cvrefofferabbrev_2003 ;
12314                 load_cvrefoffersubj_2003 ;
12315                 load_cvrefpocc_2003 ;
12316                 load_cvrefrescat_2003 ;
12317                 load_cvrefschooltype_2003 ;
12318                 load_cvrefstatus_2003 ;
12319                 load_cvreftariff_2003 ;
12320                 load_cvschool_2003 ;
12321                 load_cvschoolcontact_2003 ;
12322                 load_uvcourse_2003 ;
12323                 load_uvcoursekeyword_2003 ;
12324                 load_uvofferabbrev_2003 ;
12325                 load_uvinstitution_2004 ;
12326                 load_cvrefcountry_2007 ;
12327                 load_cvrefnationality_2007 ;
12328 
12329             -- when configuration cycle is 2008 , currently not coded
12330             ELSIF  g_cyc_info_rec.configured_cycle = '2008' THEN
12331                 NULL ;
12332             END IF ;
12333 
12334 
12335             -- GTTR Small System Reference Data
12336             OPEN c_ucas_interface('G');
12337             FETCH c_ucas_interface INTO c_ucas_interface_rec;
12338             CLOSE c_ucas_interface;
12339 
12340             -- Check system is configured to HERCULES
12341             IF c_ucas_interface_rec = 'H' THEN
12342 
12343                 IF g_cyc_info_rec.configured_cycle = '2006' THEN
12344                     -- Added cvgrefdegreesubj_2006 for bug 4638126
12345                     load_cvgrefdegreesubj_2006 ;
12346                 ELSIF g_cyc_info_rec.configured_cycle = '2007' THEN
12347                     load_cvgrefdegreesubj_2006 ;
12348                     load_cvgcourse_2007 ;
12349                 END IF;
12350             END IF;
12351 
12352 
12353             -- NMAS Small System Reference Data
12354             OPEN c_ucas_interface('N');
12355             FETCH c_ucas_interface INTO c_ucas_interface_rec;
12356             CLOSE c_ucas_interface;
12357 
12358             -- Check system is configured to HERCULES
12359             IF c_ucas_interface_rec = 'H' THEN
12360 
12361                 IF g_cyc_info_rec.configured_cycle = '2007' THEN
12362                     load_cvncourse_2007 ;
12363                 END IF;
12364             END IF;
12365 
12366       END IF ;
12367 
12368 
12369       -- Loading external reference Data if P_load_ext_ref is Y and
12370       -- the configured cycle is same as the current cycle
12371       IF   (P_load_ext_ref = 'Y') AND
12372            (g_cyc_info_rec.configured_cycle = g_cyc_info_rec.current_cycle) THEN
12373 
12374             -- when configuration cycle is 2003 then call respective sub procedures
12375             IF g_cyc_info_rec.configured_cycle = '2003'  THEN
12376                 load_cvrefpre2000pocc_2003 ;
12377                 load_cvrefsocialclass_2003 ;
12378                 load_cvrefsocioeconomic_2003 ;
12379                 load_cvrefsubj_2003 ;
12380 
12381             -- when configuration cycle is 2004 or 2005 then call respective sub procedures
12382             ELSIF  g_cyc_info_rec.configured_cycle = '2004' OR g_cyc_info_rec.configured_cycle = '2005' THEN
12383                 load_cvrefpre2000pocc_2003 ;
12384                 load_cvrefsocialclass_2003 ;
12385                 load_cvrefsocioeconomic_2003 ;
12386                 load_cvrefsubj_2003 ;
12387 
12388             -- when configuration cycle is 2006 then call respective sub procedures
12389             ELSIF  g_cyc_info_rec.configured_cycle = '2006' OR g_cyc_info_rec.configured_cycle = '2007' THEN
12390                 load_cvrefsocialclass_2003 ;
12391                 load_cvrefsocioeconomic_2003 ;
12392                 load_cvrefsubj_2003 ;
12393 
12394             -- when configuration cycle is 2007, currently not coded
12395             ELSIF  g_cyc_info_rec.configured_cycle = '2008'  THEN
12396                 NULL ;
12397             END IF;
12398 
12399       END IF ;
12400 
12401       -- Loading UCAS Application Data only when P_load_ucas_app = 'Y'
12402       IF P_load_ucas_app = 'Y' THEN
12403 
12404             OPEN c_ucas_interface('U');
12405             FETCH c_ucas_interface INTO c_ucas_interface_rec;
12406             CLOSE c_ucas_interface;
12407 
12408             IF c_ucas_interface_rec = 'H' THEN
12409 
12410                  -- when configuration cycle is 2003 then call respective sub procedures
12411                  -- smaddali has changed the order of loading StarPQR records for bug#3122898
12412                  -- because starpqr is being loaded based on ivqualification.timestamp. So please donot change the order
12413                  IF  g_cyc_info_rec.configured_cycle = '2003' THEN
12414                      load_ivoffer_2003 ;
12415                      load_ivstarpqr_2003 ;
12416                      load_ivqualification_2003 ;
12417                      load_ivstara_2003 ;
12418                      load_ivstarc_2003 ;
12419                      load_ivstarh_2003 ;
12420                      load_ivstark_2003 ;
12421                      load_ivstarn_2003 ;
12422                      load_ivstarx_2003 ;
12423                      load_ivstarz1_2003 ;
12424                      load_ivstarz2_2003 ;
12425                      -- these views are different for 2003 and 2004
12426                      load_ivstarw_2003 ;
12427                      load_ivstatement_2003 ;
12428 
12429                  -- when configuration cycle is 2004 or 2005 then call respective sub procedures
12430                  ELSIF g_cyc_info_rec.configured_cycle = '2004' OR g_cyc_info_rec.configured_cycle = '2005' THEN
12431                     load_ivoffer_2003 ;
12432                     load_ivstarpqr_2003 ;
12433                     load_ivqualification_2003 ;
12434                     load_ivstara_2003 ;
12435                     load_ivstarc_2003 ;
12436                     load_ivstarh_2003 ;
12437                     load_ivstark_2003 ;
12438                     load_ivstarn_2003 ;
12439                     load_ivstarx_2003 ;
12440                     load_ivstarz1_2003 ;
12441                     load_ivstarz2_2003 ;
12442                     -- 2004 specific views processing
12443                     load_ivreference_2004 ;
12444                     load_ivformquals_2004 ;
12445                     load_ivstarw_2004 ;
12446                     -- smaddali calling procedure 2004 , for bug#3098810
12447                     load_ivstatement_2004 ;
12448 
12449                 -- when configuration cycle is 2006 then call respective sub procedures
12450                 ELSIF g_cyc_info_rec.configured_cycle = '2006' THEN
12451                     load_ivoffer_2003 ;
12452                     load_ivstarpqr_2006 ; -- 29-MAY-2006 anwest Bug #5190520 UCTD320 - UCAS 2006 CLEARING ISSUES
12453                     load_ivqualification_2003 ;
12454                     load_ivstara_2006 ;  -- updated for 2006
12455                     load_ivstarc_2003 ;
12456                     load_ivstarh_2003 ;
12457                     load_ivstark_2003 ;
12458                     load_ivstarn_2003 ;
12459                     load_ivstarx_2003 ;
12460                     load_ivstarz1_2003 ;
12461                     load_ivstarw_2004 ;
12462                     load_ivstatement_2004 ;
12463                     -- 2006 specific views processing
12464                     load_ivreference_2006 ;
12465                     load_ivformquals_2006 ;
12466 
12467             -- when configuration cycle is 2007 then call respective sub procedures
12468             ELSIF g_cyc_info_rec.configured_cycle = '2007' THEN
12469                     load_ivoffer_2003 ;
12470                     load_ivstarpqr_2006 ;
12471                     load_ivqualification_2003 ;
12472                     load_ivstarc_2003 ;
12473                     load_ivstarh_2003 ;
12474                     load_ivstarx_2003 ;
12475                     load_ivstarz1_2003 ;
12476                     load_ivstarw_2004 ;
12477                     load_ivstatement_2004 ;
12478                     load_ivreference_2006 ;
12479                     load_ivformquals_2006 ;
12480                     -- 2007 specific view processing
12481                     load_ivstara_2007 ;
12482                     load_ivstark_2007 ;
12483                     load_ivstarn_2007 ;
12484 
12485                  -- when configuration cycle is 2008 , currently not coded
12486                  ELSIF g_cyc_info_rec.configured_cycle = '2008' THEN
12487                     NULL ;
12488                  END IF ;
12489 
12490           ELSE
12491 
12492               -- UCAS interface is MARVIN so log warning.
12493               fnd_message.set_name('IGS','IGS_UC_MARVIN_INTERFACE');
12494               fnd_message.set_token('SYSTEM_CODE','UCAS');
12495               fnd_message.set_token('PROCESS','load');
12496               fnd_file.put_line(fnd_file.log,fnd_message.get );
12497               retcode := 1;
12498 
12499           END IF;
12500 
12501 
12502       END IF;
12503 
12504 
12505       -- Loading GTTR Application Data only when P_load_gttr_app = 'Y'
12506       IF P_load_gttr_app = 'Y' THEN
12507 
12508           OPEN c_ucas_interface('G');
12509           FETCH c_ucas_interface INTO c_ucas_interface_rec;
12510           CLOSE c_ucas_interface;
12511 
12512           IF c_ucas_interface_rec = 'H' THEN
12513 
12514               -- When configuration cycle is 2006 then call respective sub procedures
12515               IF g_cyc_info_rec.configured_cycle = '2006' THEN
12516                   load_ivgoffer_2006 ;
12517                   load_ivgstara_2006 ;
12518                   load_ivgstarg_2006 ;
12519                   load_ivgstarh_2006 ;
12520                   load_ivgstark_2006 ;
12521                   load_ivgstarn_2006 ;
12522                   load_ivgstarw_2006 ;
12523                   load_ivgstarx_2006 ;
12524                   load_ivgstatement_2006 ;
12525                   load_ivgreference_2006 ;
12526 
12527               -- When configuration cycle is 2007 then call respective sub procedures
12528               ELSIF g_cyc_info_rec.configured_cycle = '2007' THEN
12529                   load_ivgoffer_2006 ;
12530                   load_ivgstara_2007 ;
12531                   load_ivgstarg_2006 ;
12532                   load_ivgstarh_2006 ;
12533                   load_ivgstark_2007 ;
12534                   load_ivgstarn_2007 ;
12535                   load_ivgstarw_2007 ;
12536                   load_ivgstarx_2006 ;
12537                   load_ivgstatement_2006 ;
12538                   load_ivgreference_2006 ;
12539 
12540               -- when configuration cycle is 2008 , currently not coded
12541               ELSIF g_cyc_info_rec.configured_cycle = '2008' THEN
12542                   NULL ;
12543               END IF ;
12544 
12545           ELSE
12546 
12547               -- GTTR interface is MARVIN so log warning.
12548               fnd_message.set_name('IGS','IGS_UC_MARVIN_INTERFACE');
12549               fnd_message.set_token('SYSTEM_CODE','GTTR');
12550               fnd_message.set_token('PROCESS','load');
12551               fnd_file.put_line(fnd_file.log,fnd_message.get );
12552               retcode := 1;
12553 
12554           END IF;
12555 
12556       END IF;
12557 
12558       -- Loading NMAS Application Data only when P_load_nmas_app = 'Y'
12559       IF P_load_nmas_app = 'Y' THEN
12560 
12561           OPEN c_ucas_interface('N');
12562           FETCH c_ucas_interface INTO c_ucas_interface_rec;
12563           CLOSE c_ucas_interface;
12564 
12565           IF c_ucas_interface_rec = 'H' THEN
12566 
12567               -- When configuration cycle is 2006 then call respective sub procedures
12568               IF g_cyc_info_rec.configured_cycle = '2006' THEN
12569                   load_ivnoffer_2006 ;
12570                   load_ivnstara_2006 ;
12571                   load_ivnstarc_2006 ;
12572                   load_ivnstarh_2006 ;
12573                   load_ivnstark_2006 ;
12574                   load_ivnstarn_2006 ;
12575                   load_ivnstarw_2006 ;
12576                   load_ivnstarx_2006 ;
12577                   load_ivnstarz1_2006 ;
12578                   load_ivnstatement_2006 ;
12579                   load_ivnreference_2006 ;
12580 
12581               -- When configuration cycle is 2007 then call respective sub procedures
12582               ELSIF g_cyc_info_rec.configured_cycle = '2007' THEN
12583                   load_ivnoffer_2006 ;
12584                   load_ivnstara_2007 ;
12585                   load_ivnstarc_2006 ;
12586                   load_ivnstarh_2006 ;
12587                   load_ivnstark_2007 ;
12588                   load_ivnstarn_2007 ;
12589                   load_ivnstarw_2007 ;
12590                   load_ivnstarx_2006 ;
12591                   load_ivnstarz1_2006 ;
12592                   load_ivnstatement_2006 ;
12593                   load_ivnreference_2006 ;
12594 
12595               -- when configuration cycle is 2008 , currently not coded
12596               ELSIF g_cyc_info_rec.configured_cycle = '2008' THEN
12597                   NULL ;
12598               END IF ;
12599 
12600           ELSE
12601 
12602               -- NMAS interface is MARVIN so log warning.
12603               fnd_message.set_name('IGS','IGS_UC_MARVIN_INTERFACE');
12604               fnd_message.set_token('SYSTEM_CODE','NMAS');
12605               fnd_message.set_token('PROCESS','load');
12606               fnd_file.put_line(fnd_file.log,fnd_message.get );
12607               retcode := 1;
12608 
12609           END IF;
12610 
12611 
12612       END IF;
12613 
12614 
12615   EXCEPTION
12616         WHEN OTHERS THEN
12617                ROLLBACK;
12618                write_to_log(SQLERRM);
12619                retcode := 2;
12620                Fnd_Message.set_name('IGS','IGS_GE_UNHANDLED_EXP');
12621                fnd_message.set_token('NAME', 'IGS_UC_LOAD_HERCULES_DATA.LOAD_MAIN');
12622                errbuf  := fnd_message.get;
12623                igs_ge_msg_stack.conc_exception_hndl;
12624 
12625   END load_main;
12626 
12627 END igs_uc_load_hercules_data;