PL SQL过程错误

时间:2016-05-12 22:02:52

标签: oracle stored-procedures plsql parameters procedure

我正在创建此过程以从数据库中检索信息。这是我第一次创建一个程序。在创建过程时,我一直在尝试设置的参数出错。它说的是一些预期不同符号的分号。 现在我的SQL语句出现错误,数据类型不一致:预期NUMBER有DATE

CREATE OR REPLACE PROCEDURE HIREDATE
(
D_ID IN EMP.DEPARTMENT_ID%TYPE; 
H_YEAR IN EMP.HIRE_DATE%TYPE;
)
--
AS
--
v_Last              VARCHAR2(20);               
v_First             VARCHAR2(25);
v_HireDate          DATE;
--
BEGIN
--
SELECT LAST_NAME,FIRST_NAME,HIRE_DATE 
INTO v_Last,v_First,v_HireDate
FROM EMP WHERE DEPARTMENT_ID = D_ID
AND EXTRACT(YEAR FROM HIRE_DATE) = H_YEAR;
--
DBMS_OUTPUT.PUTLINE(v_Last||','||v_First||'      '||v_HireDate);
--
EXCEPTION
--
WHEN NO_DATA_FOUND THEN 
DBMS_OUTPUT.PUTLINE('No data found for Department '||D_ID);
--
WHEN OTHERS THEN
DBMS_OUTPUT.PUTLINE('An unexpected error has occurred!');
--
END;

1 个答案:

答案 0 :(得分:1)

您的参数应以逗号(,)分隔。你有分号。

CREATE OR REPLACE PROCEDURE HIREDATE(
 D_ID IN EMP.DEPARTMENT_ID%TYPE,
 H_YEAR IN EMP.HIRE_DATE%TYPE) AS ...