Unit 5: Pl-SQL - Practice Quiz

CAP570 — Advanced Database Techniques 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does PL/SQL stand for?

Overview of PL/SQL Easy
A. Procedural Language/SQL
B. Programming Language/SQL
C. Portable Language/SQL
D. Processed Language/SQL

2 Which organization developed PL/SQL?

Overview of PL/SQL Easy
A. Microsoft
B. Oracle Corporation
C. PostgreSQL Global Group
D. IBM

3 PL/SQL is primarily associated with which database system?

Overview of PL/SQL Easy
A. Oracle Database
B. Apache Cassandra
C. MongoDB
D. Microsoft Access

4 Which programming style does PL/SQL add to SQL?

Overview of PL/SQL Easy
A. Procedural programming
B. Markup programming
C. Assembly programming
D. Visual programming

5 Which task can be performed using PL/SQL?

Overview of PL/SQL Easy
A. Creating operating systems
B. Editing digital images
C. Writing database procedures
D. Designing hardware circuits

6 Which statement correctly describes SQL?

Differences between SQL and PL/SQL Easy
A. SQL is mainly procedural
B. SQL is mainly object code
C. SQL is mainly declarative
D. SQL is mainly graphical

7 Which capability is directly supported by PL/SQL but not by basic SQL alone?

Differences between SQL and PL/SQL Easy
A. Updating records
B. Selecting rows
C. Using loops
D. Creating tables

8 How are SQL statements commonly executed inside PL/SQL?

Differences between SQL and PL/SQL Easy
A. As operating systems
B. As image files
C. As network drivers
D. As part of a block

9 Which language supports variables and conditional statements?

Differences between SQL and PL/SQL Easy
A. PL/SQL
B. Basic SQL only
C. XML
D. HTML

10 Which statement best compares SQL and PL/SQL?

Differences between SQL and PL/SQL Easy
A. SQL handles data, while PL/SQL adds procedural logic
B. SQL replaces databases, while PL/SQL replaces servers
C. SQL handles images, while PL/SQL handles sound
D. SQL creates hardware, while PL/SQL creates networks

11 Which PL/SQL feature is used to respond to runtime errors?

Benefits and Features of PL/SQL Easy
A. Exception handling
B. File compression
C. Index sorting
D. Table formatting

12 Which PL/SQL feature repeats a set of statements?

Benefits and Features of PL/SQL Easy
A. Loop
B. Cursor
C. Exception
D. Constant

13 How can PL/SQL help reduce communication between an application and a database?

Benefits and Features of PL/SQL Easy
A. By sending a block of statements
B. By disabling all user sessions
C. By removing every database table
D. By converting records into images

14 Which feature helps organize reusable PL/SQL code?

Benefits and Features of PL/SQL Easy
A. Rows and columns
B. Procedures and functions
C. Forms and reports
D. Keys and indexes

15 Which is a benefit of storing PL/SQL program units in the database?

Benefits and Features of PL/SQL Easy
A. Tables become unnecessary
B. Backups become impossible
C. Code can be reused
D. Passwords become visible

16 Which section of a PL/SQL block is mandatory?

Basic Structure of a PL/SQL Block Easy
A. Executable section
B. Comment section
C. Declaration section
D. Exception section

17 Which keyword starts the executable section of a PL/SQL block?

Basic Structure of a PL/SQL Block Easy
A. BEGIN
B. EXCEPTION
C. DECLARE
D. CREATE

18 In which section are PL/SQL variables normally defined?

Basic Structure of a PL/SQL Block Easy
A. Declaration section
B. Termination section
C. Executable section
D. Exception section

19 Which keyword introduces error-handling code in a PL/SQL block?

Basic Structure of a PL/SQL Block Easy
A. BEGIN
B. DECLARE
C. EXCEPTION
D. RETURN

20 Which keyword marks the conclusion of a PL/SQL block?

Basic Structure of a PL/SQL Block Easy
A. CLOSE
B. END
C. STOP
D. FINISH

21 An application must increase employee salaries, apply different rules based on department, and record failures. Why is PL/SQL more suitable than a single SQL statement?

Overview of PL/SQL Medium
A. It supports procedural control and exception handling
B. It eliminates the need for SQL statements
C. It automatically redesigns the employee table
D. It converts relational data into object files

22 A developer wants to create a named PL/SQL program that performs an action and can accept parameters without returning a value directly. Which program unit is most appropriate?

Overview of PL/SQL Medium
A. Stored procedure
B. SQL expression
C. Anonymous block
D. Database view

23 When a PL/SQL block contains both an IF statement and an UPDATE statement, how are they generally processed by Oracle?

Overview of PL/SQL Medium
A. The IF is processed by SQL and UPDATE by PL/SQL
B. The IF is processed by PL/SQL and UPDATE by SQL
C. Both are processed only by the SQL engine
D. Both are processed only by the PL/SQL engine

24 A block is written and executed directly in a development tool without being saved as a database object. What type of PL/SQL unit is it?

Overview of PL/SQL Medium
A. Database trigger
B. Anonymous block
C. Stored function
D. Package body

25 A PL/SQL variable must store values from the employees.salary column while remaining compatible if the column's datatype later changes. Which declaration is most appropriate?

Overview of PL/SQL Medium
A. v_salary employees%ROWTYPE;
B. v_salary NUMBER(8,2);
C. v_salary VARCHAR2(100);
D. v_salary employees.salary%TYPE;

26 Which task specifically requires PL/SQL rather than standalone SQL?

Differences between SQL and PL/SQL Medium
A. Deleting rows that meet one condition
B. Repeating an update until a limit is reached
C. Joining employee and department tables
D. Selecting employees from one department

27 Which comparison between SQL and PL/SQL is accurate?

Differences between SQL and PL/SQL Medium
A. SQL requires blocks, whereas PL/SQL uses isolated statements only
B. SQL is procedural, whereas PL/SQL is purely declarative
C. SQL describes data operations, whereas PL/SQL can sequence them
D. SQL handles exceptions, whereas PL/SQL cannot detect them

28 A standalone query returns several rows. The same query is used as SELECT ... INTO v_name in PL/SQL, where v_name is scalar. What is the likely result?

Differences between SQL and PL/SQL Medium
A. A runtime exception is raised
B. The variable becomes a collection
C. All rows are joined into one value
D. Only the first row is assigned

29 Why can a PL/SQL block send several SQL operations to the database more efficiently than an application issuing each operation separately?

Differences between SQL and PL/SQL Medium
A. PL/SQL groups operations into one submitted block
B. PL/SQL converts each operation into a trigger
C. PL/SQL removes all transaction logging
D. PL/SQL stores every table entirely in memory

30 A requirement says: retrieve a balance, test whether it is below zero, and insert an alert only when needed. Which distinction makes PL/SQL appropriate?

Differences between SQL and PL/SQL Medium
A. PL/SQL supports conditional execution around SQL statements
B. PL/SQL permits tables without defined columns
C. PL/SQL performs queries without the SQL engine
D. PL/SQL commits automatically after every statement

31 A company wants all applications to use the same validated process for transferring funds. Which PL/SQL feature best supports this requirement?

Benefits and Features of PL/SQL Medium
A. Automatic table duplication
B. Client-side query caching
C. Reusable stored procedures
D. Unrestricted dynamic columns

32 How can stored PL/SQL improve security when users need to perform an approved operation but should not manipulate its tables directly?

Benefits and Features of PL/SQL Medium
A. Disable constraints during the operation
B. Grant ownership of the underlying tables
C. Grant execution on the program unit
D. Store user passwords inside the procedure

33 A batch process must continue after a duplicate-key error and record information about the failed item. Which PL/SQL feature directly supports this behavior?

Benefits and Features of PL/SQL Medium
A. Column aliases
B. Exception handlers
C. Sequence caches
D. Materialized views

34 A query returns many rows that must be processed individually using procedural logic. Which PL/SQL feature is designed to manage the query result set?

Benefits and Features of PL/SQL Medium
A. Constraint
B. Cursor
C. Synonym
D. Savepoint

35 A large application groups related procedures, functions, variables, and cursors under one database object. Which PL/SQL feature is being used?

Benefits and Features of PL/SQL Medium
A. Database link
B. Package
C. Index
D. Sequence

36 A PL/SQL block needs local variables but no error handlers. Which section order is valid?

Basic Structure of a PL/SQL Block Medium
A. DECLAREENDBEGIN
B. BEGINDECLAREEND
C. EXCEPTIONDECLAREEND
D. DECLAREBEGINEND

37 Where must an EXCEPTION section appear within a standard PL/SQL block?

Basic Structure of a PL/SQL Block Medium
A. After executable statements and before END
B. After END and the terminating semicolon
C. Before the optional declaration section
D. Between declarations and executable statements

38 A block has no variables, constants, cursors, or local subprograms. Which section may be omitted?

Basic Structure of a PL/SQL Block Medium
A. The executable section
B. The DECLARE section
C. The END statement
D. The BEGIN section

39 In tools such as SQL*Plus, what is the usual role of / on a line after END;?

Basic Structure of a PL/SQL Block Medium
A. It starts the block's exception-handling section
B. It terminates the final variable declaration
C. It submits the completed block for execution
D. It commits every transaction in the block

40 Consider the block: DECLARE v_num NUMBER := 10; BEGIN DECLARE v_num NUMBER := 20; BEGIN DBMS_OUTPUT.PUT_LINE(v_num); END; DBMS_OUTPUT.PUT_LINE(v_num); END;. What values are printed, assuming output is enabled?

Basic Structure of a PL/SQL Block Medium
A. 20 followed by 20
B. 20 followed by 10
C. 10 followed by 10
D. 10 followed by 20

41 Consider the following block:

BEGIN
NULL;
END;
/

Which statement correctly distinguishes the final two symbols?

Basic Structure of a PL/SQL Block Hard
A. END; submits the block, while / is processed by the PL/SQL engine.
B. END; terminates the PL/SQL block, while / asks a client tool to submit the buffered block.
C. END; closes the session, while / recompiles the block before execution.
D. END; commits the block, while / terminates the current database transaction.

42 Which is the smallest structurally valid anonymous PL/SQL block?

Basic Structure of a PL/SQL Block Hard
A. BEGIN NULL; END;
B. DECLARE NULL; END;
C. DECLARE BEGIN END;
D. BEGIN EXCEPTION END;

43 What happens when this block is executed?

BEGIN
DECLARE
v NUMBER := 1 / 0;
BEGIN
NULL;
EXCEPTION
WHEN ZERO_DIVIDE THEN NULL;
END;
END;

Basic Structure of a PL/SQL Block Hard
A. The compiler rejects division expressions in variable initializers.
B. The declaration is deferred until v is first referenced in the body.
C. The inner handler catches ZERO_DIVIDE and execution completes normally.
D. The exception propagates because it occurs in the inner declarative section.

44 An exception is raised in a block's executable section. Its matching handler then raises a different exception. Where is the new exception searched for?

Basic Structure of a PL/SQL Block Hard
A. In the executable section of the same block
B. Only in the database's predefined handlers
C. Among the remaining handlers of the same block
D. In the exception section of an enclosing block

45 Given the following nested block, which expression inside the inner block refers specifically to the outer variable?

<<outer_block>>
DECLARE
total NUMBER := 10;
BEGIN
DECLARE
total NUMBER := 20;
BEGIN
-- expression here
NULL;
END;
END;

Basic Structure of a PL/SQL Block Hard
A. outer_block.total
B. total
C. DECLARE.total
D. parent.total

46 Which ordering of sections is syntactically valid for a complete PL/SQL block?

Basic Structure of a PL/SQL Block Hard
A. DECLAREBEGINEXCEPTIONEND
B. DECLAREEXCEPTIONBEGINEND
C. BEGINEXCEPTIONDECLAREEND
D. BEGINDECLAREEXCEPTIONEND

47 A query must retrieve one employee salary and branch according to its value. Which design best reflects the roles of SQL and PL/SQL?

Differences between SQL and PL/SQL Hard
A. Use PL/SQL alone for retrieval and SQL alone for procedural branching.
B. Use SELECT ... INTO for retrieval and a PL/SQL IF statement for branching.
C. Use a standalone SELECT for retrieval and a SQL IF clause for branching.
D. Use a SQL declaration for retrieval and a PL/SQL constraint for branching.

48 Which operation generally cannot appear directly as static SQL inside a PL/SQL executable section and therefore usually requires dynamic SQL?

Differences between SQL and PL/SQL Hard
A. COMMIT
B. DELETE FROM employees WHERE status = 'I'
C. CREATE TABLE audit_copy AS SELECT * FROM audit_log
D. UPDATE employees SET salary = salary * 1.1

49 Which statement most accurately compares the usual processing models of SQL and PL/SQL?

Differences between SQL and PL/SQL Hard
A. SQL supports exceptions, while PL/SQL excludes runtime error handling.
B. SQL executes only on clients, while PL/SQL executes only in storage files.
C. SQL describes a desired result, while PL/SQL can prescribe procedural control flow.
D. SQL always processes one row, while PL/SQL always processes complete tables.

50 What is the outcome if a static SELECT ... INTO statement returns more than one row?

Differences between SQL and PL/SQL Hard
A. The predefined exception TOO_MANY_ROWS is raised.
B. The rows are implicitly converted into a collection.
C. Only the final row is assigned to the target variables.
D. Only the first row is assigned to the target variables.

51 After an UPDATE affects zero rows, which behavior distinguishes DML from a scalar SELECT ... INTO?

Differences between SQL and PL/SQL Hard
A. The UPDATE assigns NULL to every target column.
B. The UPDATE raises NO_DATA_FOUND automatically.
C. The UPDATE raises TOO_MANY_ROWS automatically.
D. The UPDATE completes and SQL%ROWCOUNT is zero.

52 Which assignment correctly places the value 5 into a PL/SQL variable named v_count?

Differences between SQL and PL/SQL Hard
A. v_count = 5;
B. SET v_count = 5;
C. v_count := 5;
D. LET v_count := 5;

53 A client currently sends 500 individual DML statements and conditional requests to the database. Which redesign most directly reduces client-server round trips?

Benefits and Features of PL/SQL Hard
A. Send one PL/SQL block that performs the DML and decisions on the server.
B. Move every condition into separate client requests before each DML statement.
C. Send each DML statement twice and compare the returned row counts.
D. Replace bind variables with distinct literal values in all statements.

54 A variable should automatically use the datatype of employees.salary without duplicating its declared precision. Which declaration best supports maintainability?

Benefits and Features of PL/SQL Hard
A. v_salary COLUMN employees.salary;
B. v_salary employees%ROWTYPE.salary;
C. v_salary TYPE OF employees.salary;
D. v_salary employees.salary%TYPE;

55 Which claim about exception handling is correct when a PL/SQL block catches an error after earlier DML has succeeded?

Benefits and Features of PL/SQL Hard
A. Catching the error automatically rolls back all earlier DML in the transaction.
B. Catching the error automatically commits all earlier DML in the transaction.
C. Earlier DML is always discarded when execution enters any handler.
D. Transaction outcome still depends on explicit control or host behavior.

56 Which statement best characterizes the benefit of a stored PL/SQL procedure compared with repeatedly submitting an anonymous block?

Benefits and Features of PL/SQL Hard
A. It is always interpreted by the client, whereas anonymous blocks run on the server.
B. It can execute SQL, whereas an anonymous block cannot contain SQL statements.
C. It is a named schema object that can be reused and granted execution privileges.
D. It automatically commits after every statement, unlike an anonymous block.

57 Which architecture statement most accurately describes execution of a PL/SQL block containing embedded SQL?

Benefits and Features of PL/SQL Hard
A. The PL/SQL engine bypasses the SQL engine whenever static SQL appears in a block.
B. The SQL engine handles procedural statements and sends loops to the client application.
C. The PL/SQL engine handles procedural statements and passes SQL statements to the SQL engine.
D. The client handles exception sections and sends declarations directly to table storage.

58 Which description most precisely defines PL/SQL?

Overview of PL/SQL Hard
A. A replacement storage engine that eliminates the need for relational SQL
B. A schema-definition language restricted to creating and altering database objects
C. Oracle's procedural extension to SQL for combining SQL with programmatic constructs
D. A client-only reporting language that cannot execute inside the database

59 A block performs three related updates and must apply custom recovery logic if the second update fails. Which PL/SQL capability is central to this design?

Overview of PL/SQL Hard
A. Converting every update into an independent database schema object
B. Guaranteeing that each statement commits before the next statement starts
C. Combining sequential SQL statements with structured exception handling
D. Replacing transaction semantics with client-side string processing

60 What value is displayed by this block?

DECLARE
x NUMBER := 3;
BEGIN
DECLARE
x NUMBER := x + 2;
BEGIN
DBMS_OUTPUT.PUT_LINE(x);
END;
END;

Basic Structure of a PL/SQL Block Hard
A. 5
B. 2
C. A compilation error occurs
D. 3