[Home] [Help]
33: FROM igs_ad_imp_batch_det
34: WHERE created_by = FND_GLOBAL.USER_ID;
35: l_max_batch_id NUMBER;
36:
37: CURSOR cur_chk_batch (cp_batch_id igs_ad_interface_ctl.batch_id%TYPE) IS
38: SELECT batch_id
39: FROM igs_ad_interface_ctl
40: WHERE batch_id = cp_batch_id;
41: rec_chk_batch cur_chk_batch%ROWTYPE;
35: l_max_batch_id NUMBER;
36:
37: CURSOR cur_chk_batch (cp_batch_id igs_ad_interface_ctl.batch_id%TYPE) IS
38: SELECT batch_id
39: FROM igs_ad_interface_ctl
40: WHERE batch_id = cp_batch_id;
41: rec_chk_batch cur_chk_batch%ROWTYPE;
42: BEGIN
43:
44: -- If any records are available for that user in the interface table then get the max batch_id.
45: OPEN cur_max_batch_id;
46: FETCH cur_max_batch_id INTO l_max_batch_id ;
47: IF ( NVL(l_max_batch_id,0) > 0 ) THEN
48: -- For this batch_id check in igs_ad_interface_ctl if there is a record
49: OPEN cur_chk_batch(l_max_batch_id) ;
50: FETCH cur_chk_batch INTO rec_chk_batch ;
51: IF (cur_chk_batch%FOUND) THEN
52: p_batch_id := 0; -- created new Batch ID.
49: OPEN cur_chk_batch(l_max_batch_id) ;
50: FETCH cur_chk_batch INTO rec_chk_batch ;
51: IF (cur_chk_batch%FOUND) THEN
52: p_batch_id := 0; -- created new Batch ID.
53: ELSE -- No record found in igs_ad_interface_ctl for this batch_id
54: p_batch_id := l_max_batch_id; -- Return the existing MAX Batch ID.
55: END IF;
56: CLOSE cur_chk_batch ;
57: ELSE -- No record is available for that user in the interface table