Plsql programs(encrypted)

download Plsql programs(encrypted)

If you can't read please download the document

description

real-time readymade sql programs...

Transcript of Plsql programs(encrypted)

  • 1. http://placementkit.blogspot.com/PL / SQL PROGRAMSP1. WRITE A NESTED PROGRAM TO ADD AND TO MULTIPLY TWO NUMBERS.DECLAREN1 number;N2 number;Sum number ;BEGINSum := N1+N2 ;>DECLAREProd number;BEGINProd := N1 * N2 ;Dbms_output.put_line( Product Value = prod );END inner_block ;Dbms_output.put_line( Sum Value = sum);END;P2. WRITE A PROGRAM TO CALCULATE THE SIMPLE INTEREST AND COMPUNDINTEREST ,IF P, N, R ARE GIVEN.declarep number(9,2) ;n number(9,2) ;r number(9,2) ;si number(9,2) := 0;ci number(9,2) := 0;beginp := &principal_amount;n := &no_of_years;r := &rate_of_interest;si := p*n*r/100;ci := p*(1+r/100)**n;dbms_output.put_line(simple interset =si);dbms_output.put_line(compound interset = ci);end;SQL> /Enter value for principal_amount: 10000old 8: p:=&principal_amount;new 8: p:=10000;Enter value for no_of_years: 5old 9: n:=&no_of_years;new 9: n:=5;Enter value for rate_of_interest: 10.5old 10: r:=&rate_of_interest;new 10: r:=10.5;simple interset =5250compound interset =16474.47PL/SQL procedure successfully completed.PROGRAM BASED ON IF LOOP

2. http://placementkit.blogspot.com/P3 . Write a program to check greatest of two numbers :declarea number(3) :=20;b number(3) :=10;beginif a>b thendbms_output.put_line(a is the greatest :a);elsedbms_output.put_line(B is the greatest :b);end if;end;SQL> /a is the greatest : 20PL/SQL procedure successfully completed.P4. Given 2 sides of a rectangle .Write a program to find out its area is greater than its perimeter or not .declarel number;b number;ar number;pr number;beginl := &l;b := &b;ar := l*b;pr := 2*(l+b);if ar > pr thendbms_output.put_line(the area iS > its perimeter area =ar perimeter =pr);elsedbms_output.put_line(the area iS < its perimeterarea =ar perimeter =pr);end if;end;Enter value for l: 10old 7: l:=&l;new 7: l:=10;Enter value for b: 6old 8: b:=&b;new 8: b:=6;the area is > its perimeter area = 60 perimeter = 32PL/SQL procedure successfully completed.P5. WRITE A PROGRAM TO INPUT A SINGLE DIGIT NO: CONVERT IT INTO WORDS.Declarea number;t varchar2(10);begina :=&a;if a=1 then 3. http://placementkit.blogspot.com/t := one;elsif a=2 thent := two;elsif a= 3 thent := three;elsif a= thent := four;elsif a=5 thent := five;elsif a=6 thent := six;elsif a=7 thent := seven;elsif a=8 thent := eight;elsif a=9 thent := nine;elset := zero;end if;dbms_output.put_line(a = t);end;Enter value for a: 2old 5: a:=&a;new 5: a:=2;2 = twoPL/SQL procedure successfully completed.P6 . Write a program to check the given number is +ve or ve :SQL>declaren number(2):=12;beginif n>0 thendbms_output.put_line(the given number is positive n);elsedbms_output.put_line(the given number is negativen);end if;end;/SQL> save posneg.sqlCreated file posneg.sqlSQL >The given number is positive 12PL/SQL procedure successfully completed.PROGRAM BASED ON NESTED IF LOOPP7. WRITE A PROGRAM TO INPUT 2 NUMBERS IF THE 1st No >2nd No THEN SWAPIT, ELSE IF 1st No < 2nd No RAISE IT TO ITS POWER , ELSE DOUBLES IT.declarea number(5);b number(5); 4. http://placementkit.blogspot.com/t number(5);begina := &a;b := &b;dbms_output.put_line( initial value of a =a b= b)if a>bthent:= a;a:= b;b:=t;elsIF A /Enter value for a: 4old 6: a:=&a;new 6: a:=4;Enter value for b: 5old 7: b:=&b;new 7: b:=5;initial value of a = 4 b = 5final value of a = 256 b = 3125PL/SQL procedure successfully completed.SQL> /Enter value for a: 5old 6: a:=&a;new 6: a:=5;Enter value for b: 4old 7: b:=&b;new 7: b:=4;initial value of a = 5 b = 4final value of a = 4 b = 5PL/SQL procedure successfully completed.SQL> Enter value for a: 5old 6: a:=&a;new 6: a:=5;Enter value for b: 5old 7: b:=&b;new 7: b:=5;initial value of a = 5 b = 5final value of a = 10 b = 10PL/SQL procedure successfully completed.P8. A bank accepts fixed deposits for one or more years and the policy it ad 5. http://placementkit.blogspot.com/opts on interest is as follows:If a deposit is < Rs 2000 and for 2 or more years , the interest rate is 5% compounded annually.If a deposit is Rs.2000 or more but less than 6000 and for 2 or moreyears , the interest is 7 % compounded annually.If a deposit is Rs.6000 and for 1 or more years , the interest is 8% compounded annually.On all deposits for 5 years or more , interest is 10% compounded annually.On all other deposits not covered by above conditions , the interestis 3% compounded annually.Given the amount deposited and the number of years , Write a program to calculate the amount on maturity.declarep number(9,2);r number(9,2);t number(9,2);ci number(9,2);beginp := &p;t := &t;if p=2 thenr := 5;elsif p>=2000 and p=2 thenr := 7;elsif p>6000 and t>=1 thenr := 8;elsif t>=5 thenr := 10;elser := 3;end if;ci := p*(1+r/100)**t - p;dbms_output.put_line(The Principal amount is =p);dbms_output.put_line(The rate of interest is = r);dbms_output.put_line(The time period is = t);dbms_output.put_line(The compund interst is = ci);end;Enter value for p: 10000old 7: p:=&p;new 7: p:=10000;Enter value for t: 5old 8: t:=&t;new 8: t:=5;The Principal amount is =10000The rate of interest is =8The time period is =5The compund interst is =4693.28PL/SQL procedure successfully completed.Enter value for p: 1500 6. http://placementkit.blogspot.com/old 7: p:=&p;new 7: p:=1500;Enter value for t: 3old 8: t:=&t;new 8: t:=3;The Principal amount is =1500The rate of interest is =5The time period is =3The compound interest is =236.44PL/SQL procedure successfully completed.P9. WRITE A PROGRM TO INPUT 3 NUMBERS FIND THE 1st Greatest, 2nd Greatest,3rd Greatest.declarea number(3);b number(3);c number(3);f number(3);s number(3);t number(3);begina :=&a;b :=&b;c :=&c;if a>b and a>c thenf:= a;if b>c thens:=b;t:=c;elses:=c;t:=b;end if;elsif b>a and b>c thenf:= b;if a>c thens:=a;t:=c;elses:=c;t:=a;end if;elsef:= c;if a>b thens:=a;t:=b;elses:=b;t:=a;end if;end if;dbms_output.put_line(first largest =f); 7. http://placementkit.blogspot.com/dbms_output.put_line(second largest = s);dbms_output.put_line(third largest = t);end;/Enter value for a: 5old 9: a:=&a;new 9: a:=5;Enter value for b: 8old 10: b:=&b;new 10: b:=8;Enter value for c: 9old 11: c:=&c;new 11: c:=9;first largest = 9second largest = 8third largest = 5PL/SQL procedure successfully completed.P10 . WRITE A PROGRAM TO INPUT 2 NUMBERS AND AN OPERATOR , ANDDISPLAY THE RESULT.declarea number(3) ;b number(3) ;c number(3) ;op char(1) ;begina := &a ;b := &b ;op := &op ;if op=+thenc:=a+b;elsif op=-thenc:=a-b;elsif op=*thenc:=a*b;elsec:=a/b;end if;dbms_output.put_line(result= c);end;Enter value for a: 5old 7: a:=&a;new 7: a:=5;Enter value for b: 6old 8: b:=&b;new 8: b:=6;Enter value for op: *old 9: op:=&op; 8. http://placementkit.blogspot.com/new 9: op:=*;result=30PL/SQL procedure successfully completed.P11. Write a program to calculate the commission of the sales man.If salesmade Comm>10000 50010000 20000 1000>20000 1500declaresman varchar(10);sm number(9,2);com number(9,2);beginsman := &sman;sm := &sm;if sm > 10000 thencom := 500;elsif sm > 20000 thencom := 1000;elsecom := 1500;end if;dbms_output.put_line( the sales man name is : sman);dbms_output.put_line( the sales made is : sm);dbms_output.put_line( the sales commission is : com);end;Enter value for sman: Mathewold 6: sman:=&sman;new 6: sman:=Mathew;Enter value for sm: 15000old 7: sm:=&sm;new 7: sm:=15000;The sales man name is :MathewThe sales made is :15000The sales commission is :500PL/SQL procedure successfully completed.PROGRAM BASED ON WHILE LOOPP12. TO GENERATE NUMBERS FROM 0 TO 25 IN STEP OF 5declarei number :=10 ;begindbms_output.put_line( THE WHILE LOOP begins);WHILE I Enter value for n: 375old 7: n:=&N;new 7: n:=375;THE SUM OF THE DIGITS = 15PL/SQL procedure successfully completed.PROGRAM BASED ON NESTED WHILE LOOPPROGRAM BASED ON FOR LOOPP14. WRITE A PROGRAM CODE TO PRINT THE MULTIPLICATION TABLE OF A GIVENNO:declaret number(3) := 3;beginT := &T;FOR I IN 1..3 LOOPdbms_output.put_line(t X i = i*t );end loop;end;p15. write aprogram to generate even numbers from 2 to 50, and find its sum.declarei number(5);n number(5);v number(5);s number(5):=0;beginn := &terminal_number;for i in 1 .. n/2 loopv := i*2;s := s+v;dbms_output.put_line(v);end loop;dbms_output.put_line(the sum of numbers from 2 ton=s);end;SQL> / 10. http://placementkit.blogspot.com/Enter value for terminal_number: 10old 7: n:=&terminal_number;new 7: n:=10;246810The sum of numbers from 2 to 10 = 30PL/SQL procedure successfully completed.P16 . WRITE A PROGRAM TO GENERATE FIRST 25 TERMS OF THE FIBONACCISSERIES.declarea number:= 0 ;b number:= 1;c number;begindbms_output.put(a b);for i in 3..10 loopc := a + b;dbms_output.put(c);a := b;b := c;end loop;dbms_output.put_line( );end;0 1 1 2 3 5 8 13 21 34PL/SQL procedure successfully completed.P17. Write a program to find the factorial of a number :declaren number(2);i number(2);f number(5):=1;beginn :=&n;for i in 1..n loopf := f * i;end loop;dbms_output.put_line( the factorial value =f);end;Enter value for n: 5old 6: n:=&n;new 6: n:=5;the factorial value = 120PROGRAM BASED ON NESTED FOR LOOPP18. Write a program to print the following design: 11. http://placementkit.blogspot.com/112123123412345declarei number ;j number;n number;beginn :=&n;for i in 1..n loopfor j in 1..i loopdbms_output.put(j);end loop;dbms_output.put_line( );end loop;end;Enter value for n: 5old 6: n:=&n;new 6: n:=5;P19. WRITE A PROGRAM TO DISPLAY NUMBERS OF THE FORM00000123452 4 6 8 103 6 9 12 154 8 12 16 205 10 15 20 25DECLAREI NUMBER;J NUMBER ;K NUMBER;BEGINFOR I IN 0 .. 5 LOOPFOR J IN 1..5 LOOPK := I*J;DBMS_OUTPUT.PUT(K);END LOOP;DBMS_OUTPUT. PUT_LINE ( );END LOOP;END;P20. WRITE A PL/SQL CODE TO ACCEPT THE TEXT AND REVERSE THE GIVEN TEXT.CHECK THE TEXT IS PALINDROME OR NOTDECLAREG VARchar2(20);r VARchar2(20);BEGING:=&g;dbms_output.put_line(THE GIVEN TEXT : G);for i in REVERSE 1.. length(G) loopR:= R substr(G,i,1); 12. http://placementkit.blogspot.com/end loop;dbms_output.put_line(THE REVERSED TEXT : R);IF R=G THENdbms_output.put_line(THE GIVEN TEXT IS PALINDROME );ELSEdbms_output.put_line(THE GIVEN TEXT IS NOT PALINDROME );END IF;end;SQL> /Enter value for g: MALAYALAMold 5: G:=&g;new 5: G:=MALAYALAM;THE GIVEN TEXT :MALAYALAMTHE REVERSED TEXT :MALAYALAMTHE GIVEN TEXT IS PALINDROMEPL/SQL procedure successfully completed./Enter value for g: HELLOold 5: G:=&g;new 5: G:=HELLO;THE GIVEN TEXT :HELLOTHE REVERSED TEXT :OLLEHTHE GIVEN TEXT IS NOT PALINDROMEPL/SQL procedure successfully completed.P21. Write a program to print the following design:declarei number ;j number;n number;k number;m number;beginn := &n;for i in 1..n loopfor j in 1..n-i loopdbms_output.put(~);end loop;for k in 1..i loopdbms_output.put(k);end loop;for k in reverse 1..i-1 loopdbms_output.put(k);end loop;dbms_output.put_line( );end loop;end;Enter value for n: 5old 8: n:=&n;new 8: n:=5;~~~~1~~~121~~12321 13. http://placementkit.blogspot.com/~1234321123454321PL/SQL procedure successfully completed.P22. Write a program to print the following design :declarei number ;j number;n number;k number;m number;beginn := &n;for i in 1..n loopfor j in 1..n-i loopdbms_output.put(~);end loop;for k in 1..i loopdbms_output.put(k);end loop;for k in reverse 1..i-1 loopdbms_output.put(k);end loop;dbms_output.put_line( );end loop;for i in reverse 1..n-1 loopfor j in 1..n-i loopdbms_output.put(~);end loop;for k in 1..i loopdbms_output.put(k);end loop;for k in reverse 1. . i-1 loopdbms_output.put(k);end loop;dbms_output.put_line( );end loop;end;Enter value for n: 5old 8: n:=&n;new 8: n:=5;~~~~1~~~121~~12321~1234321123454321~1234321~~12321~~~121~~~~1PL/SQL procedure successfully completed.PROGRAM BASED ON FOR & IFP23. GENERATE ODD NOS: FROM 1 TO 10 AND FIND ITS SUM. 14. http://placementkit.blogspot.com/DECLAREI NUMBER(4);S NUMBER(4):=0;BEGINFOR I IN 1..10 LOOPIF MOD(I,2) 0 THENS := S+I;DBMS_OUTPUT.PUT_LINE(I);END IF;END LOOP;DBMS_OUTPUT.PUT_LINE( THE SUM OF ODD NOS FROM 1 TO 10 =S);END;SQL>/13579THE SUM OF ODD NOS FROM 1 TO 10 = 25PL/SQL procedure successfully completed.P24 . WRITE A PROGRAM TO ALL ODD NUMBERS FORM 10 TO 1 IN REVERSEORDER.declarei number(5);n number(5);v number(5);s number(5) :=0;beginS := &STARTING_NUMBER;n := &terminal_number;for i in REVERSE S .. N loopIF MOD (I,2) 0 THENs := s + I;dbms_output.put_line(I);end loop;dbms_output.put_line(the sum of numbers from 2 ton=s);end;Enter value for starting number : 1Old 6: s=&starting_number:1New 6: s:=1;Enter value for Terminal_number: 10old 7: n := &terminal_number;new 7: n:=10;97531The sum of numbers from 1 to 9 = 25PL / SQL procedure successfully completed.P25. Write a program to check the given no: is prime or not: 15. http://placementkit.blogspot.com/declaren number;i number;pr number(2):=1;beginn:= &n;for i in 2..n/2 loopif mod(n,i) = 0 thenpr := 0;end if;end loop;if pr = 1 thendbms_output.put_line( the given no: is prime:n);elsedbms_output.put_line( the given no: is not prime:n);end if;end;Enter value for n: 7old 6: n:=&n;new 6: n:=7;the given no: is prime: 7PL/SQL procedure successfully completed.SQL> /Enter value for n: 25old 6: n:=&n;new 6: n:=25;the given no: is not prime: 25PL/SQL procedure successfully completed.P26. WRITE A PROGRAM TO PRINT ASCII TABLE :DECLAREI NUMBER;BEGINFOR I IN 33..256 LOOPDBMS_OUTPUT.PUT (( TO_CHAR (I,000)) : CHR(I) );IF MOD (I, 8) = 0 THENDBMS_OUTPUT.PUT_LINE( );END IF;END LOOP;END;033:! 034:" 035:# 036:$ 037:% 038:& 039: 040:(041:) 042:* 043:+ 044:, 045:- 046:. 047:/ 048:0049:1 050:2 051:3 052:4 053:5 054:6 055:7 056:8249: 250: 251: 252: 253: 254: 255: 256::: :: :: :: :: :::: :: :: :: :: ::PL/SQL procedure successfully completed.P27. Write a program to generate prime nos from 1 to 10: 16. http://placementkit.blogspot.com/declaren number;i number;pr number;beginfor n in 1..10 looppr:=1;for i in 2 .. n/2 loopif mod(n,i) = 0 thenpr := 0;end if;end loop;if pr = 1 thendbms_output.put_line(n);end if;end loop;end;12357P28 . Write a program to check the square root of a number is prime or not.declaren number;i number;pr number;beginpr := 1;n := &n;n := sqrt(n);for i in 2 .. n/2 loopif mod(n,i) = 0 thenpr := 0;end if;end loop;if pr = 1 thendbms_output.put_line(the square root of the given number is prime n*n);elsedbms_output.put_line(the square root of the given number is not prime n*n);end if;end;SQL> Enter value for n: 81old 7: n:=&n;new 7: n:=81;The square root of the given number is not prime81PL/SQL procedure successfully completed.PROGRAM BASED ON LOOP... END LOOPP29. Write a program to reverse the digits of the number: 17. http://placementkit.blogspot.com/DECLAREN number ;S NUMBER : = 0;R NUMBER;K number;beginN := &N;K := N;LOOPEXIT WHEN N = 0 ;S := S * 10;R := MOD(N,10);S := S + R;N := TRUNC(N/10);end loop;dbms_output.put_line(THE REVERSED DIGITS OF K = S);end;Enter value for n: 4567old 7: N:=&N;new 7: N:=4567;THE REVERSED DIGITS OF 4567 = 7654PL/SQL procedure successfully completed.PROGRAM BASED ON RECORDSP30. WRITE PL/SQL SCRIPT TO CREATE A RECORD TYPE THAT CAN HOLD SALES IN4 DIFFERENT QUARTERS.Structure of the table :SALES ( SNO, NAME, QUAD1, QUAD2, QUAD3, QUAD4 )SALES2004 ( Q1, Q2, Q3, Q4 )DECLARETYPE SALEREC IS RECORD( Q1 NUMBER,Q2 NUMBER,Q3 NUMBER,Q4 NUMBER,);BEGINSREC SALEREC ;SELECT SUM(QUAD1) , SUM(QUAD2) , SUM(QUAD3), SUM(QUAD4) INTO SREC FROMSALES;INSERT INTO SALES2004 VALUES (SREC.Q1 ,SREC.Q2, SREC.Q3, SREC.Q4);END;PROGRAM BASED ON DATABASE INTERACTIONP31 . Write PL/SQL SCRIPT to determine the salary of employee in the EMP table. If salary >7500 give an increment of 15% , otherwise display the message NOINCREMENT . Get the empno from the user.DECLAREENO EMP.EMPNO%TYPE;SALARY EMP.SAL%TYPE;BEGINENO := &ENO; 18. http://placementkit.blogspot.com/SELECT SAL INTO SALARY FROM EMP WHERE EMPNO=ENO;IF SALARY >7500 THENUPDATE EMP SET SAL =SAL+SAL* 15/100 WHERE EMPNO=ENO;ELSEDBMS_OUTPUT.PUT_LINE(NO INCREMENT)END IF;END;P32 . GIVEN A TABLE STUDENT ( SID INTEGER PRIMARY KEY, NAME CHAR(30),AGE INTEGER , GPA FLOAT ). WRITE A PL/SQL SCRIPT TO GO THROUGH SID 142-857 AND SET ALL GPA UNDER 4.0 TO 4.0 .DECLARETSID STUDENT.SID%TYPE;TGPA STUDENT.GPA%TYPE;BEGINTSID:=142;LOOPEXIT WHEN TSID > 857 ;SELECT GPA INTO TGPA FROM STUDENT WHERE SID=TSID;IF TGPA< 4.0 THENUPDATE STUDENT SET GPA=4.0 WHERE SID=TSID;END IF;TSID:=TSID+1;END LOOP;END;P33 . DISPLAY AVERAGE SALARY , TOTOL NO: OF EMP, AND TOTAL SALARY FORFIRST 5 DEPARTMENTS IN EMP TABLE. DEPT NO ARE 10,20,30,40,5090.DECLAREDNO NUMBER:=10;DPNAME DEPT. DNAME%TYPE;ASAL EMP. SAL%TYPE;ACOUNT NUMBER;SSAL EMP. SAL%TYPE;BEGINLOOPEXIT WHEN DNO > 50;SELECT DNAME INTO DPNAME FROM DEPT WHERE DEPTNO=DNO;SELECT AVG(SAL), COUNT(*), SUM(SAL) INTO ASAL, ACOUNT,SSALFROM EMP WHERE DEPTNO = DNO;DBMS_OUTPUT.PUT_LINE( DEPARTMENT NAMEDPNAME);DBMS_OUTPUT.PUT_LINE( DEPARTMENT COUNTACOUNT);DBMS_OUTPUT.PUT_LINE( AVERAGE SALARYASAL);DBMS_OUTPUT.PUT_LINE( SUM SALARYSSAL);DNO := DNO+10;END LOOP;END; 19. http://placementkit.blogspot.com/P34. WRITE A PL/SQL SCRIPT TO COUNT THE NO: OF EMPLOYEES. IF TOTAL 4000 AND EMPNO=ENO;END;P40 .Write PL/SQL code to insert a new record in the table emp after obtainingvalues ( empno, ename, hiredate, sal ) from user.declaretempno number(4);tename varchar(10);thiredate varchar2(12);tsal number(7,2);begintempno :=&tempno;tename :=&tename;thiredate :=&thiredate;tsal := &tsal;insert into emp (empno,ename,hiredate,sal) values(tempno,tename,to_date(thir 21. http://placementkit.blogspot.com/edate,DD-mon-yyyy),tsal);end;Enter value for tempno: 8000old 7: tempno:=&tempno;new 7: tempno:=8000;Enter value for tename: mathewold 8: tename :=&tename;new 8: tename :=mathew;Enter value for thiredate: 10-jan-2004old 9: thiredate :=&thiredate;new 9: thiredate :=10-jan-2004;Enter value for tsal: 8000old 10: tsal := &tsal;new 10: tsal := 8000;PL/SQL procedure successfully completed.P41. WRITE A PROGRAM TO CREATE A EMP %ROWTYPE RECORD .ACCEPT THEEMPNO FROMTHE USER, AND DISPLAY ALL THE INFORMATION ABOUT THE EMPLOYEE.declareerec emp%rowtype;eno emp.empno%type;begineno := &eno;select * into erec from emp where empno=eno;dbms_output.put_line( Emp no :erec.empno) ;dbms_output.put_line( Name :erec.ename) ;dbms_output.put_line( Salary :erec.sal);dbms_output.put_line( Deptno :erec.deptno);dbms_output.put_line( hiredate:erec.hiredate);dbms_output.put_line( job :erec.job);end;SQL> /Enter value for eno: 7788old 5: eno := &eno;new 5: eno := 7788;Emp no : 7788Name : SCOTTSalary : 1452Deptno : 20hiredate: 19-APR-87job : ANALYSTPL/SQL procedure successfully completed.PROGRAM BASED ON EXCEPTIONP42. Write PL/SQL script that traps an invalid data type value given and displays acustom error message.DECLAREENO EMP. EMPNO%TYPE;SNO VARCHAR2(5);NAME EMP.ENMAE%TYPE;BEGINSNO := &SNO ; 22. http://placementkit.blogspot.com/SELECT EMPNO,ENAME INTO ENO,NAME FROM EMP WHERE EMPNO=SNO;DBMS_OUTPUT.PUT_LINE ( NAME ENAMEEMPNOEMPNO);EXCEPTIONWHEN INVALID_NUMBER THENDBMS_OUTPUT.PUT_LINE(SNOIS INVALID DATA FOR EMPLOYEE ID);END;PROGRAM BASED ON FUNCTIONSP43 . write a function to create factorial of a number.CREATE OR REPLACE FUNCTION FACT (N NUMBER)RETURN NUMBERISI NUMBER(10);F NUMBER :=1;BEGINFOR I IN 1.. N LOOPF:= F*I;END LOOP;RETURN F;END;SQL> /Function created.SQL> select fact(8) from dual;FACT(8)---------40320PROGRAM BASED ON PROCEDURESP44. Write a Procedure to increase the salary for all the employees in the EMPtable :SQL> select * from emp;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO--------- ---------- --------- --------- --------- --------- --------- ---------7369 SMITH CLERK 7902 17-DEC-80 800 207499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 3014 rows selected.SQL> create or replace procedure inc(i number)isbeginupdate emp set sal =sal+i;end;/Procedure created.To execute the procedures in the PL/SQL block:SQL> declarebegininc(100);end;/PL/SQL procedure successfully completed.SQL> select * from emp;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 23. http://placementkit.blogspot.com/7369 SMITH CLERK 7902 17-DEC-80 800 207499 ALLEN SALESMAN 7698 20-FEB-81 1700 300 3014 rows selected.P45. WRITE A PROCEDURE TO INCREASE THE SALARY FOR THE SPECIFIEDEMPLOLEE USING EMPNO IN THE EMP TABLE BASED ON THE FOLLOWINGCRITERIA: INCREASE THE SALARY BY 5% FOR CLERKS, 7% FOR SALESMAN , 10%FOR ANALYST, 20 % FOR MANAGER and 25% FOR PRESIDENT. ACTIVATE USINGPL/SQL BLOCK.SQL> SELECT * FROM EMP;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPT7369 SMITH CLERK 7902 17-DEC-80 800 20CREATE OR REPLACE PROCEDURE DESIGNATION(ENO NUMBER)ISBEGINUPDATE EMP SET SAL=SAL+SAL*5/100 WHERE JOB =CLERK AND EMPNO=ENO;UPDATE EMP SET SAL=SAL+SAL*7/100 WHERE JOB=SALESMAN AND EMPNO=ENO;UPDATE EMP SET SAL=SAL+SAL*10/100 WHERE JOB=ANALYST AND EMPNO=ENO;UPDATE EMP SET SAL=SAL+SAL*20/100 WHERE JOB=MANAGER AND EMPNO=ENO;UPDATE EMP SET SAL=SAL+SAL*25/100 WHERE JOB=PRESIDENT AND EMPNO=ENO;END;SQL> /Procedure created.SQL> DECLARE2 BEGIN3 DESIGNATION(7369);4 END;5/PL/SQL procedure successfully completed.SQL> SELECT * FROM EMP;EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPT7369 SMITH CLERK 7902 17-DEC-80 840 20__