📜  在 ORACLE 的 select 语句中从 PL SQL 调用一个函数 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:31.699000             🧑  作者: Mango

代码示例1
DECLARE
  em_sal NUMBER(20);
  em_comm employees.commission_pct%type;
  annual_salary NUMBER(10,4);
BEGIN
  SELECT salary INTO em_sal FROM employees WHERE employee_id=149;
  SELECT commission_pct INTO em_comm FROM employees WHERE employee_id=149;
  annual_salary := get_annual_comp(em_sal,em_comm);
  dbms_output.put_line('total salary '|| annual_salary);
  SELECT SUM(get_annual_comp(salary,commission_pct)) into annual_salary
  FROM employees
  WHERE department_id=90;
  dbms_output.put_line('department annual salary '|| annual_salary);
END;
/