Friday, 15 December 2017

Successful/Unsuccessful user logins in Oracle from FND_USER

https://dbissues.blogspot.com/2017/12/successfulunsuccessful-user-logins-in.html

select USER_NAME, DESCRIPTION,FAX,START_TIME, STATUS
from
(SELECT b.USER_NAME, b.DESCRIPTION, b.FAX, u.ATTEMPT_TIME START_TIME , 'UnSuccessful Login' STATUS
FROM FND_UNSUCCESSFUL_LOGINS U, FND_USER B
WHERE U.USER_ID = B.USER_ID
AND B.USER_NAME LIKE NVL(&USER_NAME, '%')
AND U.ATTEMPT_TIME
          BETWEEN CASE
                    WHEN LENGTH(&START_TIME) in (14,15)
                     THEN TO_DATE(&START_TIME, 'DD-MON-RR HH24:MI')
                    WHEN LENGTH(&START_TIME) in (8,9)
                     THEN TO_DATE(&START_TIME, 'DD-MON-RR')
                    ELSE U.ATTEMPT_TIME
                  END
          AND     CASE
                    WHEN LENGTH(&END_TIME) in (14,15)
                     THEN TO_DATE(&END_TIME, 'DD-MON-RR HH24:MI')
                    WHEN LENGTH(&END_TIME) in (8,9)
                     THEN TO_DATE(&END_TIME, 'DD-MON-RR') + 1
                    ELSE U.ATTEMPT_TIME
                  END



union

select c.USER_NAME, c.DESCRIPTION, c.FAX, a.START_TIME START_TIME , 'Successful Login' STATUS
from fnd_logins a, fnd_user c
where a.user_id = c.user_id
and c.USER_NAME LIKE NVL(&USER_NAME, '%')
and a.LOGIN_TYPE = 'FORM'
AND a.START_TIME
          BETWEEN CASE
                    WHEN LENGTH(&START_TIME) in (14,15)
                     THEN TO_DATE(&START_TIME, 'DD-MON-RR HH24:MI')
                    WHEN LENGTH(&START_TIME) in (8,9)
                     THEN TO_DATE(&START_TIME, 'DD-MON-RR')
                    ELSE a.START_TIME
                  END
          AND     CASE
                    WHEN LENGTH(&END_TIME) in (14,15)
                     THEN TO_DATE(&END_TIME, 'DD-MON-RR HH24:MI')
                    WHEN LENGTH(&END_TIME) in (8,9)
                     THEN TO_DATE(&END_TIME, 'DD-MON-RR') + 1
                    ELSE a.START_TIME
                  END

)

order by (START_TIME) desc

1 comment:

  1. I have observed some Issues in 12.2.4 Instance Regarding the above Query. Please look into the matter...

    ReplyDelete