--创建表语句
CREATE TABLE CX_DUAN(OPTY_NAME VARCHAR2(400), -- 项目名称
TYPE VARCHAR2(400), -- 类型STG_NAME VARCHAR2(400), -- 项目阶段
INDEX_ID NUMBER(10), -- 项目指引
EOA_NAME VARCHAR2(400), -- 协议名称
CREATE_DATE VARCHAR2(400), -- 创建时间
UM VARCHAR2(400), -- 创建人UM
EOA_CODE VARCHAR2(400), -- 协议编码
EOA_STATE VARCHAR2(400), -- 审批状态
ACCOUNT_SHORT VARCHAR2(400),
ACCOUNT VARCHAR2(400),
PROJECT_NAME VARCHAR2(400),
PRODUCT VARCHAR2(400))
--查询语句拼接
SELECT distinct 'SELECT '''||PROJECT_NAME||'''OPTY_NAME,'||
''''|| TYPE||''' TYPE,'||
''''|| STG_NAME||''' STG_NAME,'||
''''|| INDEX_ID||''' INDEX_ID,'||
''''|| EOA_NAME||''' EOA_NAME,'||
''''|| UM||''' UM,'||
''''|| EOA_CODE||''' EOA_CODE,'||
''''|| EOA_STATE||''' EOA_STATE,'||
''''|| CREATE_DATE||''' CREATE_DATE FROM DUAL UNION ALL'
FROM CX_DUAN where EOA_STATE != 'NULL' AND PROJECT_NAME IS NOT NULL;
--查询两个表不相同数据
select distinct product, account_short from CX_DUAN d where project_NAME is null and (
select count(1) from project_import p where p.product = d.product and p.account_erp = d.account_short and p.project_name is not null
and p.migrate_plan in ('创建新项目', 'E掌通项目更新阶段')
) = 0;