前端之家收集整理的这篇文章主要介绍了
oracle视图举例之一,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
CREATE OR REPLACE VIEW V_ALARM_REPORT_USER_R AS
SELECT AAR.REPORT_ID,AAR.ALARM_TYPE_ID,AAR.ALARM_TYPE_NAME,AAR.ALARM_CONTENT,AAR.LINE_CODE,AAR.STATION,AAR.REPORTER_CODE,AAR.REPORTER_NAME,--提报人姓名
AAW.AD_FLOW_ID,AAW.AD_RECEIVER_ROLE_ID,--哪个角色的人接收
SUW.USER_AD_ROLES USER_AD_ROLES,--接收人具有AD角色
SUW.USER_CODE AS RECEIVER_CODE,SUW.USER_NAME AS RECEIVER_NAME,AAW.AD_IF_REPORT_ANSWER,AAR.REPORT_TIME,AAW.AD_RESPONSE_INTERVAL,AAR.REPORT_TIME + (AAW.AD_RESPONSE_INTERVAL / 24 / 60) AS RESPONSE_EVENT_TIME,AAW.AD_COMPLETE_INTERVAL,AAR.RESPONSE_TIME,AAR.RESPONSE_TIME + (AAW.AD_COMPLETE_INTERVAL / 24 / 60) AS COMPLETE_EVENT_TIME,/*(SELECT PT1.MODE_ID
FROM AD_REPORT_ROLE PT1
WHERE PT1.ROLE_ID = AAW.AD_RECEIVER_ROLE_ID
AND PT1.STAGE_ID = 'RESPONSE')*/
T4.MODE_ID RESPONSE_MODE_ID,--响应通讯方式
/* (SELECT PT1.MODE_ID
FROM AD_REPORT_ROLE PT1
WHERE PT1.ROLE_ID = AAW.AD_RECEIVER_ROLE_ID
AND PT1.STAGE_ID = 'COMPLETE') COMPLETE_MODE_ID,*/ --完成通讯方式
SUW.LINE_CODE AS USER_LINE_CODE
FROM AD_ALARM_REPORT AAR,--预警记录表
AD_ALARM_WORKFLOW AAW,--流程表
SYS_USER SUW,--获取接收人
AD_REPORT_ROLE T4 --根据角色获取通讯方式(一角色多个通讯方式)
WHERE AAR.ALARM_TYPE_ID = AAW.ALARM_TYPE_ID
AND AAW.AD_RECEIVER_ROLE_ID = T4.ROLE_ID
AND T4.STAGE_ID = 'RESPONSE'
AND SUW.IF_REPONSER = 'true'
AND (SUW.LINE_CODE = AAR.LINE_CODE OR SUW.LINE_CODE = 'ANDON-LINE-ALL')
AND INSTR(',' || SUW.USER_AD_ROLES || ',',' || AAW.AD_RECEIVER_ROLE_ID || ',') > 0
;
原文链接:https://www.f2er.com/oracle/206233.html