AS SALAMO ALAIKUM WA RAHMATULLAH
CREATE OR REPLACE PROCEDURE PROC_INS_XXX_EMP_INT(errbuf out varchar2,retcode out varchar2)
IS
E_FLAG CHAR(1);
E_MSG VARCHAR2(2000);
CURSOR C1 IS
SELECT * FROM XXX_EMP_STG;
BEGIN
FOR E IN C1
LOOP
--======================
/*VALIDATION OF EMPNO*/
--=======================
BEGIN
IF E.EMPNO IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.EMPNO||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.EMPNO||' IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'IS NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'TOO MANY ROWS FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'ERROR NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF ENAME*/
--============================
BEGIN
IF E.ENAME IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.ENAME||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.ENAME||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF JOB*/
--============================
BEGIN
IF E.JOB IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.JOB||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.JOB||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.JOB||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.JOB||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.JOB||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF MGR*/
--============================
BEGIN
IF E.MGR IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.MGR||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.MGR||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.MGR||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.MGR||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.MGR||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF HIREDATE */
--============================
BEGIN
IF E.HIREDATE IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.HIREDATE||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.HIREDATE||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF SAL*/
--============================
BEGIN
IF E.SAL IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.SAL||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.SAL||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.SAL||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.SAL||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.SAL||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF DEPTNO*/
--============================
BEGIN
IF E.DEPTNO IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.DEPTNO||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.DEPTNO||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
IF(E_FLAG='V') THEN
INSERT INTO XXX_EMP_INT (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
VALUES(E.EMPNO,E.ENAME,E.JOB,E.MGR,E.HIREDATE,E.SAL,E.COMM,E.DEPTNO);
END IF;
END LOOP;
END;
CREATE OR REPLACE PROCEDURE PROC_INS_XXX_EMP_INT(errbuf out varchar2,retcode out varchar2)
IS
E_FLAG CHAR(1);
E_MSG VARCHAR2(2000);
CURSOR C1 IS
SELECT * FROM XXX_EMP_STG;
BEGIN
FOR E IN C1
LOOP
--======================
/*VALIDATION OF EMPNO*/
--=======================
BEGIN
IF E.EMPNO IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.EMPNO||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.EMPNO||' IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'IS NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'TOO MANY ROWS FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.EMPNO||'ERROR NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF ENAME*/
--============================
BEGIN
IF E.ENAME IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.ENAME||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.ENAME||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.ENAME||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF JOB*/
--============================
BEGIN
IF E.JOB IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.JOB||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.JOB||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.JOB||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.JOB||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.JOB||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF MGR*/
--============================
BEGIN
IF E.MGR IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.MGR||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.MGR||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.MGR||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.MGR||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.MGR||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF HIREDATE */
--============================
BEGIN
IF E.HIREDATE IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.HIREDATE||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.HIREDATE||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.HIREDATE||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF SAL*/
--============================
BEGIN
IF E.SAL IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.SAL||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.SAL||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.SAL||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.SAL||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.SAL||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
--===============================
/* VALIDATION OF DEPTNO*/
--============================
BEGIN
IF E.DEPTNO IS NOT NULL THEN
E_FLAG:='V';
E_MSG:=E.DEPTNO||' IS VALID';
--FND_FILE.PUT_LINE('EMPNO IS VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
ELSE
E_FLAG:='E';
E_MSG:=E.DEPTNO||'IS NOT VALID OR NULL';
--FND_FILE.PUT_LINE('EMPNO IS NOT VALID');
DBMS_OUTPUT.PUT_LINE(E_MSG);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'NAME NOT FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN TOO_MANY_ROWS THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'TOO MANY NAMED FOUND';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
WHEN OTHERS THEN
E_FLAG:='E';
E_MSG:=E.DEPTNO||'ERRORS NOT KNOWN';
--FND_FILE.PUT_LINE('EMPNO IS NOT FOUND);
DBMS_OUTPUT.PUT_LINE(E_MSG);
END;
IF(E_FLAG='V') THEN
INSERT INTO XXX_EMP_INT (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
VALUES(E.EMPNO,E.ENAME,E.JOB,E.MGR,E.HIREDATE,E.SAL,E.COMM,E.DEPTNO);
END IF;
END LOOP;
END;
--
MA ASALAAM
PASSION FOR ORACLE
No comments:
Post a Comment