37: ;
38:
39: CURSOR g_latest_job_run_id_csr IS
40: SELECT MAX(jrn.job_run_id) job_run_id
41: FROM oki_job_runs jrn
42: ;
43: rec_g_latest_job_run_id_csr g_latest_job_run_id_csr%ROWTYPE ;
44:
45: --
518: ) IS
519:
520: -- Cursor declaration
521: CURSOR l_seq_num_csr IS
522: SELECT oki_job_runs_s1.nextval seq
523: FROM dual
524: ;
525: rec_l_seq_num l_seq_num_csr%ROWTYPE ;
526:
538:
539: BEGIN
540: l_retcode := '0' ;
541: l_sysdate := sysdate;
542: l_table_name := 'OKI_JOB_RUNS';
543:
544: l_loc := 'Get job_run_id sequence number.' ;
545: OPEN l_seq_num_csr ;
546: FETCH l_seq_num_csr INTO rec_l_seq_num ;
551: l_sequence := rec_l_seq_num.seq ;
552: CLOSE l_seq_num_csr ;
553:
554: l_loc := 'Inserting into ' || l_table_name ;
555: INSERT INTO oki_job_runs (
556: job_run_id
557: , job_start_date
558: , job_end_date
559: , job_curr_start_date
688: --
689: -- This procedure checks if this is the initial first time job run.
690: -- If it is, then it:
691: -- 1. Truncates the oki base tables
692: -- 2. Seeds the oki_job_runs table with a dummy record
693: -- 3. Updates the oki_refreshs table job_run id with
694: -- the dummy job_run_id
695: --
696: ---------------------------------------------------------------------
717:
718: -- Cursor to check if this is the first time the job has ever run
719: CURSOR l_job_run_count_csr IS
720: SELECT count(*) jbrn_count
721: FROM oki_job_runs jrn ;
722: rec_l_job_run_count_csr l_job_run_count_csr%ROWTYPE ;
723:
724: BEGIN
725: l_retcode := '0' ;
898: -- Log the location within the procedure where the error occurred
899: fnd_message.set_name( application => 'OKI'
900: , name => 'OKI_OBJ_ALREADY_RFR_MSG') ;
901: fnd_message.set_token( token => 'OBJECT_NAME'
902: , value => 'OKI_JOB_RUNS') ;
903: fnd_file.put_line( which => fnd_file.log
904: , buff => fnd_message.get) ;
905:
906: WHEN l_excp_exit_immediate THEN
965: ) IS
966: SELECT
967: job_curr_start_date
968: , job_curr_end_date
969: FROM oki_job_runs jrn
970: WHERE jrn.job_run_id = p_job_run_id ;
971: rec_l_job_curr_date l_job_curr_date_csr%ROWTYPE ;
972:
973: BEGIN
1500: ---------------------------------------------------------------------
1501: -- procedure job_start
1502: --
1503: -- Starts the refresh process
1504: -- 1. Creates an oki_job_runs record
1505: -- 2. Loads the oki_job_run_dtl table with the records to delete
1506: -- and insert into the oki base tables.
1507: ---------------------------------------------------------------------
1508: PROCEDURE job_start
1529: l_table_owner VARCHAR2(30) ;
1530:
1531: -- Cursor declaration
1532: CURSOR l_seq_num_csr IS
1533: SELECT oki_job_runs_s1.nextval seq
1534: FROM dual
1535: ;
1536: rec_l_seq_num l_seq_num_csr%ROWTYPE ;
1537:
1564: CLOSE l_seq_num_csr ;
1565:
1566: SELECT least(jrn.job_curr_end_date + (1/(24 * 60 * 60)), l_sysdate)
1567: INTO l_job_start_date
1568: FROM oki_job_runs jrn
1569: WHERE jrn.job_run_id = (
1570: SELECT MAX(jrn1.job_run_id)
1571: FROM oki_job_runs jrn1
1572: WHERE jrn1.job_run_id < l_sequence ) ;
1567: INTO l_job_start_date
1568: FROM oki_job_runs jrn
1569: WHERE jrn.job_run_id = (
1570: SELECT MAX(jrn1.job_run_id)
1571: FROM oki_job_runs jrn1
1572: WHERE jrn1.job_run_id < l_sequence ) ;
1573:
1574: l_job_end_date := LEAST(nvl(p_job_start_date, sysdate ),l_sysdate);
1575:
1587: , buff => 'Job start date is greater than job end date...Hence exiting');
1588: RAISE l_excp_exit_immediate;
1589: END IF;
1590:
1591: l_loc := 'Inserting into oki_job_runs' ;
1592: INSERT INTO oki_job_runs (
1593: job_run_id
1594: , job_start_date
1595: , job_end_date
1588: RAISE l_excp_exit_immediate;
1589: END IF;
1590:
1591: l_loc := 'Inserting into oki_job_runs' ;
1592: INSERT INTO oki_job_runs (
1593: job_run_id
1594: , job_start_date
1595: , job_end_date
1596: , job_curr_start_date
1614: , l_sysdate
1615: , FND_GLOBAL.USER_ID
1616: , NULL
1617: , g_request_id
1618: FROM oki_job_runs jrn1
1619: WHERE jrn1.job_run_id = (
1620: SELECT MAX(jrn3.job_run_id)
1621: FROM oki_job_runs jrn3
1622: WHERE jrn3.job_run_id < l_sequence ) ;
1617: , g_request_id
1618: FROM oki_job_runs jrn1
1619: WHERE jrn1.job_run_id = (
1620: SELECT MAX(jrn3.job_run_id)
1621: FROM oki_job_runs jrn3
1622: WHERE jrn3.job_run_id < l_sequence ) ;
1623: COMMIT ;
1624:
1625: l_loc := 'Calling get_load_date_range.' ;
1698: ---------------------------------------------------------------------
1699: -- procedure initial_load_job_start
1700: --
1701: -- Starts the refresh process
1702: -- 1. Creates an oki_job_runs record
1703: -- 2. Loads the oki_job_run_dtl table with the records
1704: -- to insert into the oki base tables.
1705: ---------------------------------------------------------------------
1706:
1724: l_table_owner VARCHAR2(30);
1725:
1726: -- Cursor declaration
1727: CURSOR l_seq_num_csr IS
1728: SELECT oki_job_runs_s1.nextval seq
1729: FROM dual
1730: ;
1731: rec_l_seq_num l_seq_num_csr%ROWTYPE ;
1732:
1744: , buff => 'Parameter : start date '|| fnd_date.date_to_displayDT(l_job_start_date));
1745: fnd_file.put_line( which => fnd_file.log
1746: , buff => 'Parameter : end date '|| fnd_date.date_to_displayDT(l_sysdate));
1747:
1748: l_table_name := 'OKI_JOB_RUNS' ;
1749: l_loc := 'Calling truncate_table with ' || l_table_owner || '.' || l_table_name ;
1750: truncate_table( p_table_owner => l_table_owner
1751: , p_table_name => l_table_name
1752: , x_errbuf => x_errbuf
1778: END IF ;
1779: l_sequence := rec_l_seq_num.seq ;
1780: CLOSE l_seq_num_csr ;
1781:
1782: l_loc := 'Inserting into oki_job_runs' ;
1783:
1784: INSERT INTO oki_job_runs (
1785: job_run_id
1786: , job_start_date
1780: CLOSE l_seq_num_csr ;
1781:
1782: l_loc := 'Inserting into oki_job_runs' ;
1783:
1784: INSERT INTO oki_job_runs (
1785: job_run_id
1786: , job_start_date
1787: , job_end_date
1788: , job_curr_start_date
1992:
1993: -- Cursor to get the latest job_run_id
1994: CURSOR l_job_run_id_csr IS
1995: SELECT jrn1.job_run_id, jrn1.job_end_date
1996: FROM oki_job_runs jrn1
1997: WHERE jrn1.job_run_id = ( SELECT MAX(jrn2.job_run_id)
1998: FROM oki_job_runs jrn2)
1999: ;
2000: rec_l_job_run_id l_job_run_id_csr%ROWTYPE ;
1994: CURSOR l_job_run_id_csr IS
1995: SELECT jrn1.job_run_id, jrn1.job_end_date
1996: FROM oki_job_runs jrn1
1997: WHERE jrn1.job_run_id = ( SELECT MAX(jrn2.job_run_id)
1998: FROM oki_job_runs jrn2)
1999: ;
2000: rec_l_job_run_id l_job_run_id_csr%ROWTYPE ;
2001:
2002: BEGIN
2014: CLOSE l_job_run_id_csr ;
2015:
2016: l_loc := 'Determining if job_end_date needs to be set.' ;
2017: IF l_job_end_date IS NULL THEN
2018: l_loc := 'Updating oki_job_runs.' ;
2019: UPDATE oki_job_runs jrn1
2020: SET job_end_date = sysdate
2021: , last_update_date = sysdate
2022: WHERE job_run_id = l_job_run_id ;
2015:
2016: l_loc := 'Determining if job_end_date needs to be set.' ;
2017: IF l_job_end_date IS NULL THEN
2018: l_loc := 'Updating oki_job_runs.' ;
2019: UPDATE oki_job_runs jrn1
2020: SET job_end_date = sysdate
2021: , last_update_date = sysdate
2022: WHERE job_run_id = l_job_run_id ;
2023: END IF ;
2100:
2101: -- Cursor to get the latest job_run_id
2102: CURSOR l_job_run_id_csr IS
2103: SELECT max(jrn.job_run_id) job_run_id
2104: FROM oki_job_runs jrn
2105: ;
2106: rec_l_job_run_id l_job_run_id_csr%ROWTYPE ;
2107:
2108: -- Cursor to get the job_run_id from the oki_refreshs table
2424:
2425: BEGIN
2426: select max(job_run_id)
2427: into l_job_run_id
2428: from oki_job_runs;
2429: EXCEPTION
2430: WHEN NO_DATA_FOUND THEN
2431: retcode := '2';
2432: fnd_file.put_line(which => fnd_file.log