11:
12: --
13: -- Private variables
14: --
15: P_DEBUG varchar2(1) := FNDCP_TMSRV.DBG_OFF;
16: P_R_PIPE varchar2(30) := null;
17: P_T_PIPE varchar2(30) := null;
18:
19:
27:
28: P_T_PIPE := FNDCPTP || qid;
29: P_R_PIPE := FNDCPRP || qid;
30:
31: e_code := FNDCP_TMSRV.E_SUCCESS;
32:
33: end initialize;
34:
35:
36:
37: procedure set_debug(dbgtype in varchar2) is
38: begin
39: P_DEBUG := dbgtype;
40: FNDCP_TMSRV.P_DEBUG := dbgtype;
41: end set_debug;
42:
43:
44: --
50:
51: e_code number;
52:
53: begin
54: dbms_pipe.pack_message ( FNDCP_TMSRV.PK_TKN);
55: e_code := dbms_pipe.send_message (P_T_PIPE);
56: end put_token;
57:
58:
65: e_code number;
66:
67: begin
68: e_code := dbms_pipe.receive_message (P_T_PIPE, 0);
69: if (e_code = FNDCP_TMSRV.E_SUCCESS) then
70: dbms_pipe.reset_buffer;
71: end if;
72: end take_token;
73:
124: -- Read wait R_pipe.
125: e_code := dbms_pipe.receive_message (P_R_PIPE, timeout);
126:
127: -- If timed out or other error, return
128: if (e_code > FNDCP_TMSRV.E_SUCCESS) then
129: take_token;
130: return;
131: end if;
132:
131: end if;
132:
133: -- If packet type is not a Transaction request, return.
134: dbms_pipe.unpack_message (pktyp);
135: if (pktyp not in (FNDCP_TMSRV.PK_TRN, FNDCP_TMSRV.PK_TRN_D1, FNDCP_TMSRV.PK_TRN_D2)) then
136: take_token;
137: return;
138: end if;
139:
225:
226: <
227:
228:
229: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
230: fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
231: 'Unpacked request details', NULL, 'M');
232:
233: end if;
226: <
227:
228:
229: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
230: fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
231: 'Unpacked request details', NULL, 'M');
232:
233: end if;
234:
236:
237: sql_stmt := 'ALTER SESSION SET SQL_TRACE = '|| enable_trace;
238: EXECUTE IMMEDIATE sql_stmt ;
239:
240: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
241: fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
242: 'SQL_TRACE:', enable_trace, 'M');
243:
244: end if;
237: sql_stmt := 'ALTER SESSION SET SQL_TRACE = '|| enable_trace;
238: EXECUTE IMMEDIATE sql_stmt ;
239:
240: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
241: fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
242: 'SQL_TRACE:', enable_trace, 'M');
243:
244: end if;
245: return;
245: return;
246:
247: exception
248: when others then
249: fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
250: 'EXCEPTION', sqlerrm, 'M');
251: end read_message;
252:
253:
259: outcome in varchar2,
260: message in varchar2) is
261:
262: begin
263: e_code := FNDCP_TMSRV.E_SUCCESS;
264:
265: dbms_pipe.reset_buffer;
266:
267: dbms_pipe.pack_message (pktyp);
266:
267: dbms_pipe.pack_message (pktyp);
268:
269: -- Pack reply only if it's a valid reply
270: if (pktyp = FNDCP_TMSRV.PK_REP) then
271: dbms_pipe.pack_message (reqid);
272: dbms_pipe.pack_message (outcome);
273: dbms_pipe.pack_message (message);
274: for i in 1..FNDCP_TMSRV.P_RETVALCOUNT loop
270: if (pktyp = FNDCP_TMSRV.PK_REP) then
271: dbms_pipe.pack_message (reqid);
272: dbms_pipe.pack_message (outcome);
273: dbms_pipe.pack_message (message);
274: for i in 1..FNDCP_TMSRV.P_RETVALCOUNT loop
275: dbms_pipe.pack_message (FNDCP_TMSRV.P_RETURN_VALS (i));
276: end loop;
277: end if;
278:
271: dbms_pipe.pack_message (reqid);
272: dbms_pipe.pack_message (outcome);
273: dbms_pipe.pack_message (message);
274: for i in 1..FNDCP_TMSRV.P_RETVALCOUNT loop
275: dbms_pipe.pack_message (FNDCP_TMSRV.P_RETURN_VALS (i));
276: end loop;
277: end if;
278:
279: FNDCP_TMSRV.P_RETVALCOUNT := 0; -- Reset the return values table.
275: dbms_pipe.pack_message (FNDCP_TMSRV.P_RETURN_VALS (i));
276: end loop;
277: end if;
278:
279: FNDCP_TMSRV.P_RETVALCOUNT := 0; -- Reset the return values table.
280:
281: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
282: fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
283: 'Packing return message' ,
277: end if;
278:
279: FNDCP_TMSRV.P_RETVALCOUNT := 0; -- Reset the return values table.
280:
281: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
282: fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
283: 'Packing return message' ,
284: NULL, 'S');
285:
278:
279: FNDCP_TMSRV.P_RETVALCOUNT := 0; -- Reset the return values table.
280:
281: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
282: fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
283: 'Packing return message' ,
284: NULL, 'S');
285:
286: end if;
286: end if;
287:
288: e_code := dbms_pipe.send_message (return_id);
289:
290: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
291: fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
292: 'Sent Message' ,
293: NULL, 'S');
294:
287:
288: e_code := dbms_pipe.send_message (return_id);
289:
290: if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
291: fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
292: 'Sent Message' ,
293: NULL, 'S');
294:
295: end if;
294:
295: end if;
296:
297: -- Turn off debug.
298: set_debug(FNDCP_TMSRV.DBG_OFF);
299:
300: end write_message;
301:
302: