+ All Categories
Home > Technology > PL SQL Quiz | PL SQL Examples

PL SQL Quiz | PL SQL Examples

Date post: 06-Apr-2017
Category:
Upload: shubham-dwivedi
View: 622 times
Download: 8 times
Share this document with a friend
23
PLSQL QUIZ SUBMITTED BY: Shubham Dwivedi
Transcript
Page 1: PL SQL Quiz |  PL SQL Examples

PLSQLQUIZ

SUBMITTED BY:Shubham

Dwivedi

Page 2: PL SQL Quiz |  PL SQL Examples

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.

Page 3: PL SQL Quiz |  PL SQL Examples

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.

Page 4: PL SQL Quiz |  PL SQL Examples

Which of the following is NOT VALID in PL/SQL ?a] Select ... Intob] Updatec] Created] Delete

  

Page 5: PL SQL Quiz |  PL SQL Examples

What is the Result of the following 'VIK'||NULL||'RAM' ?a] Errorb] VIK RAMc] VIKRAMd] NULL

Page 6: PL SQL Quiz |  PL SQL Examples

 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

  

Page 7: PL SQL Quiz |  PL SQL Examples

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

Page 8: PL SQL Quiz |  PL SQL Examples

- 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.

Page 9: PL SQL Quiz |  PL SQL Examples

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

Page 10: PL SQL Quiz |  PL SQL Examples

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

Page 11: PL SQL Quiz |  PL SQL Examples

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

Page 12: PL SQL Quiz |  PL SQL Examples

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

Page 13: PL SQL Quiz |  PL SQL Examples

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.

Page 14: PL SQL Quiz |  PL SQL Examples

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.

Page 15: PL SQL Quiz |  PL SQL Examples

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.

Page 16: PL SQL Quiz |  PL SQL Examples

 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

Page 17: PL SQL Quiz |  PL SQL Examples

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;

Page 18: PL SQL Quiz |  PL SQL Examples

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

Page 19: PL SQL Quiz |  PL SQL Examples

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.

Page 20: PL SQL Quiz |  PL SQL Examples

Select invalid variable types

A. CHARB. VARCHAR1C. VARCHAR2D. INTEGERE. NUMBER

Page 21: PL SQL Quiz |  PL SQL Examples

he || is is an example of what functionSELECT last_name || ', ' || first_name || ' ' || middle_nameFROM employees;

A. IncantinationB. IntegrationC. ContinuationD. ConcatenationE. None of the above

 

Page 22: PL SQL Quiz |  PL SQL Examples

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.

Page 23: PL SQL Quiz |  PL SQL Examples

Recommended