PL/SQL Interface

Version 0.3.0

Implement the oddgen PL/SQL interface to make a generator visible within SQL Developer. The interface consists of a PL/SQL package with definer or invoker rights to describes the behaviour of generator through a set of PL/SQL types and PL/SQL package functions.

You are free to choose any name you like for the PL/SQL package, but you have to use the types and functions according this specification. You just have to implement a generate function. All other functions are optional.

oddgen for SQL Developer has a default behaviour for non-implemented functions. Implement optional functions only if you need to override the default behaviour. This  simplifies the creation and the maintenance of the interface.

The interface is compatible with Oracle Database Server 9.2 and higher. However, the final compatibility depends on the functionality used in the package body of the oddgen interface and its related database objects. This interface documentation focusses on the PL/SQL package specification only. See Tutorial 1 – Minimal 1:1 View Generator or Tutorial 2 – Extended 1:1 View Generator for example PL/SQL package body implementations.

oddgen for SQL Developer is backward compatible, hence the deprecated functions of the PL/SQL interface 0.2.0 are fully functional.

PL/SQL Types

The PL/SQL types for the oddgen interface are defined in PL/SQL package specification named oddgen_types.

Strongly typed PL/SQL types are favoured over weakly types (e.g. associative arrays instead of schemaless XMLTYPE). This might complicate things, especially when generators are invoked from SQL. But running a generator from SQL is not the goal of this interface. More important is a clear and concise interface definition for the integration into SQL Developer.

Syntax

Description

Keys, generic string values

Values, typically short strings, but may contain larger values, e.g. for JSON content or similar.

Value array.

Associative array of parameters (key-value pairs).

Associative array of list-of-values (key-value pairs, but a value is a value array).

Record type to represent a node in the SQL Developer navigator tree.

Icon is evaluated as follows:

  1. by icon_name, if defined
  2. by icon_base64, if defined
  3. by parent_id, if leaf node and parent_id is a known object type (normal icon)
  4. by id, if non-leaf node and id is a known object type (folder icon)
  5. UNKNOWN_ICON, if leaf node
  6. UNKNOWN_FOLDER_ICON, if non-leaf node

PL/SQL Package Functions

Mandatory package functions are marked with a star (*) must be implemented. All other package functions are optional. Implementation is required only to override the default behaviour.

get_name

Get the name of the generator, used in tree view.

If this function is not implemented, the package name will be used.

get_description

Get the description of the generator.

If this function is not implemented, the owner and the package name will be used.

get_folders

Get the list of folder names. The first entry in the list is the folder under ‘All Generators’, the second one is the subfolder under the first one and so on. The generator will be visible in the last folder of the list.

If this function is not implemented, the default is oddgen_types.t_value_type(‘Database Server Generators’). It is possible to override the default in the oddgen preference dialog.

get_help

Get the help of the generator.

If this function is not implemented, no help is available.

get_nodes

Get the list of nodes shown to be shown in the SQL Developer navigator tree. The implementation decides if nodes are returned eagerly oder lazily.

If this function is not implemented nodes for tables and views are returned lazily.

get_ordered_params

Get the list of parameter names in the order to be displayed in the generate dialog.

If this function is not implemented, the parameters are ordered by name. Parameter names returned by this function are taking precedence. Remaining parameters are ordered by name.

get_lov

Get the list of values per parameter, if such a LOV is applicable.

If this function is not implemented, then the parameters cannot be validated in the GUI. This function is called when showing the generate dialog and after updating a parameter.

get_param_states

Get the list of parameter states (enabled/disabled)

If this function is not implemented, then the parameters are enabled, if more than one value is valid. This function is called when showing the generate dialog and after updating a parameter.

generate_prolog

Generates the prolog

If this function is not implemented, no prolog will be generated. Called once for all selected nodes at the very beginning of the processing.

generate_separator

Generates the separator between generate calls.

If this function is not implemented, an empty line will be generated. Called once, but applied between generator calls.

generate_epilog

Generates the epilog.

If this function is not implemented, no epilog will be generated. Called once for all selected nodes at the very end of the processing.

generate*

Generates the result. Called for every selected and relevant node, including its children.

Template

Here’s the complete PL/SQL package specification, it will be used as template for new PL/SQL generators.