Professional Documents
Culture Documents
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);
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;
END LOOP;
END;
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.?
Simple loop always begins with the keyword LOOP and ends with a keyword END LOOP.
Scenario : Insert hundred Unique and NOT NULL record in above created table with the help of PLSQL
program.
);
Inserting unique and not null records in the column empid using plsql-
BEGIN
FOR i IN 1..100
LOOP
BEGIN
END;
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;