-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFUNCTION_NESTED_EMPLOYEE_LIST.sql
More file actions
31 lines (23 loc) · 1.08 KB
/
FUNCTION_NESTED_EMPLOYEE_LIST.sql
File metadata and controls
31 lines (23 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Function
-- 1.Nested Function: Unnamed Bloklarda yazilan fonksiyonlar. Veritabaninda saklanmaz.
-- 2.Developer Defined Function: Standalone ya da Package icinde yazilir. Veritabaninda saklanir.
--- Nested Function ---
-- Bu ornekte PROCEDURE ve FUNCTION bir arada kullanarak calisanlari listeleyecegiz.
-- Numarasi verilen departmanin ismini ardindan departmanda calisanlari listeleyecegiz.
Declare
FUNCTION dept_name (p_dept DEPARTMENTS.DEPARTMENT_ID%Type) RETURN DEPARTMENTS.DEPARTMENT_NAME%TYPE IS
wdeptname DEPARTMENTS.DEPARTMENT_NAME%TYPE;
Begin
select departments.department_name into wdeptname from departments where departments.department_id = p_dept;
RETURN wdeptname;
End;
PROCEDURE emp_oku (p_dept DEPARTMENTS.DEPARTMENT_ID%Type) IS
Begin
dbms_output.put_line(p_dept || ' ' || dept_name(p_dept));
for i in (select employees.first_name, employees.last_name from employees where employees.department_id = p_dept) loop
dbms_output.put_line(i.first_name|| ' ' || i.last_name);
End Loop;
End;
Begin
emp_oku(60);
End;