Я написал следующий запрос, но получил ошибку:
PLS-00103: Обнаружен символ «конец файла» при ожидании одного из следующих действий:
: =. (@%;
Ниже приведен запрос хранимой процедуры.
Я знаю, что это синтаксическая ошибка, но не могу понять, где именно проблема.
Будет очень полезно, если кто-нибудь поможет мне.
CREATE OR REPLACE PROCEDURE MCSIL_HR.sp_ins_emp_mst_DEV (
inemp_id emp_mst.emp_id%TYPE,
inemp_restrict_emp emp_mst.restrict_emp%TYPE,
inemp_name emp_mst.emp_name%TYPE,
inemp_email emp_mst.email_id%TYPE,
inemp_pwd emp_mst.emp_pwd%TYPE,
indob VARCHAR2,
indoj VARCHAR2,
indor VARCHAR2,
inemp_status_lkp_id emp_mst.emp_status_lkp_id%TYPE,
inemp_has_reportee_status emp_mst.has_reportees_status_yn%TYPE,
inupd_emp_id emp_mst.emp_id%TYPE,
inupd_flag CHAR,
indept VARCHAR2,
inmgr_id emp_mst.mgr_id%TYPE,
outmsg OUT VARCHAR2,
outstatus OUT VARCHAR2
)
IS
pgm_error EXCEPTION;
as_emp_id emp_mst.emp_id%TYPE;
as_cnt NUMBER;
upd_flag VARCHAR2 (3);
asdob DATE;
asdoj DATE;
asdor DATE;
BEGIN
outmsg := '';
outstatus := 'TRUE';
upd_flag := UPPER (TRIM (inupd_flag));
-- check if Emp Status lookup value exists in lookup table , if not raise error
SELECT COUNT (1)
INTO as_cnt
FROM lookup l
WHERE l.lkp_id = inemp_status_lkp_id;
IF as_cnt = 0
THEN
outmsg :=
'Employee Sattus LOOK UP VALUE : '
|| TO_CHAR (inemp_status_lkp_id)
|| ' NOT EXISTS IN LOOKUP TABLE ';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
-- check if Yes/No Status ookup value exists in lookup table , if not raise error
SELECT COUNT (1)
INTO as_cnt
FROM lookup l
WHERE l.lkp_id = inemp_has_reportee_status;
IF as_cnt = 0
THEN
outmsg :=
'Has_Reportees Status LOOK UP VALUE : '
|| TO_CHAR (inemp_has_reportee_status)
|| ' NOT EXISTS IN LOOKUP TABLE ';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
-- check whether user modifying data is valid employee
SELECT COUNT (1)
INTO as_cnt
FROM emp_mst e
WHERE e.emp_id = inupd_emp_id;
IF as_cnt = 0
THEN
outmsg :=
'UPDATING USER ID: '
|| TO_CHAR (inupd_emp_id)
|| ' NOT EXISTS IN EMPLOYEE MASTER ';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
-- checking date formatt (dd-mm-yyyy)
IF indob IS NULL
OR NOT ( SUBSTR (TRIM (indob), 3, 1) = '-'
AND SUBSTR (TRIM (indob), 6, 1) = '-'
)
THEN
outmsg :=
'Date of Birth is Blank or Formatt for Date of Birth is not in DD-MM-YYYY, Contact Administrator';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
IF indoj IS NULL
OR NOT ( SUBSTR (TRIM (indoj), 3, 1) = '-'
AND SUBSTR (TRIM (indoj), 6, 1) = '-'
)
THEN
outmsg :=
'Date of Join is Blank or Formatt for Date of Join is not in DD-MM-YYYY, Contact Administrator';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
IF indor IS NOT NULL
AND NOT ( SUBSTR (TRIM (indor), 3, 1) = '-'
AND SUBSTR (TRIM (indor), 6, 1) = '-'
)
THEN
outmsg :=
'Formatt for Date of Resign is not in DD-MM-YYYY, Contact Administrator';
outstatus := 'INSERT/UPDATE/DELETE Failed.';
RAISE pgm_error;
END IF;
asdob := TO_DATE (TRIM (indob), 'DD-MM-YYYY');
asdoj := TO_DATE (TRIM (indoj), 'DD-MM-YYYY');
asdor := TO_DATE (TRIM (indor), 'DD-MM-YYYY');
DBMS_OUTPUT.put_line ( 'LKP SRNO, UPDATE USER EMPCODE OK,'
|| 'DOB :'
|| TO_CHAR (asdob)
|| ',DOJ :'
|| TO_CHAR (asdoj)
|| ',DOR :'
|| TO_CHAR (asdor)
);
-- check whether user modifying data is valid employee
SELECT COUNT (*)
INTO as_cnt
FROM emp_mst e
WHERE e.emp_id = inemp_id;
IF upd_flag = 'U'
THEN
IF as_cnt = 0
THEN
outmsg :=
'EMPLOYEE CODE : '
|| TO_CHAR (inemp_id)
|| ' NOT EXISTS IN EMPLOYEE MASTER';
outstatus := 'UPDATE Failed.';
RAISE pgm_error;
END IF;
UPDATE emp_mst a
SET a.rec_dtl = rec_dtl (NULL, NULL, NULL, NULL)
WHERE a.rec_dtl IS NULL;
-- For password change call another procedure
UPDATE emp_mst a
SET a.emp_name = inemp_name,
a.restrict_emp = inemp_restrict_emp,
a.email_id=inemp_email,
a.emp_pwd = ENCRYPT(inemp_pwd),
a.dob = asdob,
a.doj = asdoj,
a.dor = asdor,
a.emp_status_lkp_id = inemp_status_lkp_id,
a.has_reportees_status_yn = inemp_has_reportee_status,
a.rec_dtl.updated_by = inupd_emp_id,
a.DEPT= indept,
a.MGR_ID = inmgr_id,
a.rec_dtl.updated_on = SYSDATE
WHERE a.emp_id = inemp_id;
IF SQLCODE <> 0
THEN
ROLLBACK;
outstatus := 'FALSE';
outmsg := 'UPDATE Failed.';
RAISE pgm_error;
ELSE
COMMIT;
outstatus := 'TRUE';
outmsg := 'Process sucessfully executed';
END IF;
ELSIF upd_flag = 'I'
THEN
IF as_cnt > 0
THEN
outmsg :=
'EMPLOYEE ID : '
|| TO_CHAR (inemp_id)
|| ' ALREADY IN EMPLOYEE MASTER';
outstatus := 'INSERT Failed.';
RAISE pgm_error;
END IF;
INSERT INTO mcsil_hr.emp_mst
(emp_id,restrict_emp, emp_name,email_id, emp_pwd, dob, doj, dor, ---added by shailesh
emp_status_lkp_id, has_reportees_status_yn,
rec_dtl,DEPT,MGR_ID
)
VALUES (inemp_id,inemp_restrict_emp, inemp_name, inemp_email, ENCRYPT(inemp_pwd), asdob, asdoj, asdor, ---added by shailesh
inemp_status_lkp_id, inemp_has_reportee_status,
rec_dtl (inupd_emp_id, SYSDATE, NULL, NULL),indept,inmgr_id
);
IF SQLCODE <> 0
THEN
ROLLBACK;
outstatus := 'FALSE';
outmsg := 'INSERT Failed.';
RAISE pgm_error;
ELSE
COMMIT;
outstatus := 'TRUE';
outmsg := 'Process Sucessfully executed';
END IF;
ELSIF upd_flag = 'D'
THEN
IF as_cnt = 0
THEN
outmsg :=
'EMPLOYEE ID : '
|| TO_CHAR (inemp_id)
|| ' NOT EXISTS IN EMPLOYEE MASTER';
outstatus := 'DELETE Failed.';
RAISE pgm_error;
END IF;
UPDATE emp_mst a
SET a.rec_dtl = rec_dtl (NULL, NULL, NULL, NULL)
WHERE a.rec_dtl IS NULL;
UPDATE emp_mst a
SET a.emp_status_lkp_id = 202, -- INCATIVE ACCOUNT CODE
a.rec_dtl.updated_by = inupd_emp_id,
a.rec_dtl.updated_on = SYSDATE
WHERE a.emp_id = inemp_id;
IF SQLCODE <> 0
THEN
ROLLBACK;
outstatus := 'FALSE';
outmsg := 'DELTE Failed.';
RAISE pgm_error;
ELSE
COMMIT;
outstatus := 'TRUE';
outmsg := 'Process sucessfully executed';
END IF;
ELSE
outstatus := 'FALSE';
outmsg := 'ACTION FLAG SHOULD BE IN I(Insert)/U(Update)/D(Delete).';
RAISE pgm_error;
END IF;
DBMS_OUTPUT.put_line ('STATUS :' || outstatus || ', MGS :' || outmsg);
EXCEPTION
WHEN pgm_error
THEN
BEGIN
outstatus := 'FALSE';
DBMS_OUTPUT.put_line ('STATUS :' || outstatus || ', MGS :' || outmsg);
raise_application_error (-20999, outmsg);
END;
WHEN NO_DATA_FOUND
THEN
BEGIN
outmsg := 'INSERT/UPDATE/DELETE FAILED. NO DATA FOUND';
outstatus := 'FALSE';
DBMS_OUTPUT.put_line ('STATUS :' || outstatus || ', MGS :' || outmsg);
raise_application_error (-20999, outmsg);
END;
WHEN OTHERS
THEN
BEGIN
outmsg := 'INSERT/UPDATE/DELETE FAILED. ';
outstatus := 'FALSE';
DBMS_OUTPUT.put_line ('STATUS :' || outstatus || ', MGS :' || outmsg);
raise_application_error (-20999, outmsg || SQLERRM);
END;
END sp_ins_emp_mst_DEV ;
/