[Home] [Help]
PACKAGE BODY: APPS.FND_CP_GSM_IPC
Source
1 PACKAGE BODY fnd_cp_gsm_ipc AS
2 /* $Header: AFCPSMIB.pls 120.3.12000000.3 2007/11/02 15:53:45 ckclark ship $ */
3
4
5
6 --=========================================================================--
7 /* Private Functions */
8 --=========================================================================--
9 P_Applsys_Schema varchar2(30) := NULL;
10
11 Function Q_Schema return Varchar2 is
12
13 pragma AUTONOMOUS_TRANSACTION;
14
15 begin
16
17 if (P_Applsys_Schema is null) then
18 Select TEXT
19 into P_Applsys_Schema
20 from WF_RESOURCES
21 where TYPE = 'WFTKN'
22 and NAME = 'WF_SCHEMA'
23 and rownum = 1;
24 end if;
25
26 commit;
27 return(P_Applsys_Schema);
28
29 exception
30 when OTHERS then
31 rollback;
32 end;
33
34 --=========================================================================--
35 /* ICM Functions */
36 --=========================================================================--
37
38 /*--------------------------------------------------------------------------
39 procedure Unsubscribe -unsub from AQ. Null -> unsub all
40 -----------------------------------------------------------------------------*/
41
42 procedure Unsubscribe(cpid in number default null) is
43
44 sql_stmt varchar2(2000);
45
46 pragma AUTONOMOUS_TRANSACTION;
47
48 Begin
49 if cpid is not null then
50 DBMS_AQADM.REMOVE_SUBSCRIBER(queue_name =>Q_Schema||'.FND_CP_GSM_IPC_AQ',
51 subscriber => sys.aq$_agent('FNDCPGSMIPC_Cartridge_'||to_char(cpid),
52 NULL, NULL));
53
54 DBMS_AQADM.REMOVE_SUBSCRIBER(queue_name =>Q_Schema||'.FND_CP_GSM_IPC_AQ',
55 subscriber => sys.aq$_agent('FNDCPGSMIPC_Service_'||to_char(cpid),
56 NULL, NULL));
57 else
58 sql_stmt := 'declare ';
59
60 sql_stmt := sql_stmt || 'CURSOR C1 is select NAME name ';
61 sql_stmt := sql_stmt || ' from '||Q_Schema||'.aq$FND_CP_GSM_IPC_AQTBL_S ';
62 sql_stmt := sql_stmt || ' where QUEUE=''FND_CP_GSM_IPC_AQ'';';
63
64 sql_stmt := sql_stmt || ' begin ';
65 sql_stmt := sql_stmt || ' for c1rec in c1 loop ';
66
67 sql_stmt := sql_stmt || 'DBMS_AQADM.REMOVE_SUBSCRIBER(queue_name => ''';
68 sql_stmt := sql_stmt || Q_Schema || '.FND_CP_GSM_IPC_AQ'', ';
69 sql_stmt := sql_stmt || 'subscriber=>sys.aq$_agent(c1rec.name,NULL,NULL));';
70
71 sql_stmt := sql_stmt || ' end loop; ';
72 sql_stmt := sql_stmt || ' end;';
73
74 EXECUTE IMMEDIATE sql_stmt ;
75 end if;
76
77 commit;
78
79 Exception
80 when others then null;
81 rollback;
82 end;
83
84
85 --=========================================================================-
86 /* Cartridge Functions */
87 --=========================================================================--
88
89 /*--------------------------------------------------------------------------
90 procedure Init_Cartridge
91 -----------------------------------------------------------------------------*/
92
93 procedure Init_Cartridge is
94
95 Not_Done Boolean;
96 PAYLOAD system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
97 dq_opts DBMS_AQ.DEQUEUE_OPTIONS_T;
98 msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
99 msgid raw(16);
100
101 pragma AUTONOMOUS_TRANSACTION;
102
103 Begin
104 /* we should clear expired messages out of exception queue */
105 dq_opts.consumer_name := NULL;
106 dq_opts.DEQUEUE_MODE := DBMS_AQ.REMOVE;
107 dq_opts.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
108 dq_opts.VISIBILITY := DBMS_AQ.ON_COMMIT;
109 dq_opts.WAIT := DBMS_AQ.NO_WAIT;
110 dq_opts.MSGID := NULL;
111
112 Not_Done := TRUE;
113
114 while Not_Done LOOP
115 begin
116 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.AQ$_FND_CP_GSM_IPC_AQTBL_E',
117 DEQUEUE_OPTIONS => dq_opts,
118 MESSAGE_PROPERTIES => msg_props,
119 PAYLOAD => payload,
120 MSGID => msgid);
121 exception when others then Not_Done := FALSE;
122 end;
123 end LOOP;
124
125 commit;
126
127 exception
128 when OTHERS then
129 rollback;
130 raise;
131 End;
132
133 /*--------------------------------------------------------------------------
134 procedure Shutdown_Cartridge
135 -----------------------------------------------------------------------------*/
136
137 procedure Shutdown_Cartridge is
138
139 pragma AUTONOMOUS_TRANSACTION;
140
141 Begin
142 /* Doesn't appear that anything is necessary...but we'll keep the hook */
143 null;
144 commit;
145
146 exception
147 when OTHERS then
148 rollback;
149 raise;
150 End;
151
152 /*--------------------------------------------------------------------------
153 procedure Cartridge_Init_Service
154 -----------------------------------------------------------------------------*/
155
156 procedure Cartridge_Init_Service(cpid in Number,
157 Params in Varchar2,
158 Debug_Level in Varchar2) is
159
160 pragma AUTONOMOUS_TRANSACTION;
161
162 begin
163 DBMS_AQADM.ADD_SUBSCRIBER(queue_name =>Q_Schema||'.FND_CP_GSM_IPC_AQ',
164 subscriber => sys.aq$_agent('FNDCPGSMIPC_Cartridge_'||to_char(cpid),
165 NULL, NULL));
166
167 DBMS_AQADM.ADD_SUBSCRIBER(queue_name =>Q_Schema||'.FND_CP_GSM_IPC_AQ',
168 subscriber => sys.aq$_agent('FNDCPGSMIPC_Service_'||to_char(cpid),
169 NULL, NULL));
170
171 Send_Message(cpid,'Initialize',Params,Debug_Level);
172 Update_Status (cpid, 'Uninitialized');
173 commit;
174
175 exception
176 when OTHERS then
177 rollback;
178 raise;
179 end;
180
181
182
183 /*--------------------------------------------------------------------------
184 Procedure Send_Message:
185
186 Handle = CPID
187 Message -> Stop, Suspend, Resume, Verify, Initialize
188 Payload - Currently only used to send parameters with Verify
189 Debug_Level = One character Debug Level
190 -----------------------------------------------------------------------------*/
191
192 Procedure Send_Message (Handle in Number,
193 Message in Varchar2,
194 Parameters in Varchar2,
195 Debug_Level in Varchar2) is
196
197
198 enq_opts DBMS_AQ.enqueue_options_t;
199 msg_props DBMS_AQ.message_properties_t;
200 msg_id raw(16);
201 msg system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
202 sessionid number;
203
204 pragma AUTONOMOUS_TRANSACTION;
205
206 begin
207 msg := system.FND_CP_GSM_IPQ_AQ_PAYLOAD(
208 Handle,Message,Parameters,Debug_Level);
209
210 enq_opts.visibility := DBMS_AQ.ON_COMMIT;
211 enq_opts.sequence_deviation := NULL;
212 msg_props.delay := DBMS_AQ.NO_DELAY;
213 msg_props.expiration := 365 * 24 * 3600; -- One Year
214 msg_props.recipient_list(1) := sys.aq$_agent(
215 'FNDCPGSMIPC_Service_'||to_char(Handle),NULL, NULL);
216 msg_props.sender_id := sys.aq$_agent(
217 'FNDCPGSMIPC_Cartridge_'||to_char(Handle), NULL, NULL);
218
219 DBMS_AQ.Enqueue( queue_name => Q_Schema||'.FND_CP_GSM_IPC_AQ',
220 enqueue_options => enq_opts,
221 message_properties => msg_props,
222 Payload => msg,
223 msgid => msg_id);
224
225 commit;
226
227 exception
228 when OTHERS then
229 rollback;
230 raise;
231 end;
232
233
234 /*--------------------------------------------------------------------------
235 Function Get_Status:
236
237 Handle = CPID
238 -----------------------------------------------------------------------------*/
239
240 Function Get_Status (Handle in Number) Return Varchar2 is
241
242 Status_code Varchar2(1);
243
244 Begin
245 Select GSM_INTERNAL_STATUS
246 into Status_code
247 from fnd_concurrent_processes
248 where concurrent_process_id = handle;
249
250 return (Status_code);
251 End;
252
253
254 /* No longer used */
255 Function Obsolete_Get_Status (Handle in Number) Return Varchar2 is
256
257 Not_Done Boolean;
258 Status_Name Varchar2(30);
259 Status_code Varchar2(1);
260 More_Flag Varchar2(1);
261 PAYLOAD system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
262 dq_opts DBMS_AQ.DEQUEUE_OPTIONS_T;
263 msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
264 msgid raw(16);
265 last_msg raw(16);
266
267 pragma AUTONOMOUS_TRANSACTION;
268
269 Begin
270 Not_Done := TRUE;
271
272 while (Not_Done) LOOP -- Clear off excess messages
273
274 dq_opts.consumer_name := 'FNDCPGSMIPC_Cartridge_'||to_char(Handle);
275 dq_opts.DEQUEUE_MODE := DBMS_AQ.BROWSE;
276 dq_opts.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
277 dq_opts.VISIBILITY := DBMS_AQ.ON_COMMIT;
278 dq_opts.WAIT := DBMS_AQ.NO_WAIT;
279 dq_opts.MSGID := NULL;
280
281 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
282 DEQUEUE_OPTIONS => dq_opts,
283 MESSAGE_PROPERTIES => msg_props,
284 PAYLOAD => payload,
285 MSGID => msgid);
286
287 last_msg := msgid;
288 Status_Name := PAYLOAD.Message;
289
290 dq_opts.NAVIGATION := DBMS_AQ.NEXT_MESSAGE;
291
292 begin
293 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
294 DEQUEUE_OPTIONS => dq_opts,
295 MESSAGE_PROPERTIES => msg_props,
296 PAYLOAD => payload,
297 MSGID => msgid);
298 exception
299 when others then payload.Message:= null;
300 end;
301
302
303 if (payload.Message is null) then -- No later message
304 Not_Done := FALSE;
305 else -- Kill the first message
306 dq_opts.CORRELATION := Null;
307 dq_opts.MSGID := last_msg;
308 dq_opts.DEQUEUE_MODE := DBMS_AQ.REMOVE_NODATA;
309
310 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
311 DEQUEUE_OPTIONS => dq_opts,
312 MESSAGE_PROPERTIES => msg_props,
313 PAYLOAD => payload,
314 MSGID => msgid);
315 end if;
316 END LOOP;
317
318 if (UPPER(Status_Name) = 'UNINITIALIZED') then
319 Status_Code := 'Z';
320 elsif (UPPER(Status_Name) = 'SUSPENDED') then
321 Status_Code := 'P';
322 elsif (UPPER(Status_Name) = 'RUNNING') then
323 Status_Code := 'A';
324 elsif (UPPER(Status_Name) = 'STOPPED') then
325 Status_Code := 'S';
326 else -- No Perfect answer, best to assume its Running
327 Status_Code := 'A';
328 end if;
329
330 commit;
331 return (Status_code);
332
333 exception
334 when OTHERS then
335 rollback;
336 End;
337
338 --=========================================================================--
339 /* Routines called Externally */
340 --=========================================================================--
341
342
343 /*--------------------------------------------------------------------------
344 Procedure Send_Custom_Message:
345
346 Handle = CPID
347 Type - 8 characters for identifying format
348 Message - Currently only used to send parameters with Verify
349 -----------------------------------------------------------------------------*/
350
351
352 Procedure Send_Custom_Message (Handle in Number,
353 Type in varchar2,
354 Mesg in Varchar2) is
355 pragma AUTONOMOUS_TRANSACTION;
356
357 begin
358 Send_Message (Handle, 'Custom:' || substr(Type,1,8), Mesg, Null);
359 commit;
360
361 exception
362 when OTHERS then
363 rollback;
364 raise;
365 end;
366
367 --=========================================================================--
368 /* Routines called by Service */
369 --=========================================================================--
370
371 /*--------------------------------------------------------------------------
372 Procedure Init_Service:
373
374 Init_Service:
375 Handle = CPID
376 Parameters = Initial Parameter String
377 Debug_Level = One character Debug Level
378 -----------------------------------------------------------------------------*/
379
380 Procedure Init_Service (Handle in Number,
381 Parameters out NOCOPY Varchar2,
382 Debug_Level out NOCOPY Varchar2) is
383
384
385 mesg Varchar2(2048);
386 success_f Varchar2(1);
387 more_f Varchar2(1);
388
389 s_id number;
390 p_id number;
391 osp_id v$process.spid%TYPE := Null;
392 sqlnet_str varchar2(30) := Null;
393 service_name varchar2(30) := Null;
394 que_rcg varchar2(32) := Null;
395 old_rcg varchar2(32);
396 etrace varchar2(4) := Null;
397 diag_level char := Null;
398 sql_stmt VARCHAR2(200) := null;
399 PAYLOAD system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
400 dq_opts DBMS_AQ.DEQUEUE_OPTIONS_T;
401 msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
402 msgid raw(16);
403
404 pragma AUTONOMOUS_TRANSACTION;
405
406 begin
407 Update_Status ( Handle, 'Running');
408
409 dq_opts.consumer_name := 'FNDCPGSMIPC_Service_'|| to_char(Handle);
410 dq_opts.DEQUEUE_MODE := DBMS_AQ.REMOVE;
411 dq_opts.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
412 dq_opts.VISIBILITY := DBMS_AQ.IMMEDIATE;
413 dq_opts.WAIT := DBMS_AQ.FOREVER;
414 dq_opts.MSGID := NULL;
415
416 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
417 DEQUEUE_OPTIONS => dq_opts,
418 MESSAGE_PROPERTIES => msg_props,
419 PAYLOAD => payload,
420 MSGID => msgid);
421
422 Parameters := payload.Payload;
423 mesg := payload.Message;
424 Debug_Level := payload.Debug_Level;
425
426 SELECT PID, SPID, S.AUDSID
427 INTO p_id, osp_id, s_id
428 FROM V$PROCESS P, V$SESSION S
429 WHERE S.AUDSID = USERENV('SESSIONID')
430 AND P.Addr = S.Paddr
431 and rownum <= 1; /* Probably not necessary */
432
433 /* 5867853- Make sure the fcp row for services, like that of FNDSM
434 * and managers, is storing TWO_TASK into SQLNET_STRING. The value
435 * selected here is only important if PCP DB Instance failover is on,
436 * in which case TWO_TASK is required to match the instance name.
437 * Thus, the FNDSM TWO_TASK in SQLNET_STRING will be < 17 characters
438 * and could fit in db_instance column.
439 */
440
441 select decode(sign(length(sqlnet_string) - 17), -1, sqlnet_string, null)
442 INTO sqlnet_str
443 FROM FND_CONCURRENT_PROCESSES
444 WHERE MANAGER_TYPE = 6
445 AND UPPER(NODE_NAME) = (select upper(node_name)
446 from fnd_concurrent_processes
447 where concurrent_process_id = Handle)
448 AND PROCESS_STATUS_CODE = 'A';
449
450 /* 5867853- Update DB_INSTANCE and SQLNET_STRING for services */
451 UPDATE FND_CONCURRENT_PROCESSES
452 set SESSION_ID = s_id,
453 ORACLE_PROCESS_ID = p_id,
454 OS_PROCESS_ID = osp_id,
455 INSTANCE_NUMBER = (Select instance_number from v$instance),
459 last_updated_by = 4
456 DB_INSTANCE = (Select instance_name from v$instance),
457 SQLNET_STRING = sqlnet_str,
458 last_update_date = sysdate,
460 where CONCURRENT_PROCESS_ID = Handle;
461
462 select Concurrent_Queue_Name, Resource_Consumer_Group, Diagnostic_level
463 into service_name, que_rcg, diag_level
464 from Fnd_Concurrent_Queues Q, Fnd_Concurrent_processes P
465 WHERE Q.Application_ID = P.Queue_Application_ID
466 And Q.Concurrent_queue_ID = P.Concurrent_Queue_ID
467 And P.Concurrent_Process_Id = Handle;
468
469 -- Until we add explicit support for TRACE ON/OFF
470
471 if (diag_level in ('Y', '1', '2', '3')) then
472 etrace := 'TRUE';
473 end if;
474
475 -- FND_CTL.FND_SESS_CTL(Null, Null, etrace, Null, Null, Null);
476 if etrace is not null then
477 sql_stmt := 'ALTER SESSION SET SQL_TRACE = '|| etrace;
478 EXECUTE IMMEDIATE sql_stmt ;
479 end if;
480
481 dbms_application_info.set_module(service_name,
482 'Service Management');
483
484 if que_rcg is null then
485 que_rcg := 'DEFAULT_CONSUMER_GROUP';
486 end if;
487
488 begin
489 dbms_session.switch_current_consumer_group(que_rcg, old_rcg, false);
490 exception
491 when others then null;
492 end;
493
494 commit;
495
496 exception
497 when OTHERS then
498 rollback;
499 raise;
500 end;
501
502 /*--------------------------------------------------------------------------
503 Procedure Get_Message:
504
505 Handle = CPID
506 Message -> Stop, Suspend, Resume, Verify, Initialize (Internal)
507 Parameters - Currently only used to send parameters with Verify
508 Debug_Level - One character Debug Level
509 Blocking_Flag = Y/N do we wait?
510 Consume_Flag = Y/N do we consume message?
511 More_Flag = Y/N more messages on AQ?
512 Message_Wait_Timeout = Timeout to use when waiting on AQ for msg.
513 Used for both blocking and non blocking calls. Null= nowait
514 Blocking_Sleep_Time = Only meaningful if blocking_flag = 'Y'. How
515 many secs to sleep between looking for messages.
516 -----------------------------------------------------------------------------*/
517
518 Procedure Get_Message ( Handle in Number,
519 Message out NOCOPY Varchar2,
520 Parameters out NOCOPY Varchar2,
521 Debug_Level out NOCOPY Varchar2,
522 Blocking_Flag in Varchar2,
523 Consume_Flag in Varchar2,
524 Success_Flag out NOCOPY Varchar2,
525 More_Flag out NOCOPY Varchar2,
526 Message_Wait_Timeout in number default Null,
527 Blocking_Sleep_Time in number default 30) is
528
529 Not_Done boolean;
530 payload system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
531 dq_opts DBMS_AQ.DEQUEUE_OPTIONS_T;
532 msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
533 msgid raw(16);
534
535
536 pragma AUTONOMOUS_TRANSACTION;
537
538 Begin
539 payload := system.FND_CP_GSM_IPQ_AQ_PAYLOAD(NULL,NULL,NULL,NULL);
540
541 Not_Done := TRUE;
542
543 if (Consume_Flag = 'Y') then
544 dq_opts.DEQUEUE_MODE := DBMS_AQ.REMOVE;
545 else
546 dq_opts.DEQUEUE_MODE := DBMS_AQ.BROWSE;
547 end if;
548
549 dq_opts.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
550 dq_opts.VISIBILITY := DBMS_AQ.IMMEDIATE;
551
552 if (Message_Wait_Timeout is null) then
553 dq_opts.WAIT := DBMS_AQ.NO_WAIT;
554 else
555 dq_opts.WAIT := Message_Wait_Timeout;
556 end if;
557
558 dq_opts.MSGID := NULL;
559 dq_opts.consumer_name := 'FNDCPGSMIPC_Service_'||to_char(Handle);
560
561 while (Not_Done) LOOP
562 begin
563 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
564 DEQUEUE_OPTIONS => dq_opts,
565 MESSAGE_PROPERTIES => msg_props,
566 PAYLOAD => payload,
567 MSGID => msgid);
568 exception
569 when others then payload.Message:= null;
570 end;
571
572 Parameters := payload.Payload;
573 Message := payload.Message;
574 Debug_Level := payload.Debug_Level;
575
576 if (Message is null) then
577 Success_Flag := 'N';
578 else
579 Success_Flag := 'Y';
580 end if;
581
582 if (Blocking_Flag = 'N') or (Success_Flag = 'Y') then
583 Not_Done := FALSE;
584 else
585 dbms_lock.sleep(Blocking_Sleep_Time);
586 end if;
587
588 END LOOP;
589
590 /* set more flag */
591
592 dq_opts.DEQUEUE_MODE := DBMS_AQ.BROWSE;
593 dq_opts.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;
594 dq_opts.VISIBILITY := DBMS_AQ.IMMEDIATE;
595 dq_opts.WAIT := DBMS_AQ.NO_WAIT;
596
597 begin
598 DBMS_AQ.DEQUEUE(QUEUE_NAME=>Q_Schema||'.FND_CP_GSM_IPC_AQ',
599 DEQUEUE_OPTIONS => dq_opts,
600 MESSAGE_PROPERTIES => msg_props,
601 PAYLOAD => payload,
602 MSGID => msgid);
603 exception
604 when others then payload.Message:= null;
605 end;
606
607 if payload.Message is null then
608 more_flag := 'N';
609 else
610 more_flag := 'Y';
611 end if;
612
613 commit;
614
615 exception
616 when OTHERS then
617 rollback;
618 raise;
619 End;
620
621 /* Messages */
622
623 Function MSG_Stop return varchar2 is begin return('Stop'); end;
624 Function MSG_Suspend return varchar2 is begin return('Suspend'); end;
625 Function MSG_Resume return varchar2 is begin return('Resume'); end;
626 Function MSG_Verify return varchar2 is begin return('Verify'); end;
627 Function MSG_Custom return varchar2 is begin return('Custom'); end;
628
629 /*--------------------------------------------------------------------------
630 Procedure Update_Status:
631
632 Handle = CPID
633 Status is one of: Running, Stopped, Suspended,
634 Uninitialized (for FND Use only)
635 -----------------------------------------------------------------------------*/
636
637 Procedure Update_Status ( Handle in Number,
638 Status in Varchar2) is
639
640 Status_Code varchar2(1);
641
642 pragma AUTONOMOUS_TRANSACTION;
643
644 Begin
645 if (UPPER(Status) = 'UNINITIALIZED') then
646 Status_Code := 'Z';
647 elsif (UPPER(Status) = 'SUSPENDED') then
648 Status_Code := 'P';
649 elsif (UPPER(Status) = 'RUNNING') then
650 Status_Code := 'A';
651 elsif (UPPER(Status) = 'STOPPED') then
652 Status_Code := 'S';
653 else -- No Perfect answer, best to assume its Running
654 Status_Code := 'A';
655 end if;
656
657 Update FND_CONCURRENT_PROCESSES
658 Set GSM_INTERNAL_STATUS = Status_Code
659 where CONCURRENT_PROCESS_ID = Handle;
660
661 commit;
662
663 exception
664 when OTHERS then
665 rollback;
666 raise;
667 end;
668
669 /*--------------------------------------------------------------------------
670 Procedure Update_Status_and_Info:
671
672 Handle = CPID
673 Status is one of: Running, Stopped, Suspended,
674 Uninitialized (for FND Use only)
675 Info is for service developer use.
676 -----------------------------------------------------------------------------*/
677
678 Procedure Update_Status_and_Info ( Handle in Number,
679 Status in Varchar2,
680 Info in Varchar2) is
681
682 Status_Code varchar2(1);
683
684 pragma AUTONOMOUS_TRANSACTION;
685
686 Begin
687 if (UPPER(Status) = 'UNINITIALIZED') then
688 Status_Code := 'Z';
689 elsif (UPPER(Status) = 'SUSPENDED') then
690 Status_Code := 'P';
691 elsif (UPPER(Status) = 'RUNNING') then
692 Status_Code := 'A';
693 elsif (UPPER(Status) = 'STOPPED') then
694 Status_Code := 'S';
695 else -- No Perfect answer, best to assume its Running
696 Status_Code := 'A';
697 end if;
698
699 Update FND_CONCURRENT_PROCESSES
700 Set GSM_INTERNAL_STATUS = Status_Code,
701 GSM_INTERNAL_INFO = Info
702 where CONCURRENT_PROCESS_ID = Handle;
703
704 commit;
705
706 exception
707 when OTHERS then
708 rollback;
709 raise;
710 end;
711
712 /* No longer used */
713 Procedure obsolete_Update_Status ( Handle in Number,
714 Status in Varchar2) is
715
716 msg_props dbms_aq.message_properties_t;
717 enq_opts dbms_aq.enqueue_options_t;
718 msg system.FND_CP_GSM_IPQ_AQ_PAYLOAD;
719 msg_id raw(16);
720
721 pragma AUTONOMOUS_TRANSACTION;
722
723 Begin
727 enq_opts.sequence_deviation := NULL;
724 msg := system.FND_CP_GSM_IPQ_AQ_PAYLOAD(Handle, Status, NULL, NULL);
725
726 enq_opts.visibility := DBMS_AQ.IMMEDIATE;
728
729 msg_props.delay := DBMS_AQ.NO_DELAY;
730 msg_props.expiration := 365 * 24 * 3600; -- One Year
731 msg_props.recipient_list(1) :=sys.aq$_agent(
732 'FNDCPGSMIPC_Cartridge_'||to_char(Handle),NULL,NULL);
733 msg_props.sender_id := sys.aq$_agent(
734 'FNDCPGSMIPC_Service_'||to_char(Handle), NULL, NULL);
735
736 DBMS_AQ.Enqueue( queue_name => Q_Schema||'.FND_CP_GSM_IPC_AQ',
737 enqueue_options => enq_opts,
738 message_properties => msg_props,
739 Payload => msg,
740 msgid => msg_id);
741
742
743 Commit;
744
745 exception
746 when OTHERS then
747 rollback;
748 End;
749
750 /* Statuses */
751
752 Function Status_Running return varchar2 is begin return('Running'); end;
753 Function Status_Stopped return varchar2 is begin return('Stopped'); end;
754 Function Status_Suspended return varchar2 is begin return('Suspended'); end;
755
756 END fnd_cp_gsm_ipc;