1 PACKAGE BODY OE_DBG as
2 /* $Header: OEXUTDBB.pls 115.0 99/07/16 08:16:36 porting ship $ */
3 --
4 -- PURPOSE
5 -- This package allows debugging messages to be issued by server PL/SQL
6 -- that can be retrieved by the call client program.
7 --
8 -- HISTORY
9 --
10 -- 18-APR-94 R Lee Created.
11 --
12 /*------------------------------ DATA TYPES ---------------------------------*/
13
14 TYPE MESSAGE_TABLE_TYPE IS TABLE of
15 VARCHAR2(500)
16 INDEX BY BINARY_INTEGER;
17
18 /*---------------------------- PRIVATE VARIABLES ----------------------------*/
19
20 G_Message_Buffer MESSAGE_TABLE_TYPE; -- Message Stack
21 G_Empty_Msg_Buffer MESSAGE_TABLE_TYPE; -- Empty Stack used for
22 -- clearing memory
23 -- with Message Stack
24 G_Msg_Count NUMBER := 0; -- Num of Messages on stack
25 G_Msg_Ptr NUMBER := 1; -- Points to next Message
26 -- on stack to retreive.
27 G_Debug_Flag VARCHAR2(1) := 'N'; -- Flag to indicate debug mode
28
29
30 /*--------------------------- PRIVATE ROUTINES ------------------------------*/
31
32 --
33 -- NONE
34 --
35
36 /*---------------------------- PUBLIC ROUTINES ------------------------------*/
37
38 --
39 -- NAME
40 -- Set_Line
41 --
42 -- PURPOSE
43 -- Puts a char string to message stack
44 --
45 PROCEDURE Set_Line(Message_Text IN VARCHAR2) IS
46 begin
47 --
48 -- If the number of messages is greater than 1000, don't store
49 -- an more messages. This could be removed, but developer's
50 -- could potentially use up all their process memory if they store
51 -- thousands and thousands of messages.
52 --
53 if (G_Msg_Count > 1000) then
54 return;
55 end if;
56 --
57 -- Increment message count, and put message on the stack.
58 --
59 G_Msg_Count := G_Msg_Count + 1;
60 G_Message_Buffer(G_Msg_Count) := Message_Text;
61 end;
62
63 --
64 -- NAME
65 -- Get
66 --
67 -- PURPOSE
68 -- Retrieves the next message on the message stack into
69 -- Message_Buffer.
70 --
71 -- When no message is retrieved, Status is set to 0.
72 -- When a message is retreived, Status is set to the length
73 -- of the message.
74 --
75 PROCEDURE Get(Message_Line OUT VARCHAR2,
76 Status OUT NUMBER) IS
77 begin
78 if ( (G_Msg_Ptr > G_Msg_Count)
79 or (G_Msg_Count = 0)) then
80 Status := 0;
81 Clear;
82 else
83 Message_Line := G_Message_Buffer(G_Msg_Ptr);
84 Status := LengthB(G_Message_Buffer(G_Msg_Ptr));
85 G_Msg_Ptr := G_Msg_Ptr + 1;
86 end if;
87 end;
88
89 --
90 -- NAME
91 -- Get
92 --
93 -- NOTES
94 -- Ten arguments were added to improve network performance.
95 --
96 PROCEDURE Get(Msg_Line1 OUT VARCHAR2,
97 Msg_Line2 OUT VARCHAR2,
98 Msg_Line3 OUT VARCHAR2,
99 Msg_Line4 OUT VARCHAR2,
100 Msg_Line5 OUT VARCHAR2,
101 Msg_Line6 OUT VARCHAR2,
102 Msg_Line7 OUT VARCHAR2,
103 Msg_Line8 OUT VARCHAR2,
104 Msg_Line9 OUT VARCHAR2,
105 Msg_Line10 OUT VARCHAR2,
106 Cnt OUT NUMBER) IS
107 Status NUMBER;
108 begin
109 Get(Msg_Line1, Status);
110 if (Status = 0) then Cnt := 0; return; end if;
111 Get(Msg_Line2, Status);
112 if (Status = 0) then Cnt := 1; return; end if;
113 Get(Msg_Line3, Status);
114 if (Status = 0) then Cnt := 2; return; end if;
115 Get(Msg_Line4, Status);
116 if (Status = 0) then Cnt := 3; return; end if;
117 Get(Msg_Line5, Status);
118 if (Status = 0) then Cnt := 4; return; end if;
119 Get(Msg_Line6, Status);
120 if (Status = 0) then Cnt := 5; return; end if;
121 Get(Msg_Line7, Status);
122 if (Status = 0) then Cnt := 6; return; end if;
123 Get(Msg_Line8, Status);
124 if (Status = 0) then Cnt := 7; return; end if;
125 Get(Msg_Line9, Status);
126 if (Status = 0) then Cnt := 8; return; end if;
127 Get(Msg_Line10, Status);
128 if (Status = 0) then Cnt := 9; else Cnt := 10; end if;
129 end;
130
131 --
132 -- NAME
133 -- Clear
134 --
135 -- PURPOSE
136 -- Frees memory used the the message stack and resets the
137 -- the Message Stack counter and pointer variables.
138 --
139 PROCEDURE Clear IS
140 begin
141 G_Message_Buffer := G_Empty_Msg_Buffer;
142 G_Msg_Count := 0;
143 G_Msg_Ptr := 1;
144 end;
145
146
147 FUNCTION Message_Count Return NUMBER IS
148 begin
149 Return(G_Msg_Count);
150 end;
151
152 END OE_DBG;