如何解决plsql的此错误?

时间:2019-01-21 12:19:27

标签: plsql

its show this type of error help me to solve it i attch screen shot here在此处输入代码

declare
empnos NUMBER(9,2);
L NUMBER(9,2);
ANS NUMBER(9,2);
function avg_sal(x number, y number) return number AS
begin
         ANS := (x / y) * 100;
         return  ANS;
end avg_sal;
BEGIN
   empnos := :EMPNOr;
   select TOTAT_SAL,NOOFEMP  from dept 
   where  DEPTNO=(
       select deptno from emp
       where empnos=emp.empno
 );
       L := avg_sal(TOTAT_SAL,NOOFEMP);
END;

1 个答案:

答案 0 :(得分:0)

如错误所示和上面提到的粘性位,您需要将结果放入变量中: 这是一个示例:

declare
  empnos      NUMBER(9, 2);
  L           NUMBER(9, 2);
  ANS         NUMBER(9, 2);
  v_total_sal NUMBER(9, 2);
  v_nooofemp  NUMBER(9, 2);
  function avg_sal(x number, y number)
    return number AS
    begin
      ANS := (x / y) * 100;
      return ANS;
    end avg_sal;

BEGIN
  empnos := :EMPNOr;
  select
    TOTAT_SAL,
    NOOFEMP
  into v_total_sal,
       v_nooofemp
  from dept
  where DEPTNO = (
    select deptno
    from emp
    where empnos = emp.empno
  );
  L := avg_sal(v_total_sal, v_nooofemp);
END;