---------------------------------------------- 创建oracle字符数组类型 added by wyk 2018-07-26--------------------------------------------CREATEORREPLACETYPE VARCHAR_ARRAY ISTABLEOF VARCHAR2(40);/-------------------------------------------------- 创建挖掘涉黑人员亲密度关系函数 added by wyk 2018-07-26------------------------------------------------CREATEORREPLACEFUNCTION FUNC_DIG_SHEHEI_PERSON(SFZH_IN IN VARCHAR2)RETURN VARCHAR_ARRAY AS
SFZHARR VARCHAR_ARRAY;BEGIN
SFZHARR := VARCHAR_ARRAY();
SFZHARR := FUNC_DIG_SHEHEI_PERSON_TEMP(SFZH_IN,SFZHARR);IF SFZHARR.COUNT >0THENFOR I IN SFZHARR.FIRST..SFZHARR.LASTLOOPIF SFZHARR(I)= SFZH_IN THEN SFZHARR.DELETE(I);ENDIF;ENDLOOP;ENDIF;RETURN SFZHARR;END FUNC_DIG_SHEHEI_PERSON;/------------------------------------------------------------------ 创建挖掘涉黑人员亲密度关系函数(主函数,用来递归挖掘) added by wyk 2018-07-26----------------------------------------------------------------CREATEORREPLACEFUNCTION FUNC_DIG_SHEHEI_PERSON_TEMP(SFZH_IN IN VARCHAR2,SFZHARR IN VARCHAR_ARRAY)RETURN VARCHAR_ARRAY
AS
NUM NUMBER;
INDEX_ARR NUMBER;
SFZHARR_COPY VARCHAR_ARRAY;BEGIN
INDEX_ARR :=0;
SFZHARR_COPY := SFZHARR;DECLARECURSOR RELATE_SFZHS ISSELECTDISTINCT(SFZH)FROM PERSON_SAXX WHERE SAXX_JYAQ IN(SELECT SAXX_JYAQ FROM PERSON_SAXX WHERE SFZH = SFZH_IN)AND SFZH != SFZH_IN;
RELATE_SFZH VARCHAR2(20);BEGINIFNOT RELATE_SFZHS%ISOPEN THENOPEN RELATE_SFZHS;ENDIF;FETCH RELATE_SFZHS INTO RELATE_SFZH;WHILE RELATE_SFZHS%FOUND
LOOP
NUM :=0;IF SFZHARR_COPY.COUNT >0THENFOR I IN SFZHARR_COPY.FIRST..SFZHARR_COPY.LASTLOOPIF SFZHARR_COPY(I)= RELATE_SFZH THEN
NUM :=1;ENDIF;ENDLOOP;ENDIF;IF NUM =0THENIF SFZHARR_COPY.COUNT =0THEN
SFZHARR_COPY.EXTEND(1);SFZHARR_COPY(1) := RELATE_SFZH;ELSE
INDEX_ARR := SFZHARR_COPY.COUNT+1;
SFZHARR_COPY.EXTEND(1);
SFZHARR_COPY(INDEX_ARR) := RELATE_SFZH;ENDIF;
SFZHARR_COPY := FUNC_DIG_SHEHEI_PERSON_TEMP(RELATE_SFZH,SFZHARR_COPY);ENDIF;FETCH RELATE_SFZHS INTO RELATE_SFZH;ENDLOOP;CLOSE RELATE_SFZHS;END;RETURN SFZHARR_COPY;END;
根据区域经纬度范围查询范围内警情信息,并将关联信息存入关联表
------------------------------------------------------------------ 治安乱点区域关联警情存储过程 added by wyk 2018-09-17----------------------------------------------------------------CREATEORREPLACEPROCEDURE PRD_PUBLIC_DISORDER_JQ(JOB_START_TIME INDATE, JOB_END_TIME INDATE)AS
INSERT_SQL CLOB ;BEGINDECLARECURSOR DISORDER_IDS ISSELECT ID FROM FKWW_PUBLIC_DISORDER;
DISORDER_ID VARCHAR2(40);
AREA_WKT VARCHAR2(4000);
AREA_WKT_SUBSTR VARCHAR2(4000);
LONGITUDE_MAX NUMBER;
LONGITUDE_MIN NUMBER;
LATITUDE_MAX NUMBER;
LATITUDE_MIN NUMBER;
START_TIME VARCHAR2(20);
END_TIME VARCHAR2(20);BEGINSELECT TO_CHAR(JOB_START_TIME,'yyyy-MM-dd HH24:mi:ss')INTO START_TIME FROM DUAL;SELECT TO_CHAR(JOB_END_TIME,'yyyy-MM-dd HH24:mi:ss')INTO END_TIME FROM DUAL;OPEN DISORDER_IDS;FETCH DISORDER_IDS INTO DISORDER_ID;WHILE DISORDER_IDS % FOUND
LOOPSELECT AREA_WKT INTO AREA_WKT FROM FKWW_PUBLIC_DISORDER WHERE ID = DISORDER_ID;IF AREA_WKT ISNULLTHEN
AREA_WKT_SUBSTR :=NULL;ELSE
AREA_WKT_SUBSTR := SUBSTR(AREA_WKT,10, length(AREA_WKT)-11);SELECT TO_NUMBER(MAX(SUBSTR(SPLIT_CODE,0, INSTR(SPLIT_CODE,' '))))INTO LONGITUDE_MAX FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MIN(SUBSTR(SPLIT_CODE,0, INSTR(SPLIT_CODE,' '))))INTO LONGITUDE_MIN FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MAX(SUBSTR(SPLIT_CODE, INSTR(SPLIT_CODE,' ')+1,LENGTH(SPLIT_CODE))))INTO LATITUDE_MAX FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MIN(SUBSTR(SPLIT_CODE, INSTR(SPLIT_CODE,' ')+1,LENGTH(SPLIT_CODE))))INTO LATITUDE_MIN FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));
INSERT_SQL :='INSERT INTO FKWW_PUBLIC_DISORDER_JQ SELECT '''||DISORDER_ID||''' AS DISORDER_ID,JJDBH FROM JCJB WHERE
LONGITUDE IS NOT NULL
AND LATITUDE IS NOT NULL
AND LONGITUDE > '||LONGITUDE_MIN||'
AND LONGITUDE < '||LONGITUDE_MAX||'
AND LATITUDE > '||LATITUDE_MIN||'
AND LATITUDE < '||LATITUDE_MAX||'
AND
SDO_GEOM.RELATE (
SDO_GEOM.SDO_GEOMETRY (
2001,
4326,
MDSYS.SDO_POINT_TYPE (LONGITUDE, LATITUDE, NULL),
NULL,
NULL
),
''ANYINTERACT'',
SDO_GEOM.SDO_GEOMETRY (
'''||AREA_WKT||''',
4326
),
0.00001
) = ''TRUE''';IF JOB_START_TIME ISNOTNULLTHEN
INSERT_SQL := INSERT_SQL||' AND BJSJ >= TO_DATE('''||START_TIME||''',''yyyy-MM-dd hh24:mi:ss'')';ENDIF;IF JOB_END_TIME ISNOTNULLTHEN
INSERT_SQL := INSERT_SQL||' AND BJSJ <= TO_DATE('''||END_TIME||''',''yyyy-MM-dd hh24:mi:ss'')';ENDIF;
INSERT_SQL := INSERT_SQL||' MINUS SELECT * FROM FKWW_PUBLIC_DISORDER_JQ';EXECUTE IMMEDIATE INSERT_SQL;ENDIF;FETCH DISORDER_IDS INTO DISORDER_ID ;ENDLOOP;CLOSE DISORDER_IDS;END;END;
警情重定位时,重新关联乱点区域存储过程
------------------------------------------------------------------ 警情重定位时,重新关联乱点区域存储过程 added by wyk 2018-09-30----------------------------------------------------------------CREATEORREPLACEPROCEDURE PRD_JQ_RESET_POINT (JJDBH IN VARCHAR2, LONGITUDE IN NUMBER, LATITUDE IN NUMBER)AS INSERT_SQL CLOB ;BEGINDECLARECURSOR DISORDER_IDS ISSELECT ID FROM FKWW_PUBLIC_DISORDER;
DELETE_SQL VARCHAR2(4000);
DISORDER_ID VARCHAR2(40);
AREA_WKT VARCHAR2(4000);
AREA_WKT_SUBSTR VARCHAR2(4000);
LONGITUDE_MAX NUMBER;
LONGITUDE_MIN NUMBER;
LATITUDE_MAX NUMBER;
LATITUDE_MIN NUMBER;BEGIN--先删除关联数据,重定位后再添加
DELETE_SQL :='DELETE FROM FKWW_PUBLIC_DISORDER_JQ WHERE JJDBH = '''||JJDBH||'''';EXECUTE IMMEDIATE DELETE_SQL;OPEN DISORDER_IDS;FETCH DISORDER_IDS INTO DISORDER_ID;WHILE DISORDER_IDS % FOUND
LOOPSELECT AREA_WKT INTO AREA_WKT FROM FKWW_PUBLIC_DISORDER WHERE ID = DISORDER_ID;IF AREA_WKT ISNULLTHEN
AREA_WKT_SUBSTR :=NULL;ELSE
AREA_WKT_SUBSTR := SUBSTR(AREA_WKT,10, length(AREA_WKT)-11);SELECT TO_NUMBER(MAX(SUBSTR(SPLIT_CODE,0, INSTR(SPLIT_CODE,' '))))INTO LONGITUDE_MAX FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MIN(SUBSTR(SPLIT_CODE,0, INSTR(SPLIT_CODE,' '))))INTO LONGITUDE_MIN FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MAX(SUBSTR(SPLIT_CODE, INSTR(SPLIT_CODE,' ')+1,LENGTH(SPLIT_CODE))))INTO LATITUDE_MAX FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));SELECT TO_NUMBER(MIN(SUBSTR(SPLIT_CODE, INSTR(SPLIT_CODE,' ')+1,LENGTH(SPLIT_CODE))))INTO LATITUDE_MIN FROM(SELECT REGEXP_SUBSTR (AREA_WKT_SUBSTR,'[^,]+',1,L)AS SPLIT_CODE FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (AREA_WKT_SUBSTR)- LENGTH (REPLACE(AREA_WKT_SUBSTR,','))+1) B
WHERE L <= LENGTH (AREA_WKT_SUBSTR));IF LONGITUDE >= LONGITUDE_MIN AND LONGITUDE <= LONGITUDE_MAX AND LATITUDE >= LATITUDE_MIN AND LATITUDE <= LATITUDE_MAX THEN
INSERT_SQL :='INSERT INTO FKWW_PUBLIC_DISORDER_JQ SELECT '''||DISORDER_ID||''','''||JJDBH||''' FROM DUAL
WHERE SDO_GEOM.RELATE (
SDO_GEOM.SDO_GEOMETRY (
2001,
4326,
MDSYS.SDO_POINT_TYPE ('||LONGITUDE||', '||LATITUDE||', NULL),
NULL,
NULL
),
''ANYINTERACT'',
SDO_GEOM.SDO_GEOMETRY (
'''||AREA_WKT||''',
4326
),
0.00001
) = ''TRUE''';EXECUTE IMMEDIATE INSERT_SQL;ENDIF;ENDIF;FETCH DISORDER_IDS INTO DISORDER_ID ;ENDLOOP;CLOSE DISORDER_IDS;END;END;
治安乱点区域黄赌毒警情分析函数(利用管道输出)
------------------------------------------------------------------ 治安乱点区域黄赌毒警情分析函数 added by wyk 2018-09-21----------------------------------------------------------------CREATETYPE ROW_TOPIC_TYPE AS OBJECT (COL1 VARCHAR2(100),COL2 NUMBER);CREATETYPE TABLE_TOPIC_TYPE ASTABLEOF ROW_TOPIC_TYPE;CREATEORREPLACEFUNCTION FUNC_COUNT_TOPIC_TYPE (ORDER_ID IN VARCHAR2,TOPIC_TYPE IN VARCHAR2,START_TIME VARCHAR2,END_TIME VARCHAR2)--ORDER_ID:乱点区域Id TOPIC_TYPE:警情类型('00010001000000000000,00010000000000000000,00030000000000000000')--START_TIME:开始时间 END_TIME:结束时间RETURN TABLE_TOPIC_TYPE PIPELINED IS V ROW_TOPIC_TYPE;--以管道形式输出BEGINDECLARECURSOR TYPE_ARRS ISSELECT REGEXP_SUBSTR (TOPIC_TYPE,'[^,]+',1,L)FROM DUAL,(SELECTLEVEL L FROM DUAL CONNECTBYLEVEL<= LENGTH (TOPIC_TYPE)- LENGTH (REPLACE(TOPIC_TYPE,','))+1) B
WHERE L <= LENGTH (TOPIC_TYPE);
TYPE_ITEM VARCHAR2(30);BEGINOPEN TYPE_ARRS;FETCH TYPE_ARRS INTO TYPE_ITEM;WHILE TYPE_ARRS % FOUND
LOOPIF SUBSTR(TYPE_ITEM,5)='0000000000000000'THENFOR THISROW IN(SELECT SUBSTR(JQ_TYPE,0,4)||'0000000000000000'AS JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE LIKE SUBSTR(TYPE_ITEM,0,4)||'%'AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY SUBSTR(JQ_TYPE,0,4))LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ELSEIF SUBSTR(TYPE_ITEM,9)='000000000000'THENFOR THISROW IN(SELECT SUBSTR(JQ_TYPE,0,8)||'000000000000'AS JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE LIKE SUBSTR(TYPE_ITEM,0,8)||'%'AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY SUBSTR(JQ_TYPE,0,8))LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ELSEIF SUBSTR(TYPE_ITEM,9)='000000000000'THENFOR THISROW IN(SELECT SUBSTR(JQ_TYPE,0,8)||'000000000000'AS JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE LIKE SUBSTR(TYPE_ITEM,0,8)||'%'AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY SUBSTR(JQ_TYPE,0,8))LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ELSEIF SUBSTR(TYPE_ITEM,13)='00000000'THENFOR THISROW IN(SELECT SUBSTR(JQ_TYPE,0,12)||'00000000'AS JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE LIKE SUBSTR(TYPE_ITEM,0,12)||'%'AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY SUBSTR(JQ_TYPE,0,12))LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ELSEIF SUBSTR(TYPE_ITEM,17)='0000'THENFOR THISROW IN(SELECT SUBSTR(JQ_TYPE,0,16)||'0000'AS JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE LIKE SUBSTR(TYPE_ITEM,0,16)||'%'AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY SUBSTR(JQ_TYPE,0,16))LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ELSEIF TYPE_ITEM ISNOTNULLTHENFOR THISROW IN(SELECT JQ_TYPE,COUNT(1)AS COUNT FROM(SELECT J.JQ_TYPE,J.BJSJ FROM(SELECT*FROM FKWW_PUBLIC_DISORDER_JQ WHERE DISORDER_ID = ORDER_ID) T
LEFTJOIN JCJB J ON T.JJDBH=J.JJDBH)WHERE JQ_TYPE = TYPE_ITEM
AND BJSJ >= TO_DATE(START_TIME,'yyyy-MM-dd HH24:mi:ss')AND BJSJ <= TO_DATE(END_TIME,'yyyy-MM-dd HH24:mi:ss')GROUPBY JQ_TYPE
)LOOP
V := ROW_TOPIC_TYPE(THISROW.JQ_TYPE,THISROW.COUNT);
PIPE ROW(V);ENDLOOP;ENDIF;ENDIF;ENDIF;ENDIF;ENDIF;ENDIF;FETCH TYPE_ARRS INTO TYPE_ITEM;ENDLOOP;CLOSE TYPE_ARRS;END;RETURN;END;
判断案件或警情是否已提请合成,如果未提请合成,则判断关联的案件或警情是否已提请合成
---------------------------------------------------------------------- 判断案件或警情是否已提请合成,如果未提请合成,则判断关联的案件或警情是否已提请合成 added by wyk 2018-09-19--------------------------------------------------------------------CREATEORREPLACEFUNCTION"FUNC_GET_HCYP_STATE"(CASE_ID_IN IN VARCHAR2,JJDBH_IN IN VARCHAR2)RETURN NUMBER
AS HC_STATE NUMBER;CASE_CODE_TEMP VARCHAR2(50);BEGINIF CASE_ID_IN ISNULLTHENSELECTMAX(IS_DELETE)INTO HC_STATE FROM VIRTUAL_CASE WHERE CASE_ID =(SELECT CASE_ID FROMCASEWHERE CASE_CODE ='Q'||JJDBH_IN);IF HC_STATE =0THENRETURN1;--本身已提请合成ELSEIF HC_STATE =1THENRETURN2;--本身已删除合成ELSEIF HC_STATE ISNULLTHENDECLARECURSOR IS_DELETES ISSELECT IS_DELETE FROM VIRTUAL_CASE WHERE CASE_ID IN(SELECT case_id FROM CASE_ASSOCIATE_JQ WHERE jjdbh = JJDBH_IN );
IS_DELETE NUMBER;BEGINIFNOT IS_DELETES%ISOPEN THENOPEN IS_DELETES;ENDIF;FETCH IS_DELETES INTO IS_DELETE;WHILE IS_DELETES%FOUND
LOOPIF IS_DELETE =0THENCLOSE IS_DELETES;RETURN3;--关联的案件已提请合成ELSEIF IS_DELETE =1THENRETURN4;ENDIF;--关联的案件已删除合成ENDIF;FETCH IS_DELETES INTO IS_DELETE;ENDLOOP;CLOSE IS_DELETES;RETURN0;END;ENDIF;ENDIF;ENDIF;ELSESELECTMAX(IS_DELETE)INTO HC_STATE FROM VIRTUAL_CASE WHERE CASE_ID = CASE_ID_IN;IF HC_STATE =0THENRETURN1;--本身已提请合成ELSEIF HC_STATE =1THENRETURN2;--本身已删除合成ELSEIF HC_STATE ISNULLTHENDECLARECURSOR IS_DELETES ISSELECT IS_DELETE FROM VIRTUAL_CASE WHERE CASE_ID IN(SELECT CASE_ID FROMCASEWHERE CASE_CODE IN(SELECT'Q'||JJDBH FROM CASE_ASSOCIATE_JQ WHERE CASE_ID = CASE_ID_IN));
IS_DELETE NUMBER;BEGINIFNOT IS_DELETES%ISOPEN THENOPEN IS_DELETES;ENDIF;FETCH IS_DELETES INTO IS_DELETE;WHILE IS_DELETES%FOUND
LOOPIF IS_DELETE =0THENCLOSE IS_DELETES;RETURN5;--关联的警情已提请合成ELSEIF IS_DELETE =1THENRETURN6;ENDIF;--关联的警情已删除合成ENDIF;FETCH IS_DELETES INTO IS_DELETE;ENDLOOP;CLOSE IS_DELETES;RETURN0;END;ENDIF;ENDIF;ENDIF;ENDIF;END;-- 0:未提请合成-- 1:本身已提请合成-- 2:本身已删除合成-- 3:关联的案件已提请合成-- 4:关联的案件已删除合成-- 5:关联的警情已提请合成-- 6:关联的警情已删除合成
A数据定时迁移
------------------------------------------------------------------ A数据定时迁移(TB_INOUT_RESULT表保留5天数据) added by wyk 2018-12-21----------------------------------------------------------------CREATEORREPLACEPROCEDURE PRD_TB_INOUT_RESULT_BAK AS
INSERT_SQL VARCHAR2(200);
DELETE_SQL VARCHAR2(200);BEGIN
INSERT_SQL :='INSERT INTO TB_INOUT_RESULT_BAK SELECT * FROM TB_INOUT_RESULT WHERE DATETIME >= to_char(TRUNC(SYSDATE-5),''yyyy-MM-dd hh24:mi:ss'') AND DATETIME < to_char(TRUNC(SYSDATE-4),''yyyy-MM-dd hh24:mi:ss'')';EXECUTE IMMEDIATE INSERT_SQL;
DELETE_SQL :='DELETE FROM TB_INOUT_RESULT WHERE DATETIME >= to_char(TRUNC(SYSDATE-5),''yyyy-MM-dd hh24:mi:ss'') AND DATETIME < to_char(TRUNC(SYSDATE-4),''yyyy-MM-dd hh24:mi:ss'')';EXECUTE IMMEDIATE DELETE_SQL;END;