-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4. Case Expressions (Code Samples).html
More file actions
44 lines (44 loc) · 1.58 KB
/
4. Case Expressions (Code Samples).html
File metadata and controls
44 lines (44 loc) · 1.58 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
32
33
34
35
36
37
38
39
40
41
42
43
44
<pre class="prettyprint linenums">----------------------------CASE EXPRESSIONS--------------------------------
declare
v_job_code varchar2(10) := 'SA_MAN';
v_salary_increase number;
begin
v_salary_increase := case v_job_code
when 'SA_MAN' then 0.2
when 'SA_REP' then 0.3
else 0
end;
dbms_output.put_line('Your salary increase is : '|| v_salary_increase);
end;
-------------------------SEARCHED CASE EXPRESSION----------------------------
declare
v_job_code varchar2(10) := 'IT_PROG';
v_department varchar2(10) := 'IT';
v_salary_increase number;
begin
v_salary_increase := case
when v_job_code = 'SA_MAN' then 0.2
when v_department = 'IT' and v_job_code = 'IT_PROG' then 0.3
else 0
end;
dbms_output.put_line('Your salary increase is : '|| v_salary_increase);
end;
---------------------------CASE STATEMENTS------------------------------------
declare
v_job_code varchar2(10) := 'IT_PROG';
v_department varchar2(10) := 'IT';
v_salary_increase number;
begin
case
when v_job_code = 'SA_MAN' then
v_salary_increase := 0.2;
dbms_output.put_line('The salary increase for a Sales Manager is : '|| v_salary_increase);
when v_department = 'IT' and v_job_code = 'IT_PROG' then
v_salary_increase := 0.2;
dbms_output.put_line('The salary increase for a Sales Manager is : '|| v_salary_increase);
else
v_salary_increase := 0;
dbms_output.put_line('The salary increase for this job code is : '|| v_salary_increase);
end CASE;
end;
-------------------------------------------------------------------------------</pre>