当我运行以下代码时,它会插入两行'07_%'
,这些行最初在tlp
中不存在,因为创建日期为'07-AUG-15'
。
最初在GLOB
我有600行是like '07_%'
,那么这些行是如何插入的?
INSERT INTO TLP
(LASTNAME, FIRSTNAME, EMAIL1, USERID)
SELECT NAME, GIVEN_NAME, MAIL, LOGIN
FROM gLOB
WHERE (( ( NOT EXISTS (SELECT EMAIL1
FROM TLP
WHERE GLOB.mail = TLP.email1 )
AND GLOB.mail IS NOT NULL )
AND GLOB.COUNTRY='GERMANY' )
OR (( NOT EXISTS (SELECT userid
FROM TLP
WHERE GLOB.LOGIN = TLP.userid )
)
AND GLOB.COUNTRY='Germany'))
and ( exists (select FIRSTNAME
from TLP
where (gLOB.name not like '07_%' AND
GLOB.name not like 'TR_%' AND
GLOB.name not like 'ST_%' AND
GLOB.name is not null))
));
答案 0 :(得分:1)
我认为您正在尝试过滤掉07-AUG-15
这样的值,但您喜欢的模式会显示07_%
。它应该是
gal.name not like '07-%'
另外,你的最后一部分如下所示是没有意义的;相反,您应该在主查询WHERE
子句中包含这些条件。
and ( exists (select FIRSTNAME
from TCPD_PERSONEL_COPY
where (gal.name not like '07_%' AND
gal.name not like 'TR_%' AND
gal.name not like 'ST_%' AND
gal.name not like 'KB_%' AND
gal.name not like 'HS_%' AND
gal.name is not null))
您的SELECT
应该是
SELECT SUBSTR(NAME, 1, 50),SUBSTR( GIVEN_NAME, 1, 50), DEPARTMENT, PHONE, SUBSTR(MAIL, 1, 100), SUBSTR(LOGIN, 1, 255), SYSDATE
FROM gal
WHERE ( NOT EXISTS (SELECT EMAIL1
FROM TCPD_PERSONEL_COPY
WHERE GAL.mail = TCPD_PERSONEL_COPY.email1)
OR NOT EXISTS (SELECT userid
FROM TCPD_PERSONEL_COPY
WHERE gAL.LOGIN = TCPD_PERSONEL_COPY.userid))
AND GAL.mail IS NOT NULL AND GAL.COUNTRY='GERMANY'
AND ( gal.name not like '07_%' OR
gal.name not like 'TR_%' OR
gal.name not like 'ST_%' OR
gal.name not like 'KB_%' OR
gal.name not like 'HS_%' OR
gal.name is not null);