Search Header Logo
PLSQL - ADVANCED KNOWLEDGE

PLSQL - ADVANCED KNOWLEDGE

Assessment

Presentation

Computers

University

Medium

Created by

Prof. Tarik

Used 3+ times

FREE Resource

10 Slides • 16 Questions

1

PLSQL - ADVANCED KNOWLEDGE

2

Multiple Choice

What is a stored procedure?

1

A collection of precompiled SQL statements saved in the database

2

A collection of precompiled Oracle statements saved in the database

3

A collection of precompiled Microsoft statements saved in the database

4

A collection of precompiled PLSQL statements saved in the database

3

Multiple Choice

What is the purpose of the 'FOR UPDATE' clause in a cursor in PL/SQL?

1

To specify the condition for cursor execution

2

To indicate that the cursor should be executed for each row affected by the triggering event

3

To lock the rows in the result set so that they cannot be modified by other transactions

4

To specify the timing of the cursor execution

4

Multiple Choice

Begin and End are mandatory in PLSQL code?

1

yes

2

no

3

may be

4

not at all

5

Multiple Choice

Name 4 attributes of explicit cursors?

1

%FOUND,%NOTFOUND,%ROWCOUNT,%ISOPEN

2

%FOUND,%NOTFOUND,%ISCLOSE,%ISOPEN

3

%FOUND,%OPEN,%ROWCOUNT,%ISOPEN

4

None of these

6

Multiple Choice

What is the advantage of using stored procedures?

1

Difficult to debug

2

Not reusable

3

Reduce traffic between application and database server

4

Increase memory usage of connections

7

Multiple Choice

The pre-defined exception TOO_MANY_ROWS is raised when

1

PL/SQL ran out of memory or memory was corrupted.

2

A cursor fetches value in a variable having incompatible data type.

3

SELECT INTO statement returns more than one row.

4

SELECT INTO statement returns one row.

8

Multiple Choice

Which of the following is not among the types of PL/SQL records?

1

Table-based

2

View-based

3

Cursor-based records

4

User-defined records

9

Multiple Choice

Which of the following is not a subprogram?

1

Procedure

2

Function

3

Package

4

Anonymous PL/SQL block

10

Multiple Choice

A set of statements in PLSQL are called as

1

function

2

program

3

procedure

4

Block

11

Multiple Choice

how to print a string "welcome to plsql" in PLSQL code?

1

dbms_output.put_line('welcome to plsql')

2

print('welcome to plsql')

3

show('welcome to plsql')

4

System.out.println("welcome to plsql")

12

Multiple Choice

What is the main purpose of using a trigger in a database?

1

To perform a specific action when a certain event occurs in the database

2

To create a new table in the database

3

To modify the database schema

4

To execute a stored procedure

5

None of the given answers

13

CASE Statements

CASE statement gives you a clear way to handle conditional logic within PL/SQL blocks. It is a conditional control statement that allows you to execute different blocks of code based on the specified conditions.
It is particularly useful when dealing with multiple conditions and provides a more readable and maintainable alternative to nested IF-ELSE statements.
There are two primary types of CASE statements in PL/SQL:
Simple CASE and Searched CASE.

14

Simple CASE Statements

In a Simple CASE statement, the value of an expression is compared to constant values (predefined).
It is useful when you want to match a single expression with different constant values.
CASE statement is feature that is used to handle conditional logic within PL/SQL blocks. CASE statement provides more clear and readable alternative to nested IF-ELSE statements. By efficiently managing branching logic, the CASE statement enhances code clarity and maintainability in PL/SQL programming.

15

Simple CASE Statements

media

The variable day_number is set to 1 that representing Monday.

  • The Simple CASE statement then checks the value of day_number and assigns the corresponding day name to the variable day_name.

  • The output will be The day is: Monday

16

Searched CASE Statements

In a Searched CASE statement each condition is evaluated independently.
It allows for more complex conditions such as comparisons, logical operators, and functions.

17

Searched CASE Statements

media
  • The variable product_price is set to 120.50.

  • The Searched CASE statement evaluates different conditions based on the value of product_price and assigns the appropriate category to the variable product_category.

  • The output will be The product falls into the category: High Cost.

18

Fill in the Blanks

19

Multiple Choice

Consider the following code snippet: what will be the output?

DECLARE

a number(2) ;

BEGIN

FOR a IN REVERSE 10 .. 20 LOOP

END LOOP;

dbms_output.put_line(a);

END;

1

20

2

29

3

10

4

30

20

Multiple Choice

In which statement each condition is evaluated independently?

1

Searched

2

Case

3

Simple

4

Statements don't evaluated condition indepedently

21

media

22

PL/SQL NULL Statement


Within this language, the Null statement plays a crucial role in enhancing code readability and functionality.
The Null statement in PL/SQL is a construct or feature that represents a no-operation or empty statement. It is used when a statement is syntactically necessary but no action needs to be performed on that statement. Essentially, it signifies the placeholder where no code execution occurs.

The NULL statement works like a stand-in within PL/SQL code. It’s needed by the syntax but doesn’t do any particular job. It shows that no specific code has to run at that moment. This helps keep the code in good shape when a statement is a must but the statement does not need to take actual action.

It doesn’t do any task at all, it is just a placeholder signifying that nothing particular needs to be done. It’s like saying, “No code required here!”

23

PL/SQL NULL Statement

Creating Placeholders for Subprograms

Another significant application of the Null statement is creating placeholders within subprograms.
For instance, when defining a procedure or function body, placeholders might be needed:









In this case, the Null statement serves as a placeholder for potential future modifications or additions to the subprogram’s logic, allowing developers to structure code architecture more effectively.

media

24

PL/SQL NULL Statement

Using PL/SQL NULL Statement to Provide a Target for a GOTO

The Null statement can also act as a target for a GOTO statement, aiding in controlling program flow:












By utilizing the Null statement as a target for GOTO in the above code can navigate program execution to a designated placeholder within the code very easily.

media

25

Multiple Choice

Does CASE expression supports Searched CASE?

1

Yes

2

No

3

No given information

26

Fill in the Blanks

PLSQL - ADVANCED KNOWLEDGE

Show answer

Auto Play

Slide 1 / 26

SLIDE