2014-10-05 2 views
-2

여기에 컴파일 오류가 발생하는 이유는 무엇입니까? 테이블의 모든 속성 이름이 정확합니다. 또한 테이블이 존재합니다."컴파일 오류"(기능 포함)

SQL> create or replace function user_annual_comp(f_eno emp1.empno%type) return number 
    2 is 
    3 f_sal emp1.salary%type; 
    4 f_comm emp1.comm%type; 
    5 annual_comm number; 
    6 begin 
    7 select salary into f_sal from emp1 where empno = f_eno; 
    8 select comm into f_comm from emp1 where empno = f_eno; 
    9 if f_sal is null then 
10  f_sal := 0; 
11 end if; 
12 if f_comm is null then 
13  f_comm := 0; 
14 end if; 
15 annual_comm = (f_sal + f_comm) * 12; 
16 return annual_comm; 
17 end; 
18/

결과 :

나는이 문제를 해결할 수있는 방법
Warning: Function created with compilation errors. 

?

+0

오류 메시지에 대한 자세한 정보가 없습니다. 어느 선 이요? – Juru

+0

'show error'는 무엇을 제공합니까? –

+0

희망의 OP가'SQL * Plus'에서 함수를 컴파일했습니다 :-) –

답변

1

PL/SQL의 대입 연산자는 :=이고 =은 항등 비교 연산자입니다. 15 호선을

annual_comm := (f_sal + f_comm) * 12; 

으로 변경하십시오.

0

당신은 간단한 SQL에 그 모든 기능을 쓸 수있다 : 동일은 일반 SQL에서 할 수있을 때

Select (nvl(sal,0) + nvl(comm,0))*12 as "annual_comm" 
    From emp 
    Where empno = input_emp_no; 

는 절대로 PL/SQL을 사용하지 않습니다.

annual_comm := (nvl(sal,0) + nvl(comm,0))*12

그리고이 IF-END IF 블록 제거 : 당신은 여전히 ​​함수를 작성하기 위해 주장하는 것처럼

그러나, 다음 신체의 논리를 다시 작성할 수 있습니다.

관련 문제