CREATE OR REPLACE FUNCTION TRAINING.c1c3flt_cat_grp2(cof IN VARCHAR2)
RETURN NUMBER
IS
CAT_GRP NUMBER;
BEGIN
IF cof BETWEEN '604' AND '607' THEN
CAT_GRP := 1;
ELSIF (cof IN ('610', '083', '084', '085')) OR (cof BETWEEN '615' and '619') OR
(cof BETWEEN '621' and '623') OR (cof BETWEEN '625' and '629') OR
(cof BETWEEN '631' and '634') THEN
CAT_GRP := 1;
ELSIF cof = '630' THEN
CAT_GRP := 1;
ELSIF (cof IN ('644', '699')) OR (cof BETWEEN '640' and '642') THEN
CAT_GRP := 1;
ELSIF (cof IN ('081', '082')) OR (cof BETWEEN '501' and '529') OR (cof BETWEEN '561' and '579') THEN
CAT_GRP := 1;
ELSIF cof IN ('086', '087', '080') THEN
CAT_GRP := 1;
ELSIF cof IN ('599', '593') THEN
CAT_GRP := 1;
ELSIF cof IN ('558', '598') THEN
CAT_GRP := 1;
ELSIF cof = '010' THEN
CAT_GRP := 1;
ELSIF cof BETWEEN '049' AND '056' THEN
CAT_GRP := 1;
ELSIF cof = '075' OR (cof BETWEEN '536' and '539') OR (cof BETWEEN '586' and '590') THEN
CAT_GRP := 1;
ELSIF (cof BETWEEN '531' and '533') OR (cof BETWEEN '581' and '583') THEN
CAT_GRP := 1;
ELSIF cof IN ('555', '595') THEN
CAT_GRP := 1;
ELSIF cof IN ('592', '552') THEN
CAT_GRP := 1;
ELSIF cof = '596' THEN
CAT_GRP := 1;
ELSIF cof BETWEEN '540' AND '548' THEN
CAT_GRP := 1;
ELSIF cof IN ('559', '551', '591', '594', '597', '553', '554', '556', '557') THEN
CAT_GRP := 1;
ELSIF (cof IN ('442', '448')) OR (cof BETWEEN '435' and '437') THEN
CAT_GRP := 2;
ELSIF (cof IN ('076', '472')) OR (cof BETWEEN '465' and '467') OR (cof BETWEEN '474' and '479') THEN
CAT_GRP := 2;
ELSIF (cof IN ('397', '403')) OR (cof BETWEEN '390' and '392') THEN
CAT_GRP := 2;
ELSIF (cof IN ('064', '078', '079', '322', '328')) OR (cof BETWEEN '315' and '317') THEN
CAT_GRP := 2;
ELSIF (cof IN ('028', '029', '128', '129', '312', '313')) OR (cof BETWEEN '300' and '302') THEN
CAT_GRP := 2;
ELSIF cof = '001' THEN
CAT_GRP := 2;
ELSIF cof = '021' THEN
CAT_GRP := 2;
ELSIF cof = '090' THEN
CAT_GRP := 2;
ELSIF cof = '107' THEN
CAT_GRP := 2;
ELSIF cof BETWEEN '161' AND '166' THEN
CAT_GRP := 2;
ELSIF cof = '030' THEN
CAT_GRP := 2;
ELSIF cof = '006' THEN
CAT_GRP := 2;
ELSIF cof = '004' THEN
CAT_GRP := 2;
ELSIF cof = '063' THEN
CAT_GRP := 2;
ELSIF cof = '005' THEN
CAT_GRP := 2;
ELSIF cof = '066' THEN
CAT_GRP := 2;
ELSIF cof = '045' THEN
CAT_GRP := 2;
ELSIF cof = '007' THEN
CAT_GRP := 3;
ELSIF cof = '130' THEN
CAT_GRP := 3;
ELSIF cof = '073' THEN
CAT_GRP := 3;
ELSIF cof = '070' THEN
CAT_GRP := 3;
ELSIF cof IN ('061', '062') THEN
CAT_GRP := 3;
ELSIF cof = '060' THEN
CAT_GRP := 3;
ELSIF cof = '008' THEN
CAT_GRP := 3;
ELSIF cof = '065' THEN
CAT_GRP := 3;
ELSIF cof IN ('019', '096', '098') THEN
CAT_GRP := 3;
ELSIF cof = '097' THEN
CAT_GRP := 3;
ELSIF cof IN ('018', '020') THEN
CAT_GRP := 3;
ELSIF cof = '074' THEN
CAT_GRP := 3;
ELSIF cof = '088' THEN
CAT_GRP := 3;
ELSIF cof = '089' THEN
CAT_GRP := 3;
ELSIF cof = '099' THEN
CAT_GRP := 3;
ELSIF (cof IN ('041', '044', '092', '093')) OR (cof BETWEEN '176' and '181') THEN
CAT_GRP := 3;
ELSIF cof IN ('046', '047', '048') THEN
CAT_GRP := 3;
ELSIF cof = '174' THEN
CAT_GRP := 3;
ELSIF cof IN ('168', '169') THEN
CAT_GRP := 3;
ELSIF cof IN ('153', '170', '171', '172', '173') THEN
CAT_GRP := 3;
ELSIF cof = '167' THEN
CAT_GRP := 3;
ELSIF cof = '105' THEN
CAT_GRP := 3;
END IF;
RETURN(CAT_GRP);
END;
/
CREATE OR REPLACE FUNCTION TRAINING.CHECKUSERTEAM(uid IN VARCHAR2,teamcode_mv IN VARCHAR2) RETURN number AS
CURSOR c1 IS SELECT * FROM us_userposn WHERE userid=uid;
c1_rec c1%ROWTYPE;
tmpstr1 varchar2(5) :='';
--tmpstr2 varchar2(3000) :='';
teamcode_mv_tmp varchar2(1000):='';
teamcode_mv_len number(2) :=0;
ptr number(2) :=1;
retVal number := 0;-- o= false
BEGIN
teamcode_mv_tmp :=teamcode_mv;
teamcode_mv_len := length(teamcode_mv);
while ptr<=teamcode_mv_len loop
begin
IF NOT c1%ISOPEN THEN
OPEN c1;
END IF;
tmpstr1:='';
while substr(teamcode_mv_tmp,1,1) != ';' loop
begin
tmpstr1 := tmpstr1||substr(teamcode_mv_tmp,1,1);
teamcode_mv_tmp :=substr(teamcode_mv_tmp,2,teamcode_mv_len);
ptr := ptr + 1;
end;
end loop;
/* DBMS_OUTPUT.PUT_LINE(tmpstr1);
DBMS_OUTPUT.PUT_LINE(uid);
SELECT TEAMCODE INTO tmpstr2 FROM US_USERPOSN WHERE USERID=uid and teamcode=tmpstr1;
if tmpstr2 is not null then
begin
retVal := true;
exit;
end;
end if;*/
--funcstr :=funcstr||tmpstr2||';;';
--DBMS_OUTPUT.PUT_LINE(uid);
LOOP
FETCH c1 INTO c1_rec;
EXIT WHEN c1%NOTFOUND;
IF c1_rec.teamcode = tmpstr1 THEN
retVal := 1;
EXIT;
END IF;
END LOOP;
CLOSE c1;
if retVal=1 then exit; end if;
while substr(teamcode_mv_tmp,1,1) = ';' loop
begin
teamcode_mv_tmp :=substr(teamcode_mv_tmp,2,teamcode_mv_len);
ptr := ptr + 1;
end;
end loop;
end;
end loop;
--DBMS_OUTPUT.PUT_LINE(uid);
--DBMS_OUTPUT.PUT_LINE(retVal);
RETURN retVal;
END;
/
CREATE OR REPLACE FUNCTION TRAINING.GET_LEAVEDURATIONSWITHDESC(leavedata VARCHAR2)
RETURN varchar2 IS LeaveDurations varchar2(1000);
v_counter number;
curr_char char(1);
--lgq
prev_char char(1);
get_first boolean;
get_second boolean;
curr_time_slot varchar2(10);
first_pos number;
cm_separator char(3);
v_leavetype VARCHAR2(100);
BEGIN
get_first := true;
get_second := false;
curr_time_slot := '';
cm_separator := ';; ';
curr_char := ' ';
for v_counter in 1..length(leavedata) loop
--lgq
prev_char := curr_char;
curr_char := substr(leavedata, v_counter, 1);
if (get_first = true and (curr_char = '4' OR curr_char = '5' OR curr_char = '6' OR curr_char = '7' OR curr_char = '8' OR curr_char = '9')) then
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter-1) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
SELECT valuedesc INTO v_leavetype FROM FW_co_dropdown WHERE colname = 'LEAVETYPE' AND colvalue = curr_char;
select LeaveDurations || v_leavetype || ' (' || curr_time_slot || '-' into LeaveDurations from dual;
get_first := false;
get_second := true;
first_pos := v_counter;
goto next_v_counter;
end if;
--lgq if (get_second = true and (curr_char = '0' OR curr_char = '1' OR curr_char = '2' OR curr_char = '3')) then
if (get_second = true and prev_char != curr_char) then
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter-1) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
if (curr_time_slot = '00:00:00') then
curr_time_slot := '23:59:59';
end if;
select LeaveDurations || curr_time_slot || ')' || cm_separator into LeaveDurations from dual;
get_first := true;
get_second := false;
--lgq start
if (curr_char = '4' or curr_char = '5' or curr_char = '6' or curr_char = '7' or curr_char='8' or curr_char='9') then
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter-1) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
SELECT valuedesc INTO v_leavetype FROM FW_co_dropdown WHERE colname = 'LEAVETYPE' AND colvalue = curr_char;
select LeaveDurations || v_leavetype || ' (' || curr_time_slot || '-' into LeaveDurations from dual;
get_first := false;
get_second := true;
first_pos := v_counter;
goto next_v_counter;
end if;
--lgq end
end if;
<
if (get_second = true) then
--lgq if (v_counter = length(leavedata) and (curr_char = '4' OR curr_char = '5' OR curr_char = '6' OR curr_char = '7' OR curr_char_ = '8' OR curr_char = '9')) then
if (v_counter = length(leavedata) and (curr_char = prev_char)) then
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
if (curr_time_slot = '00:00:00') then
curr_time_slot := '23:59:59';
end if;
--SELECT valuedesc INTO v_leavetype FROM FW_co_dropdown WHERE colname = 'LEAVETYPE' AND colvalue = curr_char;
--select LeaveDurations || v_leavetype || ' on ' || curr_time_slot || cm_separator into LeaveDurations from dual;
select LeaveDurations || curr_time_slot || ')' || cm_separator into LeaveDurations from dual;
end if;
--lgq if (v_counter-1 = first_pos and (curr_char = '0' OR curr_char = '1' OR curr_char = '2' OR curr_char = '3')) then
if (v_counter-1 = first_pos and (curr_char != prev_char)) then
if (v_counter = length(leavedata)) then
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter-1) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
else
select substr(to_char(to_date('01/01/2002 00:00:00', 'dd/mm/yyyy hh24:mi:ss') + (1/(24*2)) * (v_counter) , 'hh24:mi:ss'), 1, 8)
into curr_time_slot
from dual;
end if;
if (curr_time_slot = '00:00:00') then
curr_time_slot := '23:59:59';
end if;
--SELECT valuedesc INTO v_leavetype FROM FW_co_dropdown WHERE colname = 'LEAVETYPE' AND colvalue = curr_char;
--select LeaveDurations || v_leavetype || ' on ' || curr_time_slot || cm_separator into LeaveDurations from dual;
select LeaveDurations || curr_time_slot || ')' || cm_separator into LeaveDurations from dual;
end if;
end if;
end loop;
if (length(LeaveDurations) > 0) then
return substr(LeaveDurations, 1, length(LeaveDurations) - length(cm_separator));
else
return LeaveDurations;
end if;
END;
/