-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathquery_3.sql
More file actions
56 lines (52 loc) · 1.31 KB
/
query_3.sql
File metadata and controls
56 lines (52 loc) · 1.31 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
45
46
47
48
49
50
51
52
53
54
55
56
declare
name varchar(10):=:name;
gender varchar(10):=:gender;
birthdate date:=:birthdate;
age int;
begin
age:= months_between(sysdate, birthdate)/12;
if (gender='male' and age<=12) then
dbms_output.put_line('Master '||name);
elsif (gender='male' and age>12) then
dbms_output.put_line('Mr '||name);
elsif (gender='female' and age<=12) then
dbms_output.put_line('Baby '||name);
else
dbms_output.put_line('Ms '||name);
end if;
end;
declare
num int:=:num;
root int;
i int;
flag int;
begin
root:= sqrt(num);
flag:= 0;
for i in 2..root loop
if (mod(num,i)=0) then
flag := 1;
exit;
end if;
end loop;
if (flag=0) then
dbms_output.put_line(num||' is prime');
else
dbms_output.put_line(num||' is composite');
dbms_output.put_line('Factors of '||num|| ' are ');
for i in 1..num loop
if mod(num,i)=0 then
dbms_output.put_line(i);
end if;
end loop;
end if;
end;
declare
mail varchar(40):=:mail;
begin
if (mail like '%@%') then
dbms_output.put_line(mail||' is a valid mail id');
else
dbms_output.put_line(mail||' is not a valid mail id');
end if;
end;