Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
PL SQL Lab work

PL SQL Lab work

Ratings: (0)|Views: 180|Likes:
Published by Shaan Gontia
Lab work, PL SQL commands basic scripts. Lab work for BTech/Mtech students
Lab work, PL SQL commands basic scripts. Lab work for BTech/Mtech students

More info:

Published by: Shaan Gontia on Sep 05, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/23/2013

pdf

text

original

 
Shantanu Gontia 120913010, MTech-CSE1 |Page 
PL/SQL: Basic Programming Constructs,Exception Handling and Stored Subprograms
Submitted by:Shantanu GontiaReg No 120913010MTech CSE, 1
st
Year
1.
 
Write a Pl/Sql block to compute the value of 10! (i.e. 10*9*8*7*6*5*4*3*2*1), without andwith looping constructs.A.
 
With Loop:
declarecnt number;num number:=1;result number(3);beginfor cnt in 1..10 loopnum:= num*(cnt);end loop;dbms_output.put_line('Factorial 10 is: '|| num);end;
 
Shantanu Gontia 120913010, MTech-CSE2 |Page 
B.
 
Without Loop:
declarecnt number:=1;num number:=1;result number(3);beginnum:= num*(cnt)*(cnt+1)*(cnt+2)*(cnt+3)*(cnt+4)*(cnt+5)*(cnt+6)*(cnt+7)*(cnt+8)*(cnt+9);dbms_output.put_line('Factorial 10 is: '|| num);end;
2.
 
Write a PL/SQL procedure that accepts a single positive number as input, and prints out thefactorial of that number.Result:
create procedure factorial(input in number)iscnt number;result number:=1;beginfor cnt in 1..input loopresult:=result*(cnt);end loop;dbms_output.put_line('Factorial of ' ||input|| 'is: '|| result);end;execute factorial(3);
 
Shantanu Gontia 120913010, MTech-CSE3 |Page 
3.
 
Handle the division-by-zero exception in the
invert
function which computes inverse of the given number.Ans:
CREATE OR REPLACE FUNCTION INVERTTRETURN NUMBERISFIRST number(5,4);SECOND number(5);BEGINdbms_output.put_line('-----PROGRAM TO INVERT NUMBER----');FIRST:=1/&SECOND;dbms_output.put_line('INVERTED NUMBER IS----'||FIRST);RETURN(FIRST);EXCEPTIONWHEN ZERO_DIVIDE thendbms_output.put_line('YOU ARE DIVIDING BY ZERO');END INVERTT;

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->