NDS Utility Package

To make it easier for you to take advantage of the various generic utilities discussed in this chapter, I have created a single package called ndsutil. This package, available from the O’Reilly site in ndsutil.pkg, contains the programs listed in Table 15-1.

Table 15-1. Contents of the NDS utility package on the O’Reilly site

Name

Description

execImmed

A substitute for EXECUTE IMMEDIATE that does not need a USING or INTO clause; includes error handling.

openFor

A substitute for OPEN FOR that does not need a USING clause; includes error handling.

showCol

Shows the contents of a single column in the specified table.

tabCount

Returns the number of rows in the specified table, with an optional WHERE clause.

countBy

Returns the number of rows in the specified table for a particular GROUP BY expression, with an optional HAVING clause.

dynPLSQL

Executes a dynamic PL/SQL string, automatically making sure that it is a valid block and that it ends in a semicolon. The USING clause is not allowed.

The package is defined using the invoker rights mode (AUTHID CURRENT_USER). This means that no matter who owns the package, any external references in the dynamic SQL you execute via ndsutil are resolved according to the authority of the invoking schema, not the owner.

All programs contain exception sections that display the error and the offending SQL. Procedures then re-raise the error, whereas functions generally return NULL or a NULL/empty ...

Get Oracle PL/SQL Programming, Third Edition 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.