Oracle
 sql >> Database >  >> RDS >> Oracle

Come vengono inserite due righe?

Credo che tu stia cercando di filtrare valori come 07-AUG-15 ma il tuo modello simile dice 07_% . Dovrebbe essere

gal.name not like '07-%'

Inoltre, la tua ultima parte come indicato di seguito non ha senso; piuttosto dovresti includere quelle condizioni nella query principale WHERE clausola.

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))

Il tuo SELECT dovrebbe assomigliare a

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);