The following lines contain the word 'select', 'insert', 'update' or 'delete':
update_flag VARCHAR2(1) := 'N';
SELECT cdate,shift_no,
decode(sign(ftime - p_from_date),-1,p_from_date,ftime) from_time,
decode(sign(ttime - v_to_time),-1,ttime,v_to_time) to_time
FROM
(
SELECT bsd.shift_date cdate,
bsd.shift_num shift_no,
(bsd.shift_date + (bst.from_time/86400)) ftime,
(bsd.shift_date + (bst.to_time/86400)) ttime
FROM bom_calendars bc,
bom_shift_dates bsd,
bom_shift_times bst
WHERE bsd.calendar_code = bc.calendar_code
AND bst.calendar_code = bsd.calendar_code
AND bsd.shift_num = bst.shift_num
AND bsd.seq_num is not null
AND bc.calendar_code = p_cal_code
)
WHERE 1= 1
AND (
(ftime between p_from_date and v_to_time)
OR
(ttime between p_from_date and v_to_time)
)
ORDER BY cdate,from_time ;
SELECT resource_units,
decode(sign(from_date - p_from_date),-1,p_from_date,from_date) from_time,
decode(sign(to_date - v_to_time),-1,to_date,v_to_time) to_time
FROM gmp_rsrc_unavail_dtl_v
WHERE resource_id = p_resource_id
AND
(
(from_date between p_from_date and v_to_time)
OR
(to_date between p_from_date and v_to_time)
)
ORDER BY from_time;
SELECT assigned_qty FROM cr_rsrc_dtl
WHERE resource_id = p_resource_id;
SELECT to_char(p_to_date,'HH24:MI:SS')
INTO temp_date
FROM DUAL ;
cal_rec.delete;
/* Delete the Unavailable PL/SQL table before start */
if unavail_rec.COUNT > 0
then
unavail_rec.delete;
/* Delete the Out Cal Rec PL/SQL table before start */
if p_rec.COUNT > 0
then
p_rec.delete;
end of this package will do the necessary inserts */
NO_NO_EXCP := 'Y' ;
Insert the resultant into Out Tbl Which is a PL/SQL table
end loop;
skip all the calculations and gets directly inserted into
the ST table - The assumption is that the resource ids
will be coming in the same order in the Unvailable Cursor
and the resources cursor - This is taken care in both the
Cursors */
/* { ==A==
Now check if the Cal date from time is less than Unavailable
from time - Here the comparisons are made with both date
and Time
*/
IF (cal_rec(c).cal_from_date <= unavail_rec(u).u_from_date)
THEN
/* If the calendar from time is Yes, then check if the
Calendar end time is greater than unavailable from time
*/
IF /* { Special 1 */
(cal_rec(c).cal_to_date > unavail_rec(u).u_from_date)
THEN
/* {
Check if the Calendar to time is Less than Unavailable
to date
*/
IF /* == A 2 and A3 */
(cal_rec(c).cal_to_date <= unavail_rec(u).u_to_date)
THEN
/* shorten the shift (remaining shift is consumed)
and insert the record */
stmt_no := 30;
/* Break the shift and insert firt record */
/* Assign new values to start and end times of
the cal_rec shift */
/* preserve the counter u into u1 */
/* As you continue to loop check resource_id */
/* Break the shift and insert first record */
stmt_no := 40;
IF update_flag = 'N' THEN
update_flag := 'Y' ;
/* Call the Insert Procedure */
u1 := u ;
IF update_flag = 'N' THEN
update_flag := 'Y' ;
/* Insert into PL/SQL TABLE while looping through the cal_rec
from current position onwards */
/* c := c + 1 ; */
IF update_flag = 'Y'
THEN
cal_rec(c).cal_from_date := temp_from_time ;
update_flag := 'N';
IF update_flag = 'Y'
THEN
cal_rec(c).cal_from_date := temp_from_time ;
update_flag := 'N';
log_message('Error in Test rsrc Insert: '||stmt_no);
SELECT organization_id, calendar_code
FROM cr_rsrc_dtl
WHERE resource_id = p_resource_id
AND delete_mark = 0
AND inactive_ind = 0 ;
SELECT calendar_code
FROM mtl_parameters
WHERE organization_id = l_organization_id ;