1Z0-149 Oracle Database Program with PL/SQL Practice Questions
Prepare for 1Z0-149 with more than an answer.
Unlock the full exam and previous versions
- v1Version 1 246 questions Current
- 1z0-148Legacy Oracle Database 12c: Advanced PL/SQL 74 questions Locked
- Exam fee
- $245 USD
- Level
- Professional
- Valid for
- Lifetime (no recertification required)
Domains covered on the exam 18
- Declaring PL/SQL Variables8%
- Writing Executable Statements10%
- Writing SQL in PL/SQL8%
- Writing Control Structures12%
- Working with Composite Data Types12%
- Using Explicit Cursors12%
- Handling Exceptions10%
- Using PL/SQL Subprograms6%
- Creating Procedures and Using Parameters8%
- Creating Functions6%
- Creating Packages8%
- Working with Packages6%
- Using Dynamic SQL6%
- Design Considerations for PL/SQL Code8%
- Creating Compound, DDL, and Event Database Triggers6%
- Using the PL/SQL Compiler4%
- Managing PL/SQL Code4%
- Managing Dependencies2%
- 1
A developer needs to execute a DDL statement, such as
TRUNCATE TABLE, from within a PL/SQL procedure. The name of the table to be truncated is passed as a parameter to the procedure. Which method should be used to execute the DDL statement?Show answer details
Correct answer: C
DDL statements cannot be executed using static SQL in PL/SQL because the objects they reference must exist at compile time. When the object name is dynamic (passed as a parameter), Native Dynamic SQL (NDS) with
EXECUTE IMMEDIATEis the required method. The entire DDL command must be constructed as a string and then executed. - 2
A PL/SQL procedure is defined with
AUTHID CURRENT_USER. The procedure updates theSALEStable. UserSCOTT, who owns the procedure, grantsEXECUTEprivilege on it to userJANE. UserJANEdoes not have any direct privileges on theSALEStable. What happens whenJANEexecutes the procedure?Show answer details
Correct answer: B
AUTHID CURRENT_USERspecifies that the procedure executes with the privileges of the user who invokes it (the invoker), not the user who owns it (the definer). In this case,JANEis the invoker. SinceJANElacks the necessaryUPDATEprivilege on theSALEStable, the SQL statement within the procedure will fail due to insufficient privileges. - 3
What is the primary purpose of enabling compile-time warnings using
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL'?Show answer details
Correct answer: C
PL/SQL compile-time warnings identify conditions that are not syntax errors but could lead to runtime errors or poor performance. Examples include unreachable code, subprograms that don't return a value on all paths, or severe performance warnings like passing a
NOT NULLparameter to a subprogram that declares it without the constraint. Enabling warnings is a best practice for improving code quality and robustness. - 4
True or False: A user-defined PL/SQL record type can be used as a column data type in a database table.
Show answer details
Correct answer: B
A record type defined within a PL/SQL block or package (
TYPE ... IS RECORD) is a PL/SQL-only construct and cannot be used as a data type for a table column. To store a composite structure in a table column, you must create a SQLOBJECTtype using theCREATE TYPE ... AS OBJECTDDL statement. - 5
A procedure processes a large set of rows fetched using
BULK COLLECT. After processing, it needs to insert the modified data into a history table. Which statement provides the most performant way to insert all the records from the collection into the history table?Show answer details
Correct answer: C
FORALLis the companion toBULK COLLECT. It takes an entire collection and sends all the DML operations (likeINSERT,UPDATE, orDELETE) to the SQL engine in a single call. This bulk binding approach drastically reduces the performance overhead of context switching that occurs when executing DML inside a regular loop. - 6
A financial services application uses a PL/SQL package to calculate loan eligibility. To improve performance for frequently called scenarios, the lead developer decides to use a result-cached function. The function takes a customer ID and loan amount as input. During testing, it's discovered that the function returns stale data if the customer's credit score, stored in a separate
CREDIT_SCOREStable, is updated. Which clause must be added to the function definition to ensure the cache is invalidated when theCREDIT_SCOREStable changes?Show answer details
Correct answer: B
The
RELIES_ONclause is specifically designed for result-cached functions to declare their dependency on database objects. When data in theCREDIT_SCOREStable changes, the database automatically invalidates the function's result cache, ensuring subsequent calls re-execute the function and fetch fresh data.DETERMINISTICis for functions that always return the same result for the same inputs, but it doesn't manage dependencies on table data.PARALLEL_ENABLEis for parallel query execution, andAUTONOMOUS_TRANSACTIONis for independent transactions. - 7
A DBA is reviewing a large PL/SQL package and notices several procedures pass a large record type (defined with %ROWTYPE from a table with 50 columns) as an
IN OUTparameter. The DBA suspects this is causing performance degradation due to excessive copying of the record's data. Which compiler hint should be used in the procedure definition to request pass-by-reference semantics and potentially improve performance?Show answer details
Correct answer: A
The
NOCOPYhint is used in a subprogram's parameter list to request that the compiler pass the corresponding actual parameter by reference instead of by value. This is particularly effective for large composite types like records or collections passed asOUTorIN OUTparameters, as it avoids the overhead of creating a temporary copy of the data. - 8
A developer needs to create a PL/SQL package that will be deployed across different customer environments running Oracle Database 12c, 18c, and 19c. The package should use a new feature available only in 19c when possible, but fall back to an older implementation on earlier database versions. Which PL/SQL feature allows for this version-specific code implementation within a single source file?
Show answer details
Correct answer: C
Conditional compilation allows the PL/SQL compiler to selectively include or exclude code based on conditions evaluated at compile time. By using the
$IFdirective with theDBMS_DB_VERSION.VERSIONinquiry directive, a developer can write code blocks that are only compiled and included in the final package if the database version meets a certain criterion (e.g., is 19c or higher), providing a clean way to manage version-specific logic. - 9
A security audit requires that a specific sensitive procedure,
process_payroll, within theHR_PKGpackage can ONLY be called by theBATCH_JOB_PKGand theFINANCE_REPORTS_PKG. No other database object or user should be able to execute this procedure directly. Which is the most effective and secure method to enforce this access restriction?Show answer details
Correct answer: B
The
ACCESSIBLE BYclause provides a compile-time, whitelist-based access control mechanism for PL/SQL units. By specifying the calling packages in this clause, you instruct the compiler to raise an error if any other unit attempts to call the protected procedure. This is more secure than grant-based systems because it prevents access even from users with high privileges (like SYS) or through dynamic SQL, enforcing the restriction at the code level. - 10
A data processing pipeline needs to load configuration settings from a key-value table into a PL/SQL collection for fast lookups. The keys are
VARCHAR2strings (e.g., 'TIMEOUT', 'LOG_LEVEL') and the values are alsoVARCHAR2. The number of settings is unknown and can change. Which composite data type is the most appropriate choice for this requirement?Show answer details
Correct answer: D
An INDEX BY table, also known as an associative array, is the only PL/SQL collection type that allows a
VARCHAR2index. This makes it ideal for key-value pairs where the key is a string. It allows for direct, fast lookups using the string key (e.g.,config_settings('TIMEOUT')), which perfectly matches the requirement. Nested tables and VARRAYs are indexed by integers only.
