PL SQL Quiz | PL SQL Examples
-
Upload
shubham-dwivedi -
Category
Technology
-
view
630 -
download
8
Transcript of PL SQL Quiz | PL SQL Examples
PLSQLQUIZ
SUBMITTED BY:Shubham
Dwivedi
Q 3 - Which of the following is true about the following code snippet?
DECLARE a number(3) := 100;
BEGIN IF (a = 50 ) THEN dbms_output.put_line('Value of a is 10' ); ELSEIF ( a = 75 ) THEN dbms_output.put_line('Value of a is 20' );ELSE dbms_output.put_line('None of the values is matching');
END IF; dbms_output.put_line('Exact value of a is: '|| a ); END;
A - It has syntax error.B - It will print 'None of the values is matching'.C - It will print None of the values is matching Exact value of a is: 100D - None of the above.
A Stored Procedure is aa. Sequence of SQL or PL/SQL
statements to perform specific function.b. b. Stored in compiled form in the
database.c. c. Can be called from all client
environments.d. d. All of the above.
Which of the following is NOT VALID in PL/SQL ?a] Select ... Intob] Updatec] Created] Delete
What is the Result of the following 'VIK'||NULL||'RAM' ?a] Errorb] VIK RAMc] VIKRAMd] NULL
Declarea number := 5; b number := null; c number := 10;
Beginif a > b AND a < c thena := c * a;end if;
End;What will be the value of 'a' after execution ?a] 50b] NULLc] 5d] None of the above
Consider the following code snippet: how many times the loop will run?
DECLARE a number(2) := 9; BEGIN WHILE a < 30
LOOP a := a + 3; END LOOP; END;A - 10B - 8C - 7D - 9
- Which of the following is true about comments in PL/SQL?
A - Comments are explanatory statements.B - PL/SQL supports both single-line and
multi-line comments.C - The PL/SQL single-line comments start
with the delimiter -- (double hyphen) and multi-line comments are enclosed by /* and */.
D - All of the above.
DECLARE a number;
PROCEDURE squareNum(x IN OUT number)
IS BEGIN
x := x * x; END; BEGIN
a:= 5; squareNum(a); dbms_output.put_line(a);
END;
A - 5B - 10C - 25D - 0
What will be the output of the following code snippet?
DECLARE a number(3) := 100; b number(3) := 200;
BEGIN IF( a = 100 ) THEN IF( b <> 200 ) THEN
dbms_output.put_line(b); END IF; END IF;
dbms_output.put_line(a);END;
A - It has syntax error, so there will not be any output.B - 200C - 200 100D - 100
What will happen when the code is executed?
DECLARE num number := 95; BEGIN dbms_output.put_line('num: ' || num1);
DECLARE num number := 195;
BEGIN dbms_output.put_line('num: ' || num1);
END; END;
A - It won’t execute, it has syntax errorB - It will print num: 95 num: 195C - It will print num: 95 num: 95D - It will print num: 195 num: 195
Consider the following code snippet: how many times the loop will run?
DECLARE a number(2) := 9; BEGIN WHILE a < 30 LOOP a := a + 3; END LOOP; END;
A - 10B - 8C - 7D - 9
CREATE OR REPLACE FUNCTION totalCustomers total number(2) := 0;
BEGIN SELECT count(*) into total FROM customers; RETURN total;
END;
A - It doesn’t have the RETURN clause in function declaration.
B - The RETURN statement is wrong.C - Function definition should not use the IS keywordD - Nothing wrong.
Which of the following is true about the execution section of a PL/SQL block? A - It is enclosed between the keywords
BEGIN and END. B - It is a mandatory section. C - It consists of the executable PL/SQL
statements. D - All of the above.
What is the output of the following code?DECLARE x number := 4; BEGIN LOOP dbms_output.put_line(x); x := x + 1; exit WHEN x > 5; END LOOP; dbms_output.put_line(x); END;
A - 4 5 6B - 4 5C - 4D - None of the above.
DECLARE
num number; fn number;
FUNCTION fx(x number) RETURN number IS f number;
BEGIN IF x=0 THEN f := 1; ELSE f := x * fx(x-1);
END IF; RETURN f;
END;
BEGIN num:= 5; Fn := fx(num);
dbms_output.put_line(fn); END;
A - 1B - 5C - 10D - 125
Which of the following is the correct syntax for creating an explicit cursor?
A - CURSOR cursor_name IS
select_statement; B - CREATE CURSOR cursor_name IS
select_statement; C - CREATE CURSOR cursor_name AS
select_statement; D - CURSOR cursor_name AS
select_statement;
What would be printed when the following code is executed?
DECLARE x NUMBER; BEGIN
x := 5; x := 10; dbms_output.put_line(-x); dbms_output.put_line(+x); x := -10;dbms_output.put_line(-x); dbms_output.put_line(+x);
END;
A -10 10 10 -10B 10 -10 10-10C -10 +10 +10 -10D - 10 -10 -10 10
Which of the following statements is true about implicit cursors?
A.Implicit cursors are used for SQL statements that are not named.
B. Developers should use implicit cursors with great care.
C. Implicit cursors are used in cursor for loops to handle data processing.
D. Implicit cursors are no longer a feature in Oracle.
Select invalid variable types
A. CHARB. VARCHAR1C. VARCHAR2D. INTEGERE. NUMBER
he || is is an example of what functionSELECT last_name || ', ' || first_name || ' ' || middle_nameFROM employees;
A. IncantinationB. IntegrationC. ContinuationD. ConcatenationE. None of the above
Select the best answer. Which listed attribute is an invalid attribute of an Explicit cursor.
A. %NOTFOUNDB. %FOUNDC. %ROWCOUNTD. %ISOPENE. None of the above. All of these are valid.