You are on page 1of 3

NAME : ALOK KUMAR JHA

ASSIGNMENT: 3

Q1) Write a PLSQL program to print the given below string in the reverse order ,without using REVERSE
keyword.

I/P: ‘ABCDE’

O/P : ‘EDCBA’

Ans- Declare

string varchar2(20);

str1 varchar2(20);

len number;

Begin

string:='&strring';

len:= length(string);

for i in reverse 1..len

loop

str1:=str1||substr(string,i,1);

end loop;

DBMS_OUTPUT.PUT_LINE(str1);

End;

Q2) Write a PLSQL program to print the Even record only in the series of number staring from

1 to 100.
Ans-

DECLARE

N NUMBER;

BEGIN

N:=0;

LOOP

N:=N+2;

DBMS_OUTPUT.PUT_LINE('EVEN NO ARE : ' || N);

EXIT WHEN N=100;

END LOOP;

END;

Q3) What are the significance of NESTED Blocks in PLSQL Program?

Ans- In PL/SQL, each block can be nested into another block. They are referred as a nested block.
Nested blocks are very common when we want to perform the certain process, and at the same time,
the code for these process should be kept in a separate container (block).

Q4) How many types of LOOP we have in PLSQL. What are the mandatory things to be take care during
the use of LOOP (simple )in a PLSQL program.?

Ans- PL/SQL provides four kinds of loop statements. These are-

(i) Simple loop, 


(ii) WHILE loop, 
(iii) FOR loop, and

While using it, following two things must be considered:

 Simple loop always begins with the keyword LOOP and ends with a keyword END LOOP.

 A basic/simple loop can be terminated at any given point by using the exit statement or by


specifying certain condition by using the statement exit when.
Q5) CREATE below table ( table have single column mentioned below)

Table name : Employee_Record


Column name : EMPID
Data type : Number
Precision : 6

Scenario : Insert hundred Unique and NOT NULL record in above created table with the help of PLSQL
program.

Ans- Creating Employee_Record table-

CREATE TABLE Employee_Record1

Empid number(6) PRIMARY KEY

);

Inserting unique and not null records in the column empid using plsql-

BEGIN

FOR i IN 1..100

LOOP

BEGIN

INSERT INTO Employee_Record1 (empid) VALUES(i);

END;

DBMS_OUTPUT.PUT_LINE(i);

END LOOP;

END;

You might also like