Here is the code.
CREATE OR REPLACE PROCEDURE New_Emp(p_EMP_NAME IN VARCHAR2, p_EMP_JOB IN VARCHAR2, p_DEPT_NO IN NUMBER) IS v_NEW_EMP_ID EMP.EMPNO%TYPE; v_HIGHEST_DEPTNO DEPT.DEPTNO%TYPE; v_Avg_min EMP2.SAL%TYPE; FUNCTION Avg_Emp RETURN REAL AS BEGIN SELECT ROUND(AVG(SAL)) - MIN(SAL) INTO v_Avg_min FROM EMP; RETURN NUMBER; END; BEGIN SELECT MAX(EMPNO) + 1 INTO v_NEW_EMP_ID FROM EMP; SELECT MAX(DEPTNO) INTO v_HIGHEST_DEPTNO FROM DEPT; INSERT INTO EMP2(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, STARS) VALUES (v_NEW_EMP_ID, p_EMP_NAME, p_EMP_JOB, 7566, '20-DEC-2001', v_Avg_min, NULL, v_HIGHEST_DEPTNO, NULL); END; /
What am I doing wrong?
Dig Deeper on Using Oracle PL-SQL
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.