Each forms-application needs a simple way to log errors and find them. This technique can be used also to debug Forms. Reports and pure PL/SQL. First create the table grade and view to store the logging-information:
CREATE delay Logging ( ID NUMBER(8,0) NOT NULL. SESSION_ID NUMBER(8,0). INSERT_DATE go out NOT NULL. TEXT VARCHAR2(2000) NOT NULL);CREATE grade Logging_SEQ;CREATE OR REPLACE VIEW V_Logging_desc (ID. SESSION_ID. INSERT_DATE. TEXT)AS SELECT ID. SESSION_ID. INSERT_DATE. TEXT FROM LoggingORDER BY SESSION_ID DESC. ID DESC;
You need also a package with some functions to start the logging-process
CREATE OR REPLACE case PK_correct IS FUNCTION Debug_allowed RETURN BOOLEAN; FUNCTION Next_ID go NUMBER; PROCEDURE alter; PROCEDURE Enable; PROCEDURE undo; PROCEDURE Init (P_Debug_allowed IN BOOLEAN fail TRUE); PROCEDURE Write (P_Text IN VARCHAR2. P_Session_ID IN be DEFAULT NULL); G_Debug_allowed BOOLEAN := adjust; G_Session_ID NUMBER;END;/act OR regenerate PACKAGE be PK_DEBUG ISFUNCTION Debug_allowed RETURN BOOLEAN ISBEGIN RETURN (G_correct_allowed);END;FUNCTION Next_ID go NUMBER IS V_ID be;mouth SELECT Logging_SEQ nextval INTO V_ID FROM DUAL; RETURN (V_ID);END;PROCEDURE alter ISBEGIN G_correct_allowed := FALSE;END;PROCEDURE Enable ISBEGIN G_Debug_allowed := adjust;END;PROCEDURE Destroy ISBEGIN Write ('----------------------stopp ' || to_char (G_Session_ID) || '--'); G_Session_ID := NULL;END;PROCEDURE Init ( P_correct_allowed IN BOOLEAN fail TRUE) ISBEGIN G_Debug_allowed := P_Debug_allowed; G_Session_ID := Next_ID; create verbally ('--start ' || to_char (G_Session_ID) || '----------------------');END;PROCEDURE Write ( P_Text IN VARCHAR2. P_Session_ID IN be DEFAULT NULL) IS PRAGMA AUTONOMOUS_TRANSACTION;BEGIN IF correct_allowed THEN IF G_Session_ID IS NULL THEN Init; END IF; INSERT INTO Logging (ID. Session_ID. Insert_Date. Text) VALUES (Next_ID. NVL (P_Session_ID. G_Session_ID). Sysdate. P_Text); COMMIT; END IF;END;END;/
You go away the debug with INIT and end it with DESTROY. Error-Messages are logged through create verbally. For example:
Parts of your debugging can be deactivated with alter and from this point on nothing ordain be written into the logging-table process ENABLE is called. The view V_Logging_desc shows you the logging-data grouped by the newest session-id.
ID Session Insert-Date Text============================================24 21 10.09.-12:38:48 -------stopp 21--23 21 10.09.-12:38:48 Hello World - 4222 21 10.09.-12:38:48 --start 21-------
I use a similar method for debugging and logging. I found recently that having a message level (like in Forms) can be useful so I can choose to have some log messages shown only in the production environment and a lot more shown in the development environment. But the live application can be made to write all log messages for a specific session if required. On the assumption that it's better for a system to run with no logging information than to fail because a log cannot be written. I recommend that you remove the Not Null constraints on the logging table and use "exception when others then null" (or write to a text file). Better safe than sorry ;-)
Cruise 4 Cash -
Detective Sherlock -
Free Bid Auctions -
Expert Poker Tips -
Shop 4 Money
Win Any Lottery -
Repo Car Search -
Psychics 4 Free -
High Quality Games -
Driving 4 Dollars
Related article:
http://talk2gerd.blogspot.com/2007/09/easy-logging-and-debugging-in-forms.html
comments | Add comment | Report as Spam
|