Di Oracle, Anda dapat menjalankan fungsi dengan parameter melalui cara berikut:
1. Jalankan Fungsi Menggunakan Pernyataan Pilih
SELECT get_emp_job (7566) FROM DUAL;
Keluaran
GET_EMP_JOB(7566) ---------------------------------------- MANAGER 1 row selected.
2. Jalankan Fungsi Menggunakan Blok PL/SQL
SET SERVEROUTPUT ON; DECLARE v_job emp.job%TYPE; BEGIN v_job := get_emp_job (7566); DBMS_OUTPUT.put_line (v_job); END;
Keluaran
MANAGER PL/SQL procedure successfully completed.
Fungsi GET_EMP_JOB
CREATE OR REPLACE FUNCTION GET_EMP_JOB (i_EMPNO IN emp.empno%TYPE) return varchar2 IS CURSOR c_ename (p_empno emp.empno%TYPE) IS SELECT job FROM emp WHERE empno = p_empno; v_job emp.job%type; BEGIN OPEN c_ename (i_empno); FETCH c_ename INTO v_job; CLOSE c_ename; return v_job; END get_emp_job;