Redmi 9 Prime Price in India, specifications, special features
Redmi 9 Prime specifications!!
Redmi 9 Prime is the phone for the people who want massive battery and fast charging support.
Redmi 9 Prime is a budget segment phone.
Redmi 9 Prime is the best phone around Rs.11,000 in India.
Special Features:
SPECIFICATION OF Redmi 9 Prime:
| Redmi Note 9 Prime | |
|---|---|
| Network | GSM / HSPA / LTE |
| 2G bands | GSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2 |
| 3G bands | HSDPA 850 / 900 / 1900 / 2100 |
| 4G bands | 1, 3, 5, 8, 40, 41 |
| Speed | HSPA 42.2/5.76 Mbps, LTE-A |
| OS and Hardware |
|
|---|---|
| OS | Android 10, MIUI 12 |
| Processor | Octa-core (2x2.0 GHz Cortex-A75 & 6x1.8 GHz Cortex-A55) |
| Chipset | Mediatek Helio G80 |
| GPU | Mali-G52 MC2 |
| General | |
|---|---|
| Brand | Redmi |
| Released Date | 6th August 2020 |
| Launched in India | Yes |
| Model | Redmi 9 Prime |
| Custom UI | MIUI 12 |
| Charger Speed | 18W charger in the box |
| Sim size | Nano (both slots) |
| Body |
|
|---|---|
| Dimensions | 163.3 x 77 x 9.1 mm (6.43 x 3.03 x 0.36 in) |
| Weight | 198 g |
| Colors | Space Blue, Mint Green, Matte Black, Sunrise Flare |
| Build | Glass front (Gorilla Glass 3), plastic back, plastic frame |
| SIM | Dual sim slot |
| Display |
|
|---|---|
| Type | IPS LCD capacitive touchscreen, 16M colors |
| Screen Size | 6.53 inches, 104.7 cm2 (~83.2% screen-to-body ratio) |
| Resolution | 1080 x 2340 pixels, 19.5:9 ratio (~395 ppi density) |
| Multitouch | Yes |
| Storage | |
|---|---|
| Memory Card slot | Yes |
| Variants | 4/64 and 4/128 GB |
| Internal storage type | eMMC 5.1 |
| RAM | 4 GB |
| Camera |
|
|---|---|
| Rare camera |
13 MP, f/2.2, 28mm (wide), 1/3.1", 1.12µm, PDAF 8 MP, f/2.2, 118˚ (ultrawide), 1/4.0", 1.12µm, 5 MP, f/2.4, (macro), 2 MP, f/2.4, (depth) |
| Video quality | 1080p@30fps |
| Front camera | 8 MP, f/2.0, 27mm (wide), 1/4.0", 1.12µm |
| Video quality | 1080p@30fps |
| Battery and Power | |
|---|---|
| Type | Non-removable Li-Po 5020 mAh battery |
| Charger Speed | 18W |
| Charging speed supported | 18W |
| Connectivity | |
|---|---|
| WiFi | Yes, Wi-Fi 802.11 a/b/g/n/ac |
| Bluetooth | Yes, Version 5.0 |
| GPS | Yes |
| Radio | Yes |
| USB | Yes, Type C |
| Loudspeaker | Yes |
| 3.5mm jack | Yes |
| Special Features | |
|---|---|
| Fingerprint sensor | Yes |
| Fingerprint sensor position | Rear-mounted |
| Other sensors | Accelerometer, Proximity, Compass |
| Price | |
|---|---|
| Indian Rs. |
4/64: Rs.9,999 4/128: Rs.11,999 |
| US Dollar |
4/64: $137 4/128: $164 |
So what do you think about this phone?
Practical 1(sequence)
create sequence test
start with 1
increment by 1
maxvalue 999
minvalue 1
cycle;
create table test1(num integer,name varchar(10));
insert into test1 values(test.nextval,'Anjali');
select * from test1;
insert into test1 values(test.nextval,'Shweta');
select * from test1;
select test.nextval from dual;
insert into test1 values(test.nextval,'Tina');
select * from test1;
select test.currval from dual;
select test.nextval from dual;
insert into test1 values(test.nextval,'Riya');
select * from test1;
alter sequence test
increment by 3
minvalue 1
maxvalue 999
cycle;
select test.currval from dual;
select test.nextval from dual;
drop sequence test;
create sequence tempo1
start with 1
increment by 1
maxvalue 10
minvalue 1
cache 4
cycle;
select tempo1.currval from dual;
select tempo1.nextval from dual;
select tempo1.currval from dual;
create table data(num integer,name varchar(10));
insert into data values(tempo1.currval,'Abc');
select * from data;
insert into data values(tempo1.nextval,'pqr');
insert into data values(tempo1.nextval,'rina');
insert into data values(tempo1.nextval,'piya');
insert into data values(tempo1.nextval,'riya');
insert into data values(tempo1.nextval,'tina');
insert into data values(tempo1.nextval,'diya');
insert into data values(tempo1.nextval,'kiya');
insert into data values(tempo1.nextval,'disha');
insert into data values(tempo1.nextval,'rutika');
insert into data values(tempo1.nextval,'sita');
select * from data;
create sequence structure
start with 1
increment by 1
maxvalue 10
minvalue 1
cache 4
cycle;
create table employee2(no integer,name varchar(10),Dept varchar(10),sal integer);
insert into employee2 values(structure.nextval,'xyz','comp',1000);
insert into employee2 values(structure.nextval,'abc','acc',5000);
insert into employee2 values(structure.nextval,'dfc','bcc',7000);
select * from employee2;
insert into employee2 values(&no,'&name','&dept',&sal);
insert into employee2(no,name,Dept,sal)values(6,'zxz','training',2000);
insert into employee2(no,name,sal)values(6,'zxz',2000);
select * from employee2;
update employee2 set name='siya' where no=1;
select * from employee2;
alter table employee2 add(email varchar(20));
select * from employee2;
delete from employee2 where no=3;
select * from employee2;
drop table employee2;
select * from employee2;
##Expected error
__________________________________________________________________________________________________________________________________________________________________________
Practical 2
#add,sub,mul,div
declare
a number:=20;
b number:=10;
s number;
r number;
t number;
h number;
begin
s:=a+b;
r:=a-b;
t:=a*b;
h:=a/b;
dbms_output.put_line('addition='||s);
dbms_output.put_line('subtraction='||r);
dbms_output.put_line('multiplication='||t);
dbms_output.put_line('division='||h);
end;
set serveroutput on;
#for input using &
declare a number:=& a;
b number:=& b;
s number;
r number;
t number;
h number;
begin
s:=a+b;
r:=a-b;
t:=a*b;
h:=a/b;
dbms_output.put_line('addition='||s);
dbms_output.put_line('subtraction='||r);
dbms_output.put_line('multiplication='||t);
dbms_output.put_line('division='||h);
end;
# display sub marks
declare
s1 number:=&s1;
s2 number:=&s2;
s3 number:=&s3;
s4 number:=&s4;
s5 number:=&s5;
total number;
p number;
begin
total:=s1+s2+s3+s4+s5;
p:=(total/5);
dbms_output.put_line('total marks obtained='||total);
dbms_output.put_line('percent='||p);
end;
#simple interest program
declare
p number:=&p;
n number:=&n;
r number:=&r;
i number;
begin
i:=(p*n*r)/100;
dbms_output.put_line('simple interest='||i);
end;
#table to retrive from PLSQL
create table employee(empid number,sal number);
insert into employee values(101,1000);
insert into employee values(102,2000);
select * from employee;
declare
salary number;
begin
select sal into salary from employee where empid=101;
dbms_output.put_line('salary='||salary);
end;
__________________________________________________________________________________________________________________________________________________________________________
Practical 3
create table test12(id number,num number);
insert into test12 values(1,1);
insert into test12 values(2,2);
insert into test12 values(3,3);
insert into test12 values(4,4);
insert into test12 values(5,5);
insert into test12 values(1,1);
insert into test12 values(2,2);
insert into test12 values(3,3);
insert into test12 values(4,4);
insert into test12 values(5,5);
select * from test12;
ID NUM
---------- ----------
1 1
2 2
3 3
4 4
5 5
##sequential control
GOTO <CODE BLOCK>
declare
no number;
ide number;
begin
ide:=1;
select num into no from test12 where id=ide;
<<Label1>>
if(no<3) then
dbms_output.put_line('Hello Welcome');
no:=no+2;
goto Label1;
else
dbms_output.put_line('Byeeeeee');
end if;
end;
output:
Hello Welcome
Byeeeeee
##factroial by using sequential control
declare
no number;
ide number;
f number:=1;
begin
for i in 1..10
loop
f := f*i;
end loop;
end;
##null statement
declare
i number:=10;
begin
if(i=1) then
dbms_output.put_line('One');
else
goto end_loop;
end if;
<<end_loop>>
null;
end;
output:
PL/SQL procedure successfully completed.
1)simple case
declare
deptno number:=10;
dept_desc varchar(20);
begin
dept_desc:=case deptno
when 10 then 'Account'
when 20 then 'Research'
when 30 then 'Sales'
when 40 then 'Operational'
else 'unknown'
end;
dbms_output.put_line(dept_desc);
end;
op:
Account
##by using simple case statement display the day between 1 to 7 no
declare
dayno number:=3;
day_desc varchar(20);
begin
day_desc:=case dayno
when 1 then 'Sunday'
when 2 then 'Monday'
when 3 then 'Tuesday'
when 4 then 'Wednesday'
when 5 then 'Thursday'
when 6 then 'Friday'
when 7 then 'Saturday'
else 'unknown'
end;
dbms_output.put_line(day_desc);
end;
op:
17 /
Tuesday
2)Search case
declare
sal number:=20;
sal_desc varchar(20);
begin
sal_desc:=case
when sal<1000 then 'LOW'
when sal between 1000 and 3000 then 'Medium'
when sal>3000 then 'High'
else'NA'
end;
dbms_output.put_line(sal_desc);
end;
op:
LOW
## by using search case statement program to find out temp
declare
temp number:=41;
temp_desc varchar(20);
begin
temp_desc:=case
when temp<20 then 'LOW'
when temp between 20 and 31 then 'Medium'
when temp>31 then 'High'
else'NA'
end;
dbms_output.put_line(temp_desc);
end;
op:
High
create table profitloss(id integer, costp integer, sellp integer);
insert into profitloss values (101, 200, 300);
insert into profitloss values (102, 300, 150);
insert into profitloss values (103, 500, 500);
insert into profitloss values (104, 400, 350);
insert into profitloss values (105, 800, 1200);
select * from profitloss;
declare
i number;
c number;
s number;
begin
i:=&i;
select costprice into c from profitlosss where id=i;
select sellingprice into s from profitlosss where id=i;
dbms_output.put_line('Cost Price = ' || c);
dbms_output.put_line('Selling Price = ' || s);
IF(c<s) THEN
dbms_output.put_line('PROFIT');
ELSIF(c=s) THEN
dbms_output.put_line('NO PROFIT OR LOSS');
ELSE
dbms_output.put_line('LOSS');
END IF;
END;
set serveroutput on;
declare
a number:=10;
b number:=5;
begin
IF(a>b)THEN
dbms_output.put_line('A is greater');
ELSE
dbms_output.put_line('B is greater');
END IF;
end;
/
#odd even
declare
p number:=&p;
begin
IF(mod(p,2)=0)THEN
dbms_output.put_line('number is even');
ELSE
dbms_output.put_line('number is odd');
END IF;
end;
/
#to calculate total,percent & pass class
##1
declare
a number:=&a;
b number:=&b;
c number:=&c;
d number:=&d;
e number:=&e;
t number;
p number;
begin
t:=a+b+c+d+e;
p:=t/5;
dbms_output.put_line('Total : ' || t);
dbms_output.put_line('Per : ' || p);
IF (p>=75) THEN
dbms_output.put_line('Distinction');
ELSIF (p>=60) THEN
dbms_output.put_line('1st class');
ELSIF (p>=50) THEN
dbms_output.put_line('2nd class');
ELSE
dbms_output.put_line('FAIL');
END IF;
END;
##2
declare
s1 number:=&s1;
s2 number:=&s2;
s3 number:=&s3;
s4 number:=&s4;
s5 number:=&s5;
total number;
per number;
begin
total:=s1+s2+s3+s4+s5;
per:=(total/5);
dbms_output.put_line('total ='||total);
dbms_output.put_line('percentage ='||per);
IF(per>75)THEN
dbms_output.put_line('Distinction');
ELSIF(per<=75 and per>60)THEN
dbms_output.put_line('first class');
ELSIF(per<=60 and per>50)THEN
dbms_output.put_line('second class');
ELSE
dbms_output.put_line('Failed');
END IF;
end;
/
#create table
create table Account( a integer, b integer); insert into Account values (101, 200);insert into Account values (102, 300);insert into Account values (103, 500);insert into Account values (104, 400);insert into Account values (105, 800); select * from Account; declareac number;mbal number:=500;cbal number;beginac := ∾select b into cbal from Account where a=ac;dbms_output.put_line('Current Balance = ' || cbal); IF(cbal<mbal) THENupdate Account set b=b-100 where a=ac;dbms_output.put_line('Balance is below 500, Deducting 100.');select b into cbal from Account where a=ac;dbms_output.put_line('Current Balance = ' || cbal);ELSEdbms_output.put_line('Balance is above 500, No deduction.');END IF;select * from Account;END;
create table account(ano number,cbal number);
insert into account values(101,1000);
insert into account values(102,1500);
insert into account values(103,2000);
insert into account values(104,2500);
insert into account values(105,500);
insert into account values(106,400);
declare
ac number;
mbal number:=500;
curbal number;
begin
ac:=∾
select cbal into curbal from account where ano=ac;
dbms_output.put_line('current balance='||curbal);
IF(curbal<mbal)THEN
update account set cbal=cbal-100 where ano=ac;
END IF;
end;
/
select * from account;
##profit
create table profitloss(id integer, costp integer, sellp integer); insert into profitloss values (101, 200, 300);insert into profitloss values (102, 300, 150);insert into profitloss values (103, 500, 500);insert into profitloss values (104, 400, 350);insert into profitloss values (105, 800, 1200); select * from profitloss; declarei number;c number;s number;begini:=&i;select costp into c from profitloss where id=i;select sellp into s from profitloss where id=i;dbms_output.put_line('Cost Price = ' || c);dbms_output.put_line('Selling Price = ' || s);IF(c<s) THENdbms_output.put_line('PROFIT');ELSIF(c=s) THENdbms_output.put_line('NO PROFIT OR LOSS');ELSEdbms_output.put_line('LOSS');END IF;END;
create table profitloss(id number,costp number,sellp number);
insert into profitloss values(11,200,400);
select * from profitloss;
declare
cp number;
sp number;
i number;
begin
i:=&id;
select costp into cp from profitloss where id=i;
select sellp into sp from profitloss where id=i;
if(sp>cp)then
dbms_output.put_line('profit');
else
dbms_output.put_line('loss');
end if;
end;
create table test12(id number, num number);
insert into test12 values(1,1);
insert into test12 values(2,2);
insert into test12 values(3,3);
insert into test12 values(4,4);
insert into test12 values(5,5);
select * from test12;
OUTPUT:-
ID NUM
---------- ----------
1 1
2 2
3 3
4 4
5 5
# sequential control
#GOTO <CODE BLOCK>
declare
no number;
ide number;
begin
ide:=1;
select num into no from test12 where id=ide;
<<Label1>>
if(no<3) then
dbms_output.put_line('Hello Welcome');
no:=no+2;
goto Label1;
else
dbms_output.put_line('Bye');
end if;
end;
OUTPUT:-
Hello Welcome
Bye
#null statement
declare
i number:=1;
begin
if(i=1) then
dbms_output.put_line('One');
else
goto end_loop;
end if;
<<end_loop>>
null;
end;
OUTPUT:-
One
declare
i number:=10;
begin
if(i=1) then
dbms_output.put_line('One');
else
goto end_loop;
end if;
<<end_loop>>
null;
end;
OUTPUT:-
PL/SQL procedure successfully completed.
__________________________________________________________________________________________________________________________________________________________________________
Practical 4 (simple loop,while loop, FOR loop)
#simple loop
declare
i number:=1;
begin
Loop
i:=i+2;
dbms_output.put_line(i);
exit when i>10;
End Loop;
dbms_output.put_line('loop exited as the value of i reached' || to_char(i));
end;
output:
3
5
7
9
11
loop exited as the value of i reached11
##While Loop : Factorial of a number --
declare
a number := &a;
f number := 1;
begin
while a>0
loop
f := f*a;
a := a-1;
end loop;
dbms_output.put_line('Factorial of given no. is ' || f);
end;
-- Output --
Enter value for a : 5
Factorial of given no. is 120
##While Loop : Print Fibonacci Series --
declare
a number := 0;
b number := 1;
c number := 0;
i number := 0;
begin
dbms_output.put_line('Fibonacci Series :');
dbms_output.put_line(a);
dbms_output.put_line(b);
while i<10
loop
c := a+b;
dbms_output.put_line(c);
a := b;
b := c;
i := i+1;
end loop;
end;
-- Output --
Fibonacci Series :
0
1
1
2
3
5
8
13
21
34
55
89
##While Loop : Odd Even Numbers between 1 to 50 --
declare
i number:= 1;
begin
dbms_output.put_line('Even Numbers between 1 to 50 :');
while i<=50
loop
if mod(i, 2) = 0 then
dbms_output.put_line(i);
end if;
i := i+1;
end loop;
i := 1;
dbms_output.put_line('Odd Numbers between 1 to 50 :');
while i<=50
loop
if mod(i, 2) > 0 then
dbms_output.put_line(i);
end if;
i := i+1;
end loop;
end;
-- Output --
Even Numbers between 1 to 50 :
2
4
6
...
46
48
50
Odd Numbers between 1 to 50 :
1
3
5
...
45
47
49
## While Loop : Numbers Divisible By 5 & 7 between 1 to 100 --
declare
i number:= 1;
begin
dbms_output.put_line('Numbers Divisible By 5 & 7 between 1 to 100 :');
while i<=1000
loop
if mod(i, 5) = 0 then
if mod(i, 7) = 0 then
dbms_output.put_line(i);
end if;
end if;
i := i+1;
end loop;
end;
-- Output --
Numbers Divisible By 5 & 7 between 1 to 100 :
35
70
#simple loop
declare
i number:=1;
begin
Loop
i:=i+2;
dbms_output.put_line(i);
exit when i>10;
End Loop;
dbms_output.put_line('loop exited as the value of i reached' || to_char(i));
end;
output:
3
5
7
9
11
loop exited as the value of i reached11
##while loop
##printing hello
declare
i number:=1;
begin
while(i<11)
Loop
dbms_output.put_line('hello');
i:=i+1;
End Loop;
end;
/
op:
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
###1 to 10 numbers printing
declare
i number:=1;
begin
while(i<11)
Loop
dbms_output.put_line(i);
i:=i+1;
End Loop;
end;
/
op:-
1
2
3
4
5
6
7
8
9
10
##addition of 1 to 10 no:
declare
i number:=1;
a number:=0;
begin
while(i<11)
Loop
a:=a+i;
i:=i+1;
End Loop;
dbms_output.put_line('addition=' || to_char(a));
end;
/
op:
addition=55
##user input number and sum of that number
declare
i number:=&i;
a number:=0;
begin
while(i<6)
Loop
a:=i+1;
i:=a+i;
dbms_output.put_line('addition=' || to_char(a));
End Loop;
end;
##
declare
i number:=&i;
a number:=0;
begin
while(i<6)
Loop
a:=a+i;
i:=i+1;
End Loop;
dbms_output.put_line('addition=' || to_char(a));
end;
##factorial
declare
n number:=5;
s number;
begin
while(n<=5)
Loop
s:=n*n;
End Loop;
dbms_output.put_line('factorial=' || to_char(s));
end;
op:
factorial=120
## FOR loop
##display 1 to 10 numbers
declare
begin
for i in 1..10
loop
dbms_output.put_line('number is: '||i);
end loop;
end;
##op
number is: 1
number is: 2
number is: 3
number is: 4
number is: 5
number is: 6
number is: 7
number is: 8
number is: 9
number is: 10
##factorial 1 to 10
declare
f number := 1;
begin
for i in 1..10
loop
f := f*i;
dbms_output.put_line('Factorial of given no. is ' || f);
end loop;
end;
##op
Factorial of given no. is 1
Factorial of given no. is 2
Factorial of given no. is 6
Factorial of given no. is 24
Factorial of given no. is 120
Factorial of given no. is 720
Factorial of given no. is 5040
Factorial of given no. is 40320
Factorial of given no. is 362880
Factorial of given no. is 3628800
##sum of 1 to 10 numbers
declare
i integer;
s integer;
begin
s:=0;
for i in 1..10
loop
s:=s+i;
end loop;
dbms_output.put_line('Sum = '||s);
end;
##op
Sum = 55
##Fibonacci Series
declare
a number:=0;
b number:=1;
t number;
n number:=10;
i number;
begin
dbms_output.put_line('Fibonacci Series :');
dbms_output.put_line(a);
dbms_output.put_line(b);
for i in 1..n
loop
t:= a+b;
a:= b;
b:= t;
dbms_output.put_line(t);
end loop;
end;
##op
Fibonacci Series :
0
1
1
2
3
5
8
13
21
34
55
89
##odd even no. 1 to 100
declare
i number:= 1;
begin
dbms_output.put_line('Even Numbers between 1 to 100 :');
for i in 1..100
loop
if mod(i, 2) = 0 then
dbms_output.put_line(i);
end if;
end loop;
i := 1;
dbms_output.put_line('Odd Numbers between 1 to 100:');
for i in 1..100
loop
if mod(i, 2) > 0 then
dbms_output.put_line(i);
end if;
end loop;
end;
##op
Even Numbers between 1 to 100 :
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
Odd Numbers between 1 to 100:
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99
##display no.divisible by 5 & 7 from 1 to 100
declare
i number:= 1;
begin
dbms_output.put_line('Numbers Divisible By 5 & 7 between 1 to 100 :');
for i in 1..100
loop
if mod(i, 5) = 0 then
if mod(i, 7) = 0 then
dbms_output.put_line(i);
end if;
end if;
end loop;
end;
##op
Enter value for 7: 35
old 4: dbms_output.put_line('Numbers Divisible By 5 & 7 between 1 to 100 :');
new 4: dbms_output.put_line('Numbers Divisible By 5 35 between 1 to 100 :');
Numbers Divisible By 5 35 between 1 to 100 :
35
70
______________________________________________________________________________________________________________________________________
Practical 5 (case statement)
#case statement
1.simple case statement
declare
deptno number:=10;
dept_desc varchar(20);
begin
dept_desc:=case deptno
when 10 then 'Account'
when 20 then 'Research'
when 30 then 'Sales'
when 40 then 'Operational'
else 'unknown'
end;
dbms_output.put_line(dept_desc);
end;
OUTPUT:-
Account
declare
day number:=1;
day_name varchar(20);
begin
day_name:=case day
when 1 then 'Sunday'
when 2 then 'Monday'
when 3 then 'Tuesday'
when 4 then 'Wednesday'
when 5 then 'Thursday'
when 6 then 'Friday'
when 7 then 'Saturday'
else 'invalid number'
end;
dbms_output.put_line(day_name);
end;
Output:-
Sunday
2.searched case statement
declare
sal number:=10000;
sal_desc varchar(20);
begin
sal_desc:=case
when sal<1000 then 'Low'
when sal between 1000 and 3000 then 'Medium'
when sal>3000 then 'High'
else 'NA'
end;
dbms_output.put_line(sal_desc);
end;
OUTPUT:-
High
declare
temp number:=25;
temperature varchar(20);
begin
temperature:=case
when temp<20 then 'Cool'
when temp between 20 and 31 then 'Rainy'
when temp between 31 and 41 then 'High'
else 'NA'
end;
dbms_output.put_line(temperature);
end;
OUTPUT:-
Rainy
#FACTORIAL by using goto<code block>
declare
f number:=1;
begin
<<Label1>>
for i in 1..10
loop
f:=f*i;
dbms_output.put_line('Factorial for given number is' ||f);
________________________________________________________________________________________________________
Practical 6 (function )
##function
create table book(name varchar(10), author varchar(10), price number);
insert into book values('ABC', 'PQR',100);
insert into book values('ADC', 'KPQ',200);
insert into book values('TSV', 'PQS',300);
insert into book values('ABT', 'PQL',400);
insert into book values('ABE', 'PQY',500);
select * from book;
op:
NAME AUTHOR PRICE
---------- ---------- ----------
ABC PQR 100
ADC KPQ 200
TSV PQS 300
ABT PQL 400
ABE PQY 500
create or replace function book1
return number is
b number;
begin
select count(name) into b from book;
return b;
end;
op:
Function created.
select book1 from dual;
op:
BOOK1
----------
5
create or replace function book2
return number is
b number;
begin
select max(price) into b from book;
return b;
end;
select book2 from dual;
op:
BOOK2
----------
500
create or replace function addition(a number, b number)3
return number is
c number;
begin
c:=a+b;
return c;
end;
select addition(100,20) from dual;
op:
BOOK2
----------
500
##factorial
create or replace function factorial
return number is
f number:=1;
begin
for i in 1..10
loop
f := f*i;
end loop;
return f;
end;
select factorial from dual;
op:
FACTORIAL
----------
3628800
#Factorial create or replace function fact1(n number)return number isa number:=1;beginfor i in 1..nloopa:=a*i;end loop;return a;end;/select fact1(6) from dual; **fibonacci create or replace function fibo2return number isa number:= 0;b number:= 1;c number;beginfor i in 1..10loopc:=a+b;dbms_output.put_line(c)end loop;return c;end;/select fibo2 from dual;
##fibonacci series
create or replace function fibonacci
return number is
a number:=0;
b number:=1;
t number;
n number:=10;
i number;
begin
for i in 1..n
loop
t:= a+b;
a:= b;
b:= t;
end loop;
return t;
end;
select fibonacci from dual;
op:
FIBONACCI
----------
89
##odd even
create or replace function oddeven(n number)
return number is
a number;
begin
if mod(a, 2) = 0 then
end if;
return a;
end;
#grade of student
create table student1(name varchar(10), grade varchar(10),per number);
insert into student1 values('Jia','A',95);
insert into student1 values('Tia','C',50);
insert into student1 values('Siya','B',70);
insert into student1 values('John','D',35);
insert into student1 values('William','A',90);
select * from student1;
op:
NAME GRADE PER
---------- ---------- ----------
Jia A 95
Tia C 50
Siya B 70
John D 35
William A 90
create or replace function student2
return number is
b number;
begin
select max(per) into b from student1;
return b;
end;
select student2 from dual;
op:
STUDENT2
----------
95
create or replace function student4
return varchar is
b varchar;
begin
select count(grade) into b from student1;
return b;
end;
select student4 from dual;
##
set serveroutput on; -- Code 1 : Factoial of a number using Function --create or replace function Fact(n number)return number isf number := 1;a number:= n;beginwhile a>1loopf := f*a;a := a-1;end loop;return f;end;/select Fact(5) from dual; -- Output -- FACT(5)---------- 120 -- Code 2 : Check number is odd or even using function --create or replace function OddEven(n number)return varchar isa varchar(10);beginif mod(n,2) = 0 thena := 'Even';elsea:= 'Odd';return a;end;/select OddEven(5) from dual; -- Output -- OddEven(5)-------------- 120 -- Code 3 : Fibonacci series using function --create or replace function Fibonaccireturn varchar isr varchar(20) := 'Starring no. 0 and 1';a number:= 0;b number:= 1;t number;beginfor i in 1..10loopt := a+b;a := b;b := t;dbms_output.put_line(t);end loop;return r;end;/select Fibonacci from dual; -- Output --FIBONACCI---------------------Starring no. 0 and 1 123581321345589 -- Code 4 : Find Grade of Student using function --create or replace function Grade(a number, b number, c number, d number, e number)return varchar isr varchar(20);t number;p number;begint:=a+b+c+d+e;p:=t/5;dbms_output.put_line('Total Marks : ' || t);dbms_output.put_line('Percentage : ' || p);if p>=75 thenr := 'Distinction';elsif p>=60 thenr := '1st Class';elsif p>=50 thenr := '2nd Class';elser := 'Fail';end if;r := 'Result : ' || r;return r;end;/select Grade(80, 83, 86, 71, 90) from dual; -- Output --GRADE(80,83,86,71,90)---------------------Result : Distinction Total Marks : 410Percentage : 82
Practical 7(procedure)
## procedure
---simple---
create or replace procedure Data
is
begin
dbms_output.put_line('Hello');
end;
---for executing---
declare
begin
Data()
end;
--IN parameter--
create or replace procedure BFC(a IN number,b IN number)
is
c number;
begin
c:=a+b;
dbms_output.put_line('Addition '||c);
end;
--executing--
declare
a number:=10;
b number:=10;
begin
BFC(a,b);
end;
--OUT parameter--
create or replace procedure text(c out number)
is
a number:=10;
b number:=20;
begin
c:=a+b;
dbms_output.put_line('Addition '||c);
end;
declare
c number;
begin
text(c);
end;
--IN Out number--
create or replace procedure text(a in number,b in out number)
is
begin
b:=a+b;
dbms_output.put_line('Addition '||b);
end;
declare
a number:=10;
b number:=10;
begin
text(a,b);
end;
**Factorial**
create or replace procedure Vedant(a IN number,b IN number)
is
f number;
begin
while(a>0)
loop
f:=a*b;
f:=f-1;
end loop;
dbms_output.put_line('Factorial '||f);
end;
declare
a number:=10;
b number:=1;
begin
Vedant(a,b)
end;
pract7.txt
Details
Activity
Sharing Info.
Who has access
P
Manage access
General Info.
System properties
Type
Text
Size
1 KB
Storage used
1 KB
Location
Practical 7
Owner
Piyush Burate 528
Modified
Sep 15, 2022 by Piyush Burate 528
Opened
7:14 PM by me
Created
Sep 15, 2022
Description.
No description
Download permissions.
Viewers can download
---SIMPLE PROCEDURE---
create or replace procedure Data
is
begin
dbms_output.put_line('Hello');
end;
---Executing Procedure---
declare
begin
Data();
end;
---IN parameter---
create or replace procedure Data(a IN number,b IN number)
is
c number;
begin
c:=a+b;
dbms_output.put_line('Addition '||c);
end;
/
declare
a number:=10;
b number:=10;
begin
Data(a,b);
end;
---OUT parameter---
create or replace procedure Data(c Out number)
is
a number:=10;
b number:=10;
begin
c:=a+b;
end;
declare
c number;
begin
Data(c);
dbms_output.put_line('Addition '||c);
end;
---IN OUT parameter---
create or replace procedure Data(a IN number,b IN out number)
is
begin
b:=a+b;
end;
declare
a number:=20;
b number:=20;
begin
Data(a,b);
dbms_output.put_line('Addition '||b);
end;
##Factorial
create or replace procedure Data(a IN number,b IN number)
is
begin
while(b>0)
loop
b:=a*b;
b:=b-1;
end loop;
dbms_output.put_line('Factorial of num: '||b);
end;
______________________________________________________________________________________________________________________________________
Practical 8( Trigger)
create table customer(id number,name varchar(10),age number,address varchar(10),salary number);
insert into customer values(1,'xyz',20,'chiplun',1000);
insert into customer values(2,'dhg',21,'khed',2000);
insert into customer values(3,'mkl',30,'pune',3000);
insert into customer values(4,'bjf',22,'mumbai',4000);
insert into customer values(5,'dcg',31,'up',5000);
select * from customer;
op:
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 xyz 20 chiplun 1000
2 dhg 21 khed 2000
3 mkl 30 pune 3000
4 bjf 22 mumbai 4000
5 dcg 31 up 5000
create or replace trigger tr1
before delete or insert or update on customer
for each row
when(new.id>0)
declare
s number;
begin
s:= :new.salary - :old.salary;
dbms_output.put_line('old salary:' || :old.salary);
dbms_output.put_line('new salary:' || :new.salary);
dbms_output.put_line('salary difference:' || s);
end;
op:
trigger created.
insert into customer values(6,'abc',45,'us',6000);
op:
old salary:
new salary:6000
salary difference:
update customer set salary=salary+500 where id=3;
op:
old salary:3000
new salary:3500
salary difference:500
select * from customer;
op:
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 xyz 20 chiplun 1000
2 dhg 21 khed 2000
3 mkl 30 pune 3500
4 bjf 22 mumbai 4000
5 dcg 31 up 5000
6 abc 45 us 6000
6 rows selected.
drop trigger tr1;
______________________________________________________________________________________________________________________________________
Practical 9 (Cursor)
create table emp_master(emp_no number,branch_no number);
insert into emp_master values(1,101);
insert into emp_master values(2,102);
insert into emp_master values(3,103);
insert into emp_master values(4,104);
insert into emp_master values(5,105);
select * from emp_master;
O/P:-
EMP_NO BRANCH_NO
---------- ----------
1 101
2 102
3 103
4 104
5 105
## IMPLICIT CURSOR
declare
begin
update emp_master set branch_no=&branch_no where emp_no=&emp_no;
if SQL% found then
dbms_output.put_line('data found');
else
dbms_output.put_line('data not found');
end if;
end;
O/P:-
Enter value for branch_no: 103
Enter value for emp_no: 7
old 3: update emp_master set branch_no=&branch_no where emp_no=&emp_no;
new 3: update emp_master set branch_no=103 where emp_no=7;
data not found
PL/SQL procedure successfully completed
O/P 2ND:-
Enter value for branch_no: 101
Enter value for emp_no: 1
old 3: update emp_master set branch_no=&branch_no where emp_no=&emp_no;
new 3: update emp_master set branch_no=101 where emp_no=1;
data found
##EXPLICIT CURSOR
declare
cursor c1 is select * from emp_master;
z c1 % rowtype;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('data'|| z.emp_no);
fetch c1 into z;
end loop;
close c1;
end;
O/P:
data1
data2
data3
data4
data5
PL/SQL procedure successfully completed.
##addition
create table add_num(num1 number, num2 number);
insert into add_num values(1,10);
insert into add_num values(2,20);
insert into add_num values(3,30);
insert into add_num values(4,40);
insert into add_num values(5,50);
select * from add_num;
declare
cursor c1 is select * from add_num;
z c1%rowtype;
a number:=0;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('data '||z.num2);
a:=a+z.num2;
fetch c1 into z;
end loop;
dbms_output.put_line('addition '||a);
close c1;
end;
O/P:
data 10
data 20
data 30
data 40
data 50
addition 150
PL/SQL procedure successfully completed.
#Employeee
create table employee(emp_no number, emp_name varchar(10), emp_address varchar(20), emp_salary number);
insert into employee values(1,'john','mumbai',1000);
insert into employee values(2,'joe','pune',2000);
insert into employee values(3,'yash','chiplun',3000);
insert into employee values(4,'raj','khed',4000);
insert into employee values(5,'tia','banglore',5000);
select * from employee;
declare
cursor c3 is select * from employee;
t c3 % rowtype;
begin
open c3;
fetch c3 into t;
while(c3 % found)
loop
dbms_output.put_line('salary of employee:'|| t.emp_salary);
fetch c3 into t;
end loop;
close c3;
end;
O/P:
salary of employee:1000
salary of employee:2000
salary of employee:3000
salary of employee:4000
salary of employee:5000
PL/SQL procedure successfully completed.
declare
cursor c1 is select* from employee;
z c1%rowtype;
a number:=0;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('data '||z.emp_salary);
a:=(a+z.emp_salary)/5;
fetch c1 into z;
end loop;
dbms_output.put_line('average salary '||a);
close c1;
end;
O/P:
data 1000
data 2000
data 3000
data 4000
data 5000
average salary 1187.52
PL/SQL procedure successfully completed.
declare
cursor c1 is select* from employee;
z c1%rowtype;
f number:=1;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
f:=(z.emp_no)*(f);
dbms_output.put_line('data '||z.emp_no);
dbms_output.put_line('factorial '||f);
fetch c1 into z;
end loop;
close c1;
end;
O/P
data 1
factorial 1
data 2
factorial 2
data 3
factorial 6
data 4
factorial 24
data 5
factorial 120
PL/SQL procedure successfully completed.
declare
cursor c1 is select* from employee;
z c1%rowtype;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
fetch c1 into z;
end loop;
dbms_output.put_line('count '||z.emp_no);
close c1;
end;
OP:=
count 5
create table emp_master(emp_no number, branch_no number);
insert into emp_master values(1,101);
insert into emp_master values(2,102);
insert into emp_master values(3,103);
insert into emp_master values(4,104);
insert into emp_master values(5,105);
select * from emp_master;
declare
begin
update emp_master set branch_no=&branch_no where emp_no=&emp_no;
if SQL%found Then
dbms_output.put_line('data found');
else
dbms_output.put_line('Data Not found');
end if;
end;
/
declare
cursor c1 is select* from emp_master;
z c1%rowtype;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('data'||z.emp_no);
fetch c1 into z;
end loop;
close c1;
end;
/
******************task*****************************************************************
create table addnum(num1 number, num2 number);insert into addnum values(1, 10);insert into addnum values(2, 20);insert into addnum values(3, 30);insert into addnum values(4, 40);insert into addnum values(5, 50);select * from addnum; // Row Number Additiondeclarecursor c1 isselect * from addnum;z c1%rowtype;add number := 0;n number := 1;beginopen c1;fetch c1 into z;while (c1%found)loopadd := z.num1 + z.num2;dbms_output.put_line('Row ' || n || ' Addition : ' || add);fetch c1 into z;n := n+1;end loop;/>>> Row 1 Addition : 11>>> Row 2 Addition : 22>>> Row 3 Addition : 33>>> Row 4 Addition : 44>>> Row 5 Addition : 55 // Column Number Additiondeclarecursor c2 isselect * from addnum;z c2%rowtype;col1 number := 0;col2 number := 0;beginopen c2;fetch c2 into z;while (c1%found)loopcol1 := col1 + z.num1;col2 := col2 + z.num2;fetch c2 into z;end loop;dbms_output.put_line('Column 1 Addition : ' || col1);dbms_output.put_line('Column 2 Addition : ' || col2);close c2;end;/ >>> Column 1 : 15>>> Column 2 : 150
***************************************************************************************
create table emp(emp_id number,name varchar(20), address varchar(20),salary number);
insert into emp values(1,'ibrahim','cpn',10000);
insert into emp values(2,'harsh','khed',50000);
insert into emp values(3,'shams','cpn',20000);
insert into emp values(4,'chatniya','kherdi',9000);
insert into emp values(5,'anas','khed',10000);
select * from emp;
declare
cursor c1 is select* from emp;
z c1%rowtype;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('salary '||z.salary);
fetch c1 into z;
end loop;
close c1;
end;
/
declare
cursor c1 is select* from emp;
z c1%rowtype;
a number:=0;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
dbms_output.put_line('data '||z.salary);
a:=(a+z.salary)/5;
fetch c1 into z;
end loop;
dbms_output.put_line('average salary '||a);
close c1;
end;
/
declare
cursor c1 is select* from emp;
z c1%rowtype;
f number:=1;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
f:=(z.emp_id)*(f);
dbms_output.put_line('data '||z.emp_id);
dbms_output.put_line('factorial '||f);
fetch c1 into z;
end loop;
close c1;
end;
/
declare
cursor c1 is select* from emp;
z c1%rowtype;
begin
open c1;
fetch c1 into z;
while (c1 % found)
loop
fetch c1 into z;
end loop;
dbms_output.put_line('count '||z.emp_id);
close c1;
end;
// table employee (empno empname addr salary)create table emp_chart (empno number, empname varchar(20), addr varchar(20), salary number);insert into emp_chart values (1, 'ABC', 'Chiplun', 10000);insert into emp_chart values (2, 'ABC', 'Chiplun', 12000);insert into emp_chart values (3, 'ABC', 'Chiplun', 14000);insert into emp_chart values (4, 'ABC', 'Chiplun', 16000);insert into emp_chart values (5, 'ABC', 'Chiplun', 18000); select * from emp_chart; // Display Salarydeclarecursor c1 isselect * from emp_chart;z c1%rowtype;beginopen c1;fetch c1 into z;while (c1%found)loopdbms_output.put_line('Employee No.' || z.empno || ' Salary : ' || z.salary);fetch c1 into z;end loop;close c1;end;/ // Average Salary of Employeesdeclarecursor c1 isselect * from emp_chart;z c1%rowtype;a integer := 0;beginopen c1;fetch c1 into z;while (c1%found)loopa := a + z.salary;fetch c1 into z;end loop;a := a/5;dbms_output.put_line('Average Salary of Employees : ' || a);close c1;end;/ // factorial of empnodeclarecursor c1 isselect * from emp_chart;z c1%rowtype;f number := 1;beginopen c1;fetch c1 into z;while (c1%found)loopfor i in 1..z.empnoloopf := f * i;end loop;dbms_output.put_line('TFactorial of Employee No.' || z.empno || ' : ' || f);fetch c1 into z;end loop;close c1;end;/ // count no. of rowsdeclarecursor c1 isselect * from emp_chart;z c1%rowtype;c number := 0;beginopen c1;fetch c1 into z;while (c1%found)loopc := c+1;fetch c1 into z;end loop;dbms_output.put_line('Total No. of Rows : ' || c);close c1;end;/Q. Given
no is palindrome or not .
Examples:
Input : 12221
Output : true
Input : 12345
Output : false
Below is the required implementation:
Code:
declare
-- declare variable n, m, temp
-- and temp of datatype number
n number;
m number;
temp number:=0;
rem number;
begin
n:=5432112345;
m:=n;
-- while loop with condition
till n>0
while n>0
loop
rem:=mod(n,10);
temp:=(temp*10)+rem;
n:=trunc(n/10);
end loop; -- end of while loop
here
if m = temp
then
dbms_output.put_line('true');
else
dbms_output.put_line('false');
end if;
end;
/
Q. Write
a PL/SQL code block for inverting a number ‘102345’ and string ‘AMITY’.
SQL> declare
2
num varchar(6):='102345';
3
len number(2);
4
rev varchar(6);
5
begin
6
len:=length(num);
7
for cntr in reverse 1..len
8
loop
9
rev:=rev||substr(num,cntr,1);
10
end loop;
11
dbms_output.put_line('The Given Number is'||num);
12
dbms_output.put_line('The Inverted Number is'||rev);
13
end;
14
/
The Given Number is102345
The Inverted Number is543201
PL/SQL procedure successfully completed.
Q. Program
to invert string ‘AMITY’.
SQL> set serveroutput on;
SQL> declare
2
given_str varchar(5):='AMITY';
3
str_length number(2);
4
inv_str varchar(5);
5
begin
6
str_length := length(given_str);
7
for cntr IN REVERSE 1..str_length
8
loop
9
inv_str := inv_str || substr(given_str,cntr,1);
10
end loop;
11
dbms_output.put_line('The given String is' || given_str);
12
dbms_output.put_line('The inverted String is ' || inv_str);
13
end;
14
/
The given String is AMITY
The inverted String is YTIMA
Q. -Find
the area and perimeter of circle
DECLARE
-- Variables to store area and
perimeter
area NUMBER(6, 2)
;
perimeter NUMBER(6, 2)
;
--Assigning the value of
radius
radius NUMBER(1) := 3;
--Constant value of PI
pi CONSTANT NUMBER(3, 2) :=
3.14;
BEGIN
--Formula for area and
perimeter of a circle
area := pi * radius *
radius;
perimeter := 2 * pi *
radius;
dbms_output.Put_line('Area
= ' || area);
dbms_output.Put_line('
Perimeter = ' || perimeter);
END;
Output:
Area = 28.26
Perimeter = 18.84


