kintana_scripts_users_synchronize_contacts_and_users
-- Generic queries
select count(*)
from KCRT_CONTACTS cc
where cc.enabled_flag = 'Y'
select count(*)
from KNTA_USERS nu
where nu.end_date is NULL
select *
from KCRT_CONTACTS cc
where cc.enabled_flag = 'Y'
and cc.full_name like ('%Zabrinski%' )
order by cc.creation_date
-- Step 1
-- List enabled contacts for which the user record end date is set
-- These ought to be disabled in the contact list.
select cc.full_name
from KCRT_CONTACTS cc,
KNTA_USERS nu
where cc.enabled_flag = 'Y'
and cc.user_id = nu.user_id
and nu.end_date is not NULL
-- Step 2 :
-- List Contact-User Record name variations and clean them up
-- *** In particular, clean up critical errors such as invalid emails!
select cc.first_name "cc.first_name", nu.first_name "nu.first_name",
cc.last_name "cc.last_name", nu.last_name "nu.last_name",
cc.email_address "cc.email_address", nu.email_address "nu.email_address",
cc.phone_number "cc.phone_number", nu.phone_number "nu.phone_number"
from KCRT_CONTACTS cc,
KNTA_USERS nu
where cc.user_id = nu.user_id
and cc.enabled_flag = 'Y'
and ( cc.first_name != nu.first_name
or cc.last_name != nu.last_name
or cc.email_address != nu.email_address
or cc.phone_number != nu.phone_number
)
-- Step 3
-- List enabled contacts for which there is no user record
-- (It's Ok to have contacts with no user record).
-- Note 1 : A blank in the Demand - Contacts dialog ''username' column
-- indicates the same thing
-- Note 2 : There is no 'username' column in the KCRT_CONTACTS table
-- Note 3 : If the User_ID field is not blank then the user appears in
-- the Demand Mgmt - Contacts List as an enabled user
-- and also in the Sys Admin - Users List
-- BUT the user end-date is set in the user_record
-- Note 4 : If the User_ID field is blank
-- then the user appears in the Demand Mgmt - Contacts list
-- as an enabled user but there is no record for him in
-- the Sys-Admin - Users List.
select cc.user_id, cc.first_name, cc.last_name
from KCRT_CONTACTS cc
where cc.enabled_flag = 'Y'
minus
select nu.user_id, nu.first_name, nu.last_name
from KNTA_USERS nu
where nu.end_date is NULL
-- Step 4
-- List active users (with null end_dates) for which there is either
-- no enabled contacts record or one with exactly matching fields
-- It's not Ok to have an active user record without a contact record
select nu.user_id, nu.first_name, nu.last_name,
nu.email_address, nu.phone_number
from KNTA_USERS nu
where nu.end_date is NULL
minus
select cc.user_id, cc.first_name, cc.last_name,
cc.email_address, cc.phone_number
from KCRT_CONTACTS cc
where cc.enabled_flag = 'Y'
|