MINI MINI MANI MO
Rem
Rem $Header: sdo/admin/sdoobjtrkrh.sql /main/10 2017/11/13 14:38:06 cfreiwal Exp $
Rem
Rem sdoobjtrkrh.sql
Rem
Rem Copyright (c) 2014, 2017, Oracle and/or its affiliates.
Rem All rights reserved.
Rem
Rem NAME
Rem sdoobjtrkrh.sql - Spatial Data OBJect TRacKeR Header file
Rem
Rem DESCRIPTION
Rem Header file for the object tracker package
Rem
Rem NOTES
Rem
Rem BEGIN SQL_FILE_METADATA
Rem SQL_SOURCE_FILE: sdo/admin/sdoobjtrkrh.sql
Rem SQL_SHIPPED_FILE: md/admin/sdoobjtrkrh.sql
Rem SQL_PHASE: SDOOBJTRKRH
Rem SQL_STARTUP_MODE: NORMAL
Rem SQL_IGNORABLE_ERRORS: NONE
Rem SQL_CALLING_FILE: sdo/admin/sdoobjtrkrh.sql
Rem END SQL_FILE_METADATA
Rem
Rem MODIFIED (MM/DD/YY)
Rem rjanders 10/08/17 - Add MDSYS to spatial type
Rem cfreiwal 09/15/17 - add coordinates to notification message
Rem sravada 07/25/17 - remove the type drops
Rem rjanders 05/10/17 - #26037683: Raise 'when other' exceptions
Rem rjanders 03/23/17 - #25437999: Remove 'when others then NULL'
Rem handlers
Rem sravada 08/05/16 - XbranchMerge sravada_bug-24341766 from
Rem st_sdo_12.2.0.1.0
Rem czechar 08/14/15 - add SQL file metadata
Rem bbamba 05/07/14 - LRG 11755990
Rem bbamba 03/10/14 - Created
Rem
@@?/rdbms/admin/sqlsessstart.sql
Create or Replace library ORDMD_OT_LIBS TRUSTED as STATIC;
/
-- In the tracker rewrite, these types exist but have different structures
-- if they exist in the DB, drop them so they can be redefined below
declare
object_not_found exception;
pragma exception_init(object_not_found, -04043);
begin
begin
execute immediate 'DROP TYPE tracker_msg FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.location_msg FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.location_msg_arr FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.location_msg_pkd FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.proc_msg FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.proc_msg_arr FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.proc_msg_pkd FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP TYPE MDSYS.notification_msg FORCE';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
begin
execute immediate 'DROP PACKAGE MDSYS.sdo_trkr';
exception
when object_not_found then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE ||')4]: ' || SQLERRM); RAISE;
end;
end;
/
-- tracker_msg(objectId, regionId, operation)
--
-- operation:
-- 'I' issue notification msgs when the object is "Inside" the region
-- 'O' issue notification msgs when the object is "Outside" the region
-- 'T' only issue a notification msg when the object "Transitions" from
-- inside to outside of the region or from outside to inside of the
-- region.
-- 'D' Disable tracking of the object in this region
--
-- The 'I', 'O' operation codes directly set the alert_when field in the
-- *_tracking_regions table. 'T' will initially set the alert_when field to
-- 'TU' Trasition, state unknown. After the first location message is
-- processed the value cycles between 'TI' Transition INTO a region or
-- 'TO' Transistion OUTOF region. The 'D' operation deletes the row described
-- by the object_id/region_id pair from the *_tracking_regions table.
--
-- Any other, invalid, operations passed are converted to 'TU' IF the
-- the object_id/region_id pair is valid. If the objec_id/region_id pair is
-- not valid the entire tracking message is ignored.
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
'Create or Replace Type tracker_msg as object (
object_id INTEGER,
region_id INTEGER,
operation VARCHAR2(2)) ';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 1]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym tracker_msg for mdsys.tracker_msg;
Grant execute on tracker_msg to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type location_msg as object (
object_id INTEGER,
time TIMESTAMP,
x NUMBER,
y NUMBER) ';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 2]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym location_msg for mdsys.location_msg;
Grant execute on location_msg to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type location_msg_arr as
VARRAY(1000) of location_msg';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 3]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym location_msg_arr for mdsys.location_msg_arr;
Grant execute on location_msg_arr to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type location_msg_pkd as
object(arr location_msg_arr)' ;
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 4]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym location_msg_pkd for mdsys.location_msg_pkd;
Grant execute on location_msg_pkd to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type proc_msg as object (
object_id INTEGER,
time TIMESTAMP,
x NUMBER,
y NUMBER,
region_id INTEGER,
alert_when VARCHAR2(2))';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 4]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym proc_msg for mdsys.proc_msg;
Grant execute on proc_msg to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type proc_msg_arr as VARRAY(1000) of proc_msg';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 5]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym proc_msg_arr for mdsys.proc_msg_arr;
Grant execute on proc_msg_arr to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type proc_msg_pkd as object(arr proc_msg_arr)';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 6]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym proc_msg_pkd for mdsys.proc_msg_pkd;
Grant execute on proc_msg_pkd to public;
declare
dependent_objects exception;
pragma exception_init(dependent_objects, -02303);
begin
begin
execute immediate
' Create or Replace Type notification_msg as object (
object_id INTEGER,
region_id INTEGER,
time TIMESTAMP,
x NUMBER,
y NUMBER,
state VARCHAR2(8))';
exception
when dependent_objects then NULL;
when others then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'EXCEPTION[sdoobjtrkrh.sql(' || $$PLSQL_LINE || ') 7]: ' || SQLERRM); RAISE;
end;
end;
/
show errors;
Create or Replace public synonym notification_msg for mdsys.notification_msg;
Grant execute on notification_msg to public;
Create or Replace Package MDSYS.sdo_trkr AUTHID current_user
AS
Procedure create_tracking_set(tracking_set_name IN VARCHAR2,
num_trkr_queues IN INTEGER DEFAULT 4,
num_loc_queues IN INTEGER DEFAULT 1);
Procedure start_tracking_set(tracking_set_name IN VARCHAR2);
Procedure stop_tracking_set(tracking_set_name IN VARCHAR2);
Procedure drop_tracking_set(tracking_set_name IN VARCHAR2);
Procedure run_loc_deq(tracking_set_name IN VARCHAR2,
qNo IN INTEGER,
num_trkr_queues IN INTEGER);
Procedure run_trkr_deq(tracking_set_name IN VARCHAR2,
qNo IN INTEGER,
num_trkr_queues IN INTEGER);
Procedure get_notification_msg(tracking_set_name IN VARCHAR2,
deq_wait IN INTEGER DEFAULT DBMS_AQ.NO_WAIT,
message OUT MDSYS.NOTIFICATION_MSG);
Procedure send_tracking_msg(tracking_set_name IN VARCHAR2,
tracking_msg IN MDSYS.TRACKER_MSG);
Procedure send_location_msgs(tracking_set_name IN VARCHAR2,
location_msgs IN MDSYS.LOCATION_MSG_ARR);
END sdo_trkr;
/
show errors;
@?/rdbms/admin/sqlsessend.sql
OHA YOOOO