1.We want to execute one of three statements depending on whether the value in V_VAR is 10, 20, or some other value.
What should be coded at Line A?
IF v_var = 10 THEN
statement1;
-- Line A
statement2;
ELSE
statement3;
END IF;


*ELSIF v_var = 20 THEN

2.Name three types of control structures in PL/SQL. (Choose three)
* IF statements
LOOP statements
*CASE statements

3. A basic loop is a type of control structure used to change the logical flow of statements in a PL/SQL block. True or False?
*true

4.

You want to repeat a set of statements 100 times, incrementing a counter each time. What kind of PL/SQL control structure would you use?

*A loop

5.What is wrong with the following trivial IF statement:
IF (v_job='President')
THEN v_salary := 10000;
* END IF; is missing

6.
Look at the following (badly written) code:
age := 5; IF age<30 THEN mature := 'adult';
ELSIF age<22 THEN mature := 'teenager';
ELSIF age<13 THEN mature := 'child';
END IF;
DBMS_OUTPUT.PUT_LINE(mature);
What will be displayed when this code is executed?
* adult

7.
What will be displayed when this block is executed?
DECLARE
v_bool1 BOOLEAN := TRUE;
v_bool2 BOOLEAN;
v_char VARCHAR(4) := 'up';
BEGIN
IF (v_bool1 AND v_bool2) THEN
v_char:='down';
ELSE v_char:='left';
END IF;
DBMS_OUTPUT.PUT_LINE(v_char);
END; 

*left



8.What will be displayed when this block is executed? DECLARE
   v_birthdate DATE;
BEGIN
   IF v_birthdate < '01-JAN-2000'
   THEN
     DBMS_OUTPUT.PUT_LINE(' Born in the 20th century ');
   ELSE
     DBMS_OUTPUT.PUT_LINE(' Born in the 21st century ');
   END IF;
END; 

* Born in the 21st century


9.What will be displayed when this block is executed?
DECLARE
v_bool1 BOOLEAN := NULL;
v_bool2 BOOLEAN := NULL;
v_char VARCHAR(10) := 'Start';
BEGIN
IF (v_bool1 = v_bool2) THEN
v_char:='Equal';
ELSE v_char:='Not equal';
END IF;
DBMS_OUTPUT.PUT_LINE(v_char);
END; 

 *Not equal

10) Which one of the following is correct syntax for an IF statement?
* IF condition THEN statement1; statement2; END IF;

11)
Which of the following statements are true about any of the PL/SQL conditional control structures such as IF ... , CASE... , and loops?

*all of the above
 
 


Comments