Giter Club home page Giter Club logo

pit's Introduction

PIT

PL/SQL Instrumentation Toolkit

Hi everybody, this is the home of PIT, the PL/SQL Instrumentation Toolkit. This tool is designed to help you manage your

  • exceptions
  • debug information
  • trace information
  • assertion functions
  • user messages

within a single package, with a single API and least possible code.

Yet, PIT gives you

  • unlimited number of different output channels to write messages to
  • full i18n support, messages are translatable using a XLIFF file and an open source editor
  • possibility to maintain a full call stack with timing and cpu-timing option
  • fully parameterizable, ability to debug a single session within a connection pool environment
  • ability to define different debug and tracing settings per session

The code is free to use and I hope that you'll enjoy doing so. Should any errors occur, feel free to describe them here, I'll do my best to remove them.

Caveat

This version of PIT has changed the interface in some respects to make it easier and more concise to use. Please read Interface changes for a full description of the changes.

Usage

The use of PIT is straightforward. I took care to create a dense and short interface for working with PIT, as I know that nobody likes to write long package and method names, especially in code areas that you need repeatidly. On the other side, I provide enough explicit methods not to bother you with repeated parameters like severity of a message or similar. Here's a code snippet of a minimal usage of PIT:

procedure my_proc(
  p_param1 in varchar2)
as
begin
  -- trace entering and leaving a method
  pit.enter;
  <do_something>
  -- internal debugging
  pit.debug(msg.STEP_ONE_COMPLETED, msg_args(p_param1));
  -- pass messages to the view layer
  pit.print(msg.STEP_ONE_VIEW_MESSAGE, msg_args(p_param1));
  <do_something_else>
  -- raise an exception
  pit.raise_error(msg.STEP_TWO_FAILED);
  pit.leave;
exception
  -- catch predefined Oracle errors as usual
  when NO_DATA_FOUND then
    -- but provide your own exception messages
    pit.handle_exception(msg.NO_ITEMS_IN_STOCK);
  -- catch your own exceptions just the same way
  when msg.STEP_TWO_FAILED_ERR then
    -- log, re-raise your custom exception
    pit.stop; -- or pit.reraise_exception;
end my_proc;

As you can see, the code amount for instrumentation is minimal, no need to hardcode any message text, no possibility to mistype a message name. The code remains clean, concise and easy to understand. All delivery problems of the debug and exception messages are taken away from the code.

How it works

Messages

PIT is centered around messages. A message basically consists of a message text, a language and a severity, optionally along with an Oracle exception number.

Severities range from 10 (LEVEL_FATAL) to 70 (LEVEL_VERBOSE)or from 20 (TRACEL_MANDATORY) to 50 (TRACE_ALL) to track methods calls. Along with the severity there is a custom error number that you can assign to a message. These error numbers may reference Oracle error numbers with the exception of all those that have a predefined exception already, such as NO_DATA_FOUND or similar. By assigning an Oracle error number to a message, the Oracle error is automatically mapped to this message. If you provide no Oracle error number but need a exception constant, PIT automatically creates a custom error for you, so you don't have to deal with -20.000 numbers anymore!

Messages support being translated to any target language Oracle supports. To make this convenient, PIT supports translating all messages by exporting them as XLIFF files ready to be translated using any XLIFF editor. After translation, the resulting XLIFF file is simply re-imported into PIT and you're done. Translating a single message is possible by calling method pit_admin.translate_message.

The messages are accessible through a package called MSG that contains constants for each message plus Oracle exceptions for all messages with severity LEVEL_ERROR, LEVEL_SEVERE or LEVEL_FATAL (for the first two, you can choose to habe an exception for it or not). So if you create a message called CHILD_RECORD_FOUND, severity LEVEL_ERROR with Oracle error number -2292, package MSG will contain entries like this:

package MSG
as
  CHILD_RECORD_FOUND constant pit_util.ora_name_type := 'CHILD_RECORD_FOUND';
  CHILD_RECORD_FOUND_ERR exception;
  pragma exception_init(CHILD_RECORD_FOUND_ERR, -2292);
...

This package is generated by a procedure called pit_admin.create_message_package and can be rebuilt at any time. As this package will be created during development time only, this package behves like a »normal« package in production and may be either deployed like any other package or created dynamically after having created all required messages. To learn more about the creation of messages, read Using PIT

Messages are basically text templates enhanced with replacement anchors. These are numbered from 1 to 20 and replaced with actual information when they are constructed. It's a bit uncommon that PIT allows CLOB instances to be passed in as parameter values, allowing for really large messages. This comes in handy if you use messages as a technical communication medium, such as passing the result of a calculation as a message. As a powerful extension to this concept, PIT now supports messages in ICU (International Components for Unicode) format alternatively to the messages mentioned above. Read more about ICU messages and their integration into PIT. In a nutshell, ICU messages behave exactly like normal messages but add the internationalization features of ICU to the message text.

Using messages

But now, what do you do with messages? Messages are required in many places of a program. They may be used to

  • maintain error messages in the exception block
  • provide meaningful messages in assertion-methods
  • pass information that is language specific to the view layer of an application
  • provide debug information
  • ...

Being creative will lead to further use cases for PIT. I use messages containing a JSON template like {"status":"#1#","message":"#2#"}. Those messages obviously need no translation. But as they are able to replace anchors within the message with CLOB parameters, they can be used to write the outcome of even complex calculations to the view layer (by calling pit.print(msg.JSON_MSG, msg_args(clob_param));), replacing helper packages for the same purpose. Output modules which implement the print method take care of properly delivering content to the application regardeless of their size. Let's look at the requirements that derive from these use cases a bit closer.

Output modules

From the list of use cases you can see that there is a requirement to be very flexible in regard to output modules. Storing messages in a table or printing them to the console simply is not enough. PIT is designed from ground up to support any number of output modules such as PIT_CONSOLE, PIT_TABLE, PIT_MAIL, PIT_APEX, PIT_FILE and others without the need to change the basic PIT code at all. Plus, all of these output modules may be present but which one will be actually used for debugging is controlled using a context concept. This allows for the least possible logging activities and thus preserving performance.

When you think about these output modules, other requirements pop up. While it is ok to write any debug message to the console, this is certainly not true for a mail output module. To cater for this, PIT allows any channel to decide whether and how they process an incoming message. So it's possible to parameterize the PIT_CONSOLE output module to write every single message to the screen whereas the PIT_MAIL output channel decides to send message of severity LEVEL_FATAL immediately, collecting messages of severity LEVEL_ERROR in a table and send them once a day and ignore all other messages.

I strongly encourage you to create your own output module tailored to your logging needs. Perhaps you need a module that immediately creates a ticket in your ticket system in case of fatal errors or something similar. An own output module is the way to achieve this goal. If you want to familarize yourself with creating your own output module, you may want to continue reading here.

Communication Channels

Output modules implement a number of communication channels, implemented as methods defined in an abstract super class PIT_MODULE from which all other output modules a derived. These are:

  • ENTER/LEAVE: These channels are used to trace your code. They allow for parameters to be passed in and provide timing functionality and others
  • LOG_VALIDATION: A channel specifically for validation messages. These aren't written to the log tables normally, so this channel allows to implement a more lightweight information system.
  • LOG_EXCEPTION/PANIC: Errors and exceptions are normally thrown using the LOG_EXCEPTION channel. If an unexpected and unhandled error occurs, PANIC may be your last ressort. It is normally implemented to create tickets, terminate the application or similar.
  • NOTIFY: This channel is meant as a very lightweight information mechanism, e.g. for Websocket/ServerSentEvents methods.
  • TWEET: Even easier to use is this channel, as it accepts plain text and tweets it to all output modules. This is ideal for ad hoc-testing and should not remain in your code.
  • PURGE_LOG/CONTEXT_CHANGE: These are admoinistrative channels which allow to purge log entries from an output module or take some action if the settings for debug and trace change.

All communication channels are available for each output module. It is up to the output module to implement the channels it wants to deal with, leaving all other channels untouched. As the abstract base module implements all channels, it is allways save to rely on the standard implementation (which is a simple stub, doing nothing). This methods allows for easy extension lateron: The base module offers new channels and the concrete output modules implement what they need later.

Context

It's good practice to include instrumentation code not only in development but in production code as well. Obviously there's a need to be very flexible in switching this code off and on. PIT supports this flexibility by a concept of contexts. A context is a set of settings that is used to control the debug and trace level. It consists of four settings:

  • DEBUG_LEVEL: Set the maximum severity that gets logged
  • TRACE LEVEL: Set the maximum trace level (of which there are four) to trace entering and leaving methods
  • TRACE_TIMING: Flag to switch capturing of timing information on and off
  • OUTPUT_MODULES: Colon-delimited list of output modules that are required for logging, such as PIT_CONSOLE:PIT_TABLE.

One such context is called CONTEXT_DEFAULT. The default context is parameterized and used upon »normal« execution of the code. To change it, change the parameter settings and have PIT initialize again. Besides this default context, it's possible to create any number of named contextes by using parameters with a naming convention of CONTEXT_<Name>. With such a context, you're free to predefine any combination of logging settings and output modules and easily switch to that context later. Plus, you can call a pit.set_context method and define a new context on the fly. Any named context may be activated per session (even in an connection pool environment, where only one user is traced, no matter which connection this user utilizes) or globally. If set, the activated context overrules the default. By resetting the context, you switch back to you CONTEXT_DEFAULT settings.

Using the context concept, you have the choice to control the debugging by:

  • Parameterizing the default control and adjust the generic debug settings
  • Overrule the default settings with predefined context settings
  • Dynamically define a new context setting for immediate debug activities
  • Trace the complete code, a defined session or a defined user, even in connection pools

More information on contexts can be found here.

Toggle logging on and off based on package or method names

With PIT, it's possible to create a include or exclude list of code units which toggle logging on or off. Imagine a predefined context CONTEXT_ALL which defines complete logging (70|50|Y|PIT_CONSOLE:PIT_FILE). As per default, logging is set to no logging at all, as you are in production environment. Then you can create a parameter called TOGGLE_<Name> with a value of MY_PACKAGE|MY_OTHER_PACKAGE:CONTEXT_ALL. If you enter one of these packages, PIT will set the context to CONTEXT_ALL, tracing anything from now on. Once you leave these packages, context will be switched back to defaut settings.

This will create an include list. By switching to a to be defined context CONTEXT_OFF you can realize an exclude list, preventing logging for certain package even if default logging is switched on.

You may have as many toggle parameters as you like. Plus, PIT offers a set of methods in the pit_admin package to create toggles for your code to avoid having to manually format the parameters accordingly.

Collect messages and exceptions and handle them in bulk

Often, UI forms require you to validate the user's input. Those validation methods are placed in a package, probably as part of a transaction API, near the tables. If you validate your code, those methods typically stop validating upon the first exception that occurs. To the end user, this is very unfriendly, you want to see all validation issues there are.

To avoid this, you could

  • recode all validation methods in packages which are closer to the UI and implement your own way of validating all aspects and collect the exceptions
  • break up to validation logic into many trivial methods which only implement the validation of one aspect at a time and construct something around it that collects the upcoming validation issues.

Both scenarios can be avoided by using PIT in collect mode. To set this mode, you simply call PIT.start_message_collection prior to calling the validation logic. Any PIT message that is raised during processing of the validation code are not raised immediately but stored in an internal collection within PIT.

You stop this mode by calling PIT.stop_message_collection. PIT now examines the list of collected messages, looking for a message with severity FATAL or ERROR, whatever is worse. Based on the worst severity, PIT now throws an exception called PIT_BULK_FATAL or PIT_BULK_ERROR respectively. If you catch those, you get access to the collected messages using PIT.get_message_collection and can now iterate through all messages collected and present them to the end user.

Of course you can omit the call to PIT.stop_message_collection and directly work with the collected messages. If you do so, PIT automatically switches off collection mode. PIT.get_message_collection will include all collected messages of all severities you have parameterized to fire, so calling this method will even be useful if no exception was raised after stopping collect mode.

More details on working in collect mode can be found here.

Administration

To administer PIT, a dedicated administration package is provided. It provides methods to

  • create or translate messages
  • create the MSG package
  • create or import an XLIFF file containing all messages ready for translation
  • check whether predefined Oracle errors exist to prevent overriding
  • Helper methods to create named contexts and context toggles
  • create an installation file containing all messages in the database

With these methods it's easy to maintain and extend an installation file during development to create new messages on the fly. If you do so, the deplyoment file is created just along with your activities. Alternatively, you may want to have PIT_ADMIN create an installation file containing all messages in the database for you.

To make it even more convenient for you, I also added an APEX application that allows to maintain (create, edit, translate) messages and parameters, export their values by creating a downloadable script file withs calls to the PIT_ADMIN-API and see where any given message is referenced in the code. Read more about this AEPX application here.

Extensibility

PIT comes ready to use with a bunch of output modules. You may want to start your changes by reviewing the output modules and adjust their behaviour. Should an output module be missing, it's easy to create a new one based on the other modules that ship with PIT. I decided to create the necessary object types but only implement the bare minimum of functionality within these types, just enough to call helper packages that carry out the heavy lifting. This way you're not exposed to object oriented programming in PL/SQL more than absolutely necessary ... ;-) What I achieved by this is that object orientation adds a feature to PL/SQL not otherwise available, namely the concept of an interface. Using this concept makes the code more stable and easier to implement and understand, as you don't need to create dynamic PL/SQL packages and the like.

Other possible extensions refer to the way session identity is detected. It may be sufficient to rely on CLIENT_IDENTIFIER, as this is the case in APEX environments, or to stick to the USER function to detect a specific user. Should this turn out to not be working for you (e.g. in a proxy user environment), you may provide a new SESSION_ADAPTER that implements your method of detecting the session identity. Which SESSION_ADAPTER is used is parameterizable. PITships with a default adapter and a second adapter to be used with the PIT_APEX output module. Within APEX, there is a different concept of session (namely a http session as opposed to a database session) and the way to access the username is different. Take this as a blue print for your own session adapters should you need one.

The session adapter serves for another purpose as well: If the calling environment is set to debug, as this is possible within APEX, the session adapter will switch PIT to debug modus as well. This way, PIT automatically follows the application in this regard.

What's more?

Reusable Components

PIT makes havy use of parameters. Parameters are organized in parameter groups of which PIT uses the parameter group PIT. These parameters are maintained by separate packages PARAM and PARAM_ADMIN to retrieve and maintain parameter values in a mandator aware way. Plus, the parameter package supports a concept called REALM that allows to store different parameter settings depending on the realm they are defined for. This allows for storing different parameter values per realm, say a list of URLs for development, testing and production use.

As this package, along with a generic parameter table, is accessible outside PIT, the parameter package may be used to organize all of your application parameters as well. The administrative package once again allows you to create and maintain parameters and to export parameters by reating a group of parameter files with all parameters and their values in a file per parameter group. Read more about parameter support using parameters

A second component that might be reused is a component to maintain globally managed contexts. In order to store parameters in a way that they are accessible cross-session, you need a globally accessed context. Whereas this type of context is very nice in that access to its information does not incur context switches from neither PL/SQL nor SQL, it's not all intuitive to use. A separate package UTL_CONTEXT allows for a smoother utilization of globally accessible contexts. Being a separate package it's easy to reuse this package for your own context requirements. Context are described in depth here.

APEX administration app for various APEX versions

PIT ships with an administrative APEX application to easily create and maintain parameters, messages and PIT related settings such as contexts or context toggles. An export page allows you to export parameters, messages and translatable items as ZIP files. You may export as many message or paramter groups as you like. For messages and translatable items, there is also a possibility to generate and import XLIFF translation files in any Oracle supported target language. For a brief introduction to the APEX application, continue reading here

Further reading

If you need assistance in installing PIT, read Installing PIT

To get familiar with PIT, read Using PIT

Details to throwing and catching Exceptions can be found here

If you want to validate user input, read Validating User Input

Some advice on how to keep execution speed high with PIT can be found here

Should you experience problems when using PIT, some advices can be found here

Technical documentation about the packages that form PIT can be found here

pit's People

Contributors

j-sieben avatar sushar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pit's Issues

Neuer Fehler

Folgende Fehlermeldung bekomme ich bei der Installation von PIT:
Fehler f³r PACKAGE BODY UTILS.PIT_ADMIN:

LINE/COL ERROR


790/16 PL/SQL: Item ignored
790/16 PLS-00201: ID 'WWV_FLOW_GLOBAL.VC_ARR2' muss deklariert werden
799/7 PL/SQL: Statement ignored
799/7 PLS-00320: Die Typ-Deklaration dieses Ausdruckes ist unvollstõndig oder fehlerhaft
800/7 PL/SQL: Statement ignored
800/31 PLS-00320: Die Typ-Deklaration dieses Ausdruckes ist unvollstõndig oder fehlerhaft
801/7 PL/SQL: Statement ignored
801/16 PLS-00320: Die Typ-Deklaration dieses Ausdruckes ist unvollstõndig oder fehlerhaft
. - Create default parameters

greets
tanto

ein weiteres Problem bei der Installation von PIT

Hallo Jürgen,

bei der Installation von PIT (neueste Version) wird folgender Fehler ausgegeben:

** Create tables
. - Create table PIT_MESSAGE_LANGUAGE
. - Create table PIT_MESSAGE_GROUP
. - Create table PIT_TRANSLATABLE_ITEM
. - Create table PIT_MESSAGE_SEVERITY
pse_pti_pmg_id varchar2(50 char) default on null 'PIT',
*
ERROR at line 5:
ORA-00936: missing expression

Kannst Du mir an dieser Stelle weiterhelfen ?

Besten Dank und viele Grüße
Thomas

issue with PARAM_ADMIN during installation

Dear Jürgen,
I want to establish PIT and replace Logger in my company (leading German automotive supplier). Therefore I am preparing a demo environment to convince our architects :-)
I connected as SYS and got following issue. I would appreciate your help a lot!

I have made only small changes to the values in init.sql

-- ADJUST THIS SETTINGS IF YOU WANT ANOTHER TYPE 
--define FLAG_TYPE="char(1 byte)";
--define C_TRUE="'Y'";
--define C_FALSE="'N'";

define FLAG_TYPE="number(1, 0)";
define C_TRUE=1;
define C_FALSE=0;
...
define EXCEPTION_PREFIX=e
define EXCEPTION_POSTFIX=ERR

install script output:

********************************************************************************
*** PL/SQL INSTRUMENTATION TOOLKIT (PIT) Installation at user PIT_OWNER

********************************************************************************
*** Checking whether required users exist
**  Checking owner user PIT_OWNER
.    - User PIT_OWNER exists.
**  grant user rights
*   Grant SYSTEM privileges
**  Check whether PIT_OWNER has privilege create session
.    - System privilege create session is already granted.
**  Check whether PIT_OWNER has privilege create procedure
.    - System privilege create procedure is already granted.
**  Check whether PIT_OWNER has privilege create table
.    - System privilege create table is already granted.
**  Check whether PIT_OWNER has privilege create type
.    - System privilege create type is already granted.
*   Grant OBJECT privileges
**  Check whether PIT_OWNER has privilege select on dba_context
.    - Object privilege select on dba_context is already granted.
.    - SYS granted inherit privileges to PIT_OWNER
.    - Set Compiler-Flags

********************************************************************************
*** Installing parameter framework
**  Change current schema to PIT_OWNER
**  Clean up existing installations
.    - Package PARAM deleted.
.    - Package PARAM_ADMIN deleted.
.    - Table PARAMETER_GROUP deleted.
.    - Table PARAMETER_LOCAL deleted.
.    - Table PARAMETER_TAB deleted.
.    - Table PARAMETER_TYPE deleted.
.    - View PARAMETER_REALM_VW deleted.
.    - View PARAMETER_VW deleted.
**  Create parameter tables
.    - Create table PARAMETER_GROUP
.    - Table PARAMETER_REALM already exists
.    - Create table PARAMETER_TYPE
.    - Create table PARAMETER_TAB
.    - Create table PARAMETER_LOCAL
**  Create parameter view
.    - Create view parameter_core_vw
.    - Create view parameter_vw.owner
.    - Create view parameter_realm_vw
**  Create parameter packages
.    - Create package specification param
No errors.
.    - Create package specification param_admin
No errors.
.    - Create package body param
No errors.
.    - Create package body param_admin

Warning: Package Body created with compilation errors.

Errors for PACKAGE BODY PARAM_ADMIN:

LINE/COL ERROR
-------- -----------------------------------------------------------------
502/7    PL/SQL: SQL Statement ignored
504/38   PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got
         CHAR

529/7    PL/SQL: Statement ignored
530/32   PLS-00364: loop index variable 'PRE' use is invalid
**  Load data
.    - Script merge_parameter_realm
begin
*
ERROR at line 1:
ORA-04063: package body "PIT_OWNER.PARAM_ADMIN" has errors
ORA-06508: PL/SQL: could not find program unit being called: "PIT_OWNER.PARAM_ADMIN"
ORA-06512: at line 3

Install PIT into existent user WITHOUT need for DBA privileges

Hey Juergen,

this tool looks awesome, however I won't be able to use it as part of a client project because I will never get DBA privileges at any point for the client's production database.
It seems to me that the only reason to use dba privileges for installation is convenience, is that correct?
Can you give a hint what would be needed to create an alternative installation approach that allows to install PIT into an existing user without any privileges?
I'd be willing to contribute for implementation.

Sam

Initial thoughts and questions

Learned about PIT yesterday and I'm really impressed. Love what you've build here!
I thought I already have high standards with ORA Logger but you put it to the next level :D

But after reading through the doc I have some questions and thoughts. (Important: I haven't installed or used PIT yet!)

  • As far as I understood you have to define the severity for a message. But I only see log procedures which override this and dont have variable level?! E.g.: debug | Captures debug information, level debug.
    So the severity of the msg will be ignored? Do I miss something?
  • How to handle the messages with multiple development environments. E.g. keep all the pit_admin.merge_messages in a script which can be version controlled and therefore merged and called on every instance?!
  • Some procedure names are in my opinion not self explanatory, eg.: "stop" (handles an error and calls leave and re-raises the error). This info needs to be in the name in my opinion, eg. "leave_and_raise"
  • Option to log msg_params without calling "enter" or "leave" which would switch the context.
  • Is there a way to raise exception with raise_application_error and the correct message? Sth like pit.raise(msg.CHILD_RECORD_FOUND_ERR)? Or should this be done with pit.sql_exception?

Maybe some bad questions but as I said I just had a first look :)

Probleme bei der Installation von PIT

Hallo Jürgen, erstmal schöne Osterfeiertage.
Wollte heute am Karfreitag PIT installieren, was aber immer an derselben Stelle mit einem Fehler abbricht:
. - Create default parameters
. - Script ParameterGroup_PIT
Geben Sie einen Wert für true ein: 'y'
Geben Sie einen Wert für false ein: 'n'
Geben Sie einen Wert für false ein: 'n'
,p_par_description => 'Named context, switches logging on [LOG_LEVEL|TRACE_LEVEL|TRACE_TIMING_FLAG ('Y','N')|MODULE_L
IST]'
*
FEHLER in Zeile 37:
ORA-06550: Zeile 37, Spalte 105:
PLS-00103: Fand das Symbol "Y" als eines der folgenden erwartet wurde:
) , * & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset

Habe es auch mit den Symbolen versucht, die mir als 'erwartet' angezeigt wurden.
Viele Liebe Grüße
Jürgen (Tanto)

UTL_TEXT missing in install script

PIT core check_prerequisites.sql script checks for UTL_TEXT existence and fails because core install.sql script does not call it's installation before (@&core_dir.utl_text/install.sql).

Issue with type spec PIT_UTIL

Dear Jürgen
thanks for reworking the installation grants for PIT, this will help to introduce it a lot in my company.
Unfortunately while installing it always fails due to invalid PIT_MODULE spec.
I also tried to manually compile all type specs but this also failed.
Anyway, happy easter, see you at APEX Connect!
Stefan

. - Create type specificationPIT_MODULE_LIST
** Create ADMIN package declarations
. - Create package specification pit_util

Fehler fⁿr TYPE PIT_OWNER.PIT_MODULE:

LINE/COL ERROR


0/0 PL/SQL: Compilation unit analysis terminated
1/11 PLS-00304: Body von 'PIT_MODULE' nicht ohne die Spezifikation kompilierbar
`

After installation packages are invalid

Hi Jürgen, I just dropped the schema and ran the install procedure from your latest Git commits. The installation ended with a success message but I found following issues:

  • ')' is missing in PIT_APEX_PKG here:

pit.log(msg.WEBSOCKET_MESSAGE, msg_args(g_websocket_server, l_message);

  • in PIT_PKG:
    • component 'NAME_TYPE' must be declared
    • identifier 'G_SCHEMA_NAME' must be declared

During installation I was asked about the values for true, false and the post- and prefixes. The text for the post fix says "Geben Sie einen Wert für false ein" so I guess it is a Copy&Paste issue.

Regards,
Stefan

Issue with pit_install_client.sql

Hi Jürgen,
sorry, it's me again with a hopefully small issue ;-) After the sucessful installation I wanted to grant access to my test user to start building a demo.
A hint: During installation I set the boolean parameter as follows:
define FLAG_TYPE="number(1, 0)"; define C_TRUE=1; define C_FALSE=0;

Thanks a lot for any help!

output of pit_install_client.sql

`INSTALL_USER REMOTE_USER


PIT_OWNER POS8FE

ORA_NAME_TYPE ORA_MAX_LENGTH


varchar2(128 byte) ##########


*** Installing PIT client POS8FE


*** Checking whether required users exist
** Checking owner user PIT_OWNER
. - User PIT_OWNER exists.
** Check whether PIT_OWNER has privilege create session
. - System privilege create session is already granted.

** Grant access to PARAM installation

** Granting access to parameter package to POS8FE

  • Clean up schema POS8FE
    . - revoking client rights
  • Grant access rights to POS8FE
    . - Granting execute on param to POS8FE
    . - Create synonym param for PIT_OWNER.param at POS8FE
    . - Granting execute on param_admin to POS8FE
    . - Create synonym param_admin for PIT_OWNER.param_admin at POS8FE
    . - Granting select, references on parameter_group to POS8FE
    . - Create synonym parameter_group for PIT_OWNER.parameter_group at POS8FE
    . - Granting select, references on parameter_realm to POS8FE
    . - Create synonym parameter_realm for PIT_OWNER.parameter_realm at POS8FE
    . - Granting select, references on parameter_tab to POS8FE
    . - Create synonym parameter_tab for PIT_OWNER.parameter_tab at POS8FE
    . - Granting select, references on parameter_type to POS8FE
    . - Create synonym parameter_type for PIT_OWNER.parameter_type at POS8FE
    . - Granting select on parameter_core_vw to POS8FE
    . - Create synonym parameter_core_vw for PIT_OWNER.parameter_core_vw at POS8FE
    . - Granting select on parameter_realm_vw to POS8FE
    . - Create synonym parameter_realm_vw for PIT_OWNER.parameter_realm_vw at POS8FE
  • Change current schema to POS8FE
  • Create PIT user tables and views
    . - Create table PARAMETER_LOCAL
    . - Create view PARAMETER_VW
    coalesce(pal_boolean_value, par_boolean_value) par_boolean_value,
    *
    FEHLER in Zeile 10:
    ORA-00932: Inkonsistente Datentypen: CHAR erwartet, NUMBER erhalten`

It might be a good idea to abort install when a non-existing Oracle language has been entered

Hi!
I entered a non-existing language at this point
"Enter default language (Oracle language name) for messages:"

The installation nevertheless continued and but later on gave me some error like "ungueltiger Benutzer" or something similar.
It would be great, if the installer aborts earlier and with a more logical error.

The error was due the init/init.sql script which failed to initialize the INSTALL_USER variable using the following statement due the fact that my chosen language was non existent:
select user sys_user,
upper('&1.') install_user,
null remote_user,
value default_language
from V$NLS_VALID_VALUES
where parameter = 'LANGUAGE'
and value = upper('&2.');

I know this is just convenient feature, so no worries.

Best regards,

Nils Stritzel

Install with existing user and special default tablespace

Hallo Jürgen,

bei einer Neuinstallation ist mir folgendes aufgefallen:
Voraussetzungen:

  • separates tablespace (create tablespace TS_SU_ALL Datafile ....)
  • neuer Benutzer (create user SUTLS identified by "pswd" default tablespace TS_SU_ALL ...)
  • Berechtigung (grant connect to SULTS)

Ein Aufruf des Installationsskriptes mittels @pit_install SUTLS GERMAN führt erst mal zu einem Fehler in "chek_users_exist.sql". Dort kann der Identifizierer "l_user_has_quota" nicht aufgelöst werden. Nach dem Ersetzen von "l_user_has_quota" durch "l_user_has_tablespace" war das Problem behoben.
Allerdings scheiterte ein weiterer Versuch jetzt daran, dass die Tabelle "parameter_group" im Skript "parameter_group.tbl" wegen nicht ausreichender Berechtigung nicht angelegt werden konnte (ORA-01950: keine Berechtigungen für Tablespace 'TS_SU_ALL'). Der Grund dafür besteht darin, dass im Skript "chek_users_exist.sql" quotas für das tablespace "users" erzeugt werden, nicht aber für das default tablespace des Benutzers.

Mein Vorgehen für eine gelungene Installation besteht also jetzt darin, dass ich a) in "chek_users_exist.sql" den Bezeichner "l_user_has_quota" durch "l_user_has_tablespace" ersetze und b) beim Anlegen des Benutzers die quotas für das default tablespace vorher festlege.

Vermutlich ist mein Vorgehen bei der Installation nicht der allgemein beschrittene Pfad, aber vielleicht lässt sich auch hierfür noch eine kleine Verbesserung etablieren.

Viele Grüße und besten Dank für die hervorragenden Werkzeuge,
Frank

[Y/N] is static in PIT_UTIL.check_context_settings

Hello Jürgen,
I think I found one last place where Y/N is not replaced by the values provided in settings:
C_SETTING_REGEX constant varchar2(200) := '^(((10|20|30|40|50|60|70)\|(10|20|30|40|50)\|(Y|N)\|[A-Z_]+(\:[A-Z_]+)*)|(10\|10\|N\|))$';

I came across this when I wanted to create my first named context.

this works fine:
BEGIN
pit.set_context( p_log_level => pit.level_all
, p_trace_level => pit.trace_all
, p_trace_timing => TRUE
, p_log_modules => 'PIT_CONSOLE:PIT_TABLE'
);
END;
this fails:
BEGIN
pit_admin.create_named_context(
p_context_name => 'CONTEXT_12'
, p_log_level => 70
, p_trace_level => 40
, p_trace_timing => TRUE
, p_module_list => 'PIT_CONSOLE:PIT_TABLE'
);
END;

Have a good one,
Stefan

Fehler bei der Installation (Oracle Express 19) 03.07.2020

Fehler anfang:
. - Create package Body PIT_ADMIN

Warnung: Package Body wurde mit Kompilierungsfehlern erstellt.

Fehler bei PACKAGE BODY PIT_ADMIN:

LINE/COL ERROR


988/7 PL/SQL: Statement ignored
988/25 PLS-00201: ID 'MSG.SQL_ERROR' muss deklariert werden
. - Create default parameters
. - Create translatable items
begin
*
FEHLER in Zeile 1:
ORA-04063: package body "PIT_OWNER.PIT_ADMIN" enthält Fehler
ORA-06508: PL/SQL: aufgerufene Programmeinheit : "PIT_OWNER.PIT_ADMIN" konnte nicht gefunden werden
ORA-06512: in Zeile 3

Grüße
Jürgen (aus Berlin ;-) )

Obsolete synonyms found

Hi Jürgen,
I am preparing my demo to some important guys in order to convince them to integrate PIT into our new Exadata machine. I found the following obsolete syn. in my application schema.

  • pit_log (replaced by PIT_TABLE_LOG?)
  • PIT_CALL_STACK (to PIT_TABLE_CALL_STACK?)
  • PIT_TABLE_CALL_PARAMS (to PIT_TABLE_PARAMS?)
    I hope I have not overlooked anything.
    Regards, Stefan

Consider alter session command for 23c while installing client

Dear Jürgen,
there is a similar issue when granting privs to a client.

alter session set plsql_implicit_conversion_bool = true
Error at line 9
ORA-02248: invalid option for ALTER SESSION

Connected PIT_OWNER


*** Grant access to PIT to client DEV

** Grant access to PARAM installation

** Granting access to parameter package to DEV

  • Grant access rights to DEV
    Script stopped on line 8 of ...git\pit\PIT\install_scripts../parameters/grant_client.sql.

unkompilierte Objekt nach der Installation

Hallo Jürgen,

bei meinen Tests ist es vorgekommen (jedes Mal), dass Objekte nicht Valid waren. In Deinem Projekt UTL_TEXT verwendest Du in Deinem InstallScript am Ende folgendes Statement, um ein Recompile durchzuführen, vielleicht ist es sinnvoll das oder etwas Ähnliches auch hier eingesetzt werden.

prompt &h1.Recompiling invalid objects
declare
l_invalid_objects binary_integer;
begin
dbms_utility.compile_schema(
schema => user,
compile_all => false);

select count(*)
into l_invalid_objects
from user_objects
where status = 'INVALID';

dbms_output.put_line(l_invalid_objects || ' invalid objects found');
end;
/

mfg.
Ralf

old code examples in using_pit.md

Hey Jürgen,
while proceeding with my demo (to convince our architect and chief developer) I found two small issues in this subchapter

  1. the MERGE_MESSAGE procedure has new parameter names
  2. the TRANSLATE_MESSAGE does not exist any more. I assume that I can use the merge_message and just provide another language to translate (at least this worked for me, I hope this is the intended way)
  3. a typo in parameter name:
    pit.enter('my_func', p_ oparams => msg_params(

Enjoy the rest of your day,
Stefan

Trying to install the PIT and accompanying Apex application on autonomous cloud.

Good afternoon,

Trying to install the PIT and accompanying Apex application on autonomous cloud.

The install script for PIT mentions:
-- PIT_MAIL may be installed after installing UTL_TEXT
--@modules/pit_mail/install.sql
But when I install PIT first and UTL_TEXT next and then PIT with uncommented @modules/pit_mail/install.sql, I lose the UTL_TEXT messages and I end up with an invalid UTL_TEXT. I'm a bit in a chicken-egg sitiuation...

I have to disable this set plsql_code_type - is it really neccesary?
-- insufficient privileges for this one on autonomous cloud
-- alter session set plsql_code_type='NATIVE';

Also using PIT_OWNER schema name as password is not allowed, I have to include a separate parameter with password.

There is no tablespace user on cloud, the default permanent tablespace is data. Maybe fetching the default permanent tablespace and using that, is more robust?

Abbruch in create_client_synonyms.sql

Hallo Jürgen, diesmal auf Deutsch, ist einfacher ;-)
Ich bin fast am Ziel, für mein Client Schema "DEV" ist das Skript "grant_client_access" bereits erfolgreich durchgelaufen.
Weil ich mit einer Sandbox-DB arbeite, die nicht in der zentral-verteilten TNS names ist, habe ich in der install_client.bat einfach den connect Befehl direkt eingebaut, daran sollte es aber nicht liegen:

echo @install_scripts/grant_client_access %InstallUser% %RemoteUser% | sql PIT_OWNER/******@//*****:1522/CIAPEX19C.WORLD 
echo @install_scripts/create_client_synonyms %InstallUser% %RemoteUser% | sql DEV/******@//*****:1522/CIAPEX19C.WORLD

Das Skript create_client_synonyms bricht vorzeitig ab, beim Anlegen den ersten Synonyms.

DEFAULT_TABLESPACE
_____________________
USERS
.    - Checking whether PIT exists at user PIT_OWNER

ERR_PRE    ERR_POST
__________ ___________
E_

Boolean type: number(1, 0), 1|0

********************************************************************************
*** Registering PIT, found at PIT_OWNER at client DEV

**  Registering parameter package.
*   Clean up schema DEV

**  Remove registration of parameter package.
*   Drop synonyms
*   Drop local objects
.    - Drop table PARAMETER_LOCAL
.    - Drop view PARAMETER_VW
*   Create synonyms
.    - Create synonym param
Abgemeldet von Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.7.0.0.0

es startet damit

prompt &h3.Create synonyms
@&tools.create_synonym.sql param

Abbruch müsste dann hier erfolgen, evtl. weil PIT_USER nicht übergeben wurde und der Vergleich dann schief geht.

prompt &s1.Create synonym &1.
begin
  if '&PIT_USER.' != user then
    execute immediate 'create or replace synonym &1. for &PIT_USER..&1.';
  end if;
end;
/

Gruß
Stefan

PIT in APEX22.1

Hi Jürgen,

ich versuche gerade PIT in APEX22 zum laufen zu bekommen. Ich habe soweit alle Funktionen für Websheets mit Dummy Werten aufgefüllt, da ich diese eh nicht verwenden werde. Damit lässt sich das Package zumindest wieder kompilieren. Und die Installation läuft durch.

Ich habe nun nur das Problem das PIT_UI Package Fehler hat, da die message Konstanten für msg.UTL_INVALID_REQUEST, msg.UTL_PARAMETER_REQUIRED und msg.UTL_INVALID_REQUEST_ERR fehlen. Ich finde diese aber in keinem Installationsskript.
Kann ich die Parameter einfach selbst im Package anlegen und mir einen ErrorCode dazu ausdenken?

Grüße
Moritz

Can we use PIT on the Oracle Cloud ATP?

Hello, we were trying to install PIT on the Oracle-Always-Free-Cloud-ATP database instance, but it seems that the admin user is not allowed to log in as sysdba. We see the same problems with Logger for example. Maybe you have already tried this yourself?

Solution for json_object_t if working with Oracle < 12.1

Hi Jürgen, this time I did not find a new issue;-) I just found out that package PIT_APEX_PKG is invalid due to my DB version 12.1.02 and the JSON_OBJECT_T which was introduced in 12.2 :-(
Unfortunately we will not upgrade in the next months so I would need to apply a workaround.
But if I get it right it's relatively easy to achieve the same with manual string concatenation. The format expected is
[ {"key1":"value1"},...{"key_n":"value_n"} ], then everything should work be fine and I simply pass it over instead of l_message.stringify here:

pit.log(msg.WEBSOCKET_MESSAGE, msg_args(g_websocket_server, l_message.stringify)); l_response := apex_web_service.make_rest_request( p_url => g_websocket_server, p_http_method => 'GET', p_body => l_message.stringify());

If you see any further issues I haven't considered I would appreciate a short note.
Have a nice weekend!
Stefan

Number conversion error in PIT_UTIL

Hi Jürgen,
I proudly created my first test message
BEGIN pit.info( msg.my_first_info_message ); END;
but the execution ended up in
[Error] Execution (222: 1): ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "PIT_OWNER.PIT_UTIL", line 393
ORA-06512: at "PIT_OWNER.PIT_PKG", line 234
ORA-06512: at "PIT_OWNER.PIT_PKG", line 262
ORA-06512: at "PIT_OWNER.PIT_PKG", line 284
ORA-06512: at "PIT_OWNER.PIT_PKG", line 815
ORA-06512: at "PIT_OWNER.PIT_PKG", line 896
ORA-06512: at "PIT_OWNER.PIT", line 238
ORA-06512: at line 2

The message is inserted correctly in MSG table (wanted to add a screenshot but this does not work at the moment).
(PSE_ID: 50, PML_NAME: AMERICAN, PMS_ID = PMS_NAME = MY_FIRST_INFO_MESSAGE)

Do you have a clue what's the reason here?

UTL_TEXT issue with name of exception

Hi Jürgen,
sorry, it' me again with an issue:-)
In utl_text.clob_to_blob the name of the assertion exception does not get adapted to what was setup during the PIT installation (I chose E as prefix).

when msg.ASSERT_IS_NOT_NULL_ERR then...

Have a nice day,
Stefan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.