0% found this document useful (0 votes)
17 views3 pages

PL/SQL Operations Ex. No: Date

This document provides examples of four PL/SQL operations: 1) A reverse number procedure that takes a number as input, reverses the digits, and displays the original and reversed numbers. 2) An addition procedure that takes two numbers as input, adds them together, and displays the sum. 3) A print numbers procedure that takes a value n as input and prints the numbers from 1 to n. 4) An update table procedure that takes a house number as input, looks up the corresponding amount in a master table, and updates the amount if it is over $1000 by reducing it by 10%.

Uploaded by

aaanathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

PL/SQL Operations Ex. No: Date

This document provides examples of four PL/SQL operations: 1) A reverse number procedure that takes a number as input, reverses the digits, and displays the original and reversed numbers. 2) An addition procedure that takes two numbers as input, adds them together, and displays the sum. 3) A print numbers procedure that takes a value n as input and prints the numbers from 1 to n. 4) An update table procedure that takes a house number as input, looks up the corresponding amount in a master table, and updates the amount if it is over $1000 by reducing it by 10%.

Uploaded by

aaanathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

PL/SQL OPERATIONS

Ex. No:
Date:
Aim:
Write the following PL/SQL operations.
Addition of two numbers
Print 1.n
Reverse a number
update a table
SQL set server output on!
REVERSE
SQL de"lare
# given$number number%1&'()*given$number!
+ entr number%#'!
, inverted$number var"har#%1&'!
- begin
. entr()length%given$number'!
/ while entr&
0 loop
1 inverted$number()inverted$number22substr%given$number3entr31'!
1& entr()entr41!
11 end loop!
1# 567S$89:P9:.P9:$L;<=%>:he given number is>22given$number'!
1+ 567S$89:P9:.P9:$L;<=%>:he inverted number is>22inverted$number'!
1, end!
1- /
=nter value for given$number( 1#
old #( given$number number%1&'()*given$number!
new #( given$number number%1&'()1#!
:he given number is1#
:he inverted number is#1
PL/SQL pro"edure su""essfull? "ompleted.
ADDITION
SQL 5=@LAR=
# input number%1&'()*input!
+ input1 number%1&'()*input1!
, output number%1&'!
- 6=A;<
. output()inputBinput1!
/ 567S$89:P9:.P9:$L;<=%>:C= A55;:;8< 8D :W8 <8S ;S>22output'!
0 =<5!
1 /
=nter value for input( +
old #( input number%1&'()*input!
new #( input number%1&'()+!
=nter value for input1( .
old +( input1 number%1&'()*input1!
new +( input1 number%1&'().!
:C= A55;:;8< 8D :W8 <8S ;S1
PL/SQL pro"edure su""essfull? "ompleted.
PRINT 1N
SQL 5=@LAR=
# n number%1&'()*n!
+ i number%+'()&!
, begin
- while iEn
. loop
/ 567S$89:P9:.P9:$L;<=%i'!
0 i()iB1!
1 end loop!
1& end!
11 /
=nter value for n( .
old #( n number%1&'()*n!
new #( n number%1&'().!
&
1
#
+
,
-
PL/SQL pro"edure su""essfull? "ompleted.
UPDATE A TABLE:
;nstru"tion4get the house number and amount data t?pe of master table. Aet the
house no3 from the house no find the amount from the master table and transfer to a
variable p.if p#-&& then update master table amount with
#&F redu"tion.%ele"tri"it? board table'
SQL de"lare
# h board.house$noFt?pe!
+ a board.amtFt?pe!
, 6=A;<
- h()*h!
. sele"t amt into a from board where house$no)h!
/ if a #-&& then
0 update board set amt ) a4aG&.# where house$no)h!
1 else
1& 567S$89:P9:.P9:$L;<=%><8: @CA<A=5>'!
11 =<5 ;D!
1# =<5!
1+ /
=nter value for h( 1&&
old -( h()*h!
new -( h()1&&!
<8: @CA<A=5
PL/SQL pro"edure su""essfull? "ompleted.
RESULT
:hus the PL/SQL operations are eHe"uted.

You might also like