17-1. Testing Stored PL/SQL Code Without Unit Tests

Problem

You want to ensure that a block of PL/SQL code is working properly, but don't want to take the time to write a unit test.

Solution

Wrap the code in DBMS_OUTPUT statements that display or print the results of intermediate and final computations and the results of complex conditional steps and branches. This will enable you to see the path that the code is taking when the function is called with specified parameters. The following example demonstrates this tactic for placing comments into strategic locations within a PL/SQL code block in order to help determine if code is functioning as expected. For example, suppose you wish to quickly test the function we introduced in the example for ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.