SQL to get first name, last name, email of user in Oracle Fusion

Details on the table used:

PER_USERS  - Table for storing one record per fusion system user. Maps to a single LDAP user. Primary Key is USER_ID

PER_LDAP_USERS - Table for storing one record for each user to be processed in OIM when creating new users or maintaining user details. Primary Key is LDAP_USER_ID

PER_ALL_PEOPLE_F - This table will store core personal data. Data is stored with date effectivity and it can having multiple records for given person_id record. Values that are static over time will be duplicated to each new date effective instance of a row with the same person_id. Primary Key is PERSON_ID, EFFECTIVE_START_DATE, EFFECTIVE_END_DATE

PER_PERSON_NAMES_F - This table is to hold core (common) and legislative-specific name components for a person, and names represented in different character sets. The table is date effective to record changes over time. Primary Key is PERSON_IDEFFECTIVE_START_DATEEFFECTIVE_END_DATE

PER_EMAIL_ADDRESSES - This table stores email addresses of different types for a person. Primary Key is EMAIL_ADDRESS_ID

 Run the below query to get first name, last name, email of user in Oracle Fusion


SELECT 
	 pu.user_id
	,pu.user_guid
	,papf.person_id
	,papf.effective_start_date
	,papf.effective_end_date
	,papf.person_number
	,pu.username
	,NVL(
		ppnf.first_name,(
			SELECT 	ldu.first_name FROM PER_LDAP_USERS ldu 
			WHERE 	ldu.username 	= pu.username 
			AND 	ldu.user_guid 	= pu.user_guid 
			AND 	ldu.creation_date = (
				SELECT 	MAX(ldu1.creation_date) 
				FROM 	PER_LDAP_USERS ldu1 
				WHERE 	ldu1.username 	= ldu.username 
				AND 	ldu1.user_guid 	= ldu.user_guid
			)
		)
	) AS FIRST_NAME
	,NVL(
		ppnf.last_name,(
			SELECT 	ldu.last_name FROM PER_LDAP_USERS ldu 
			WHERE 	ldu.username 	= pu.username 
			AND 	ldu.user_guid 	= pu.user_guid 
			AND 	ldu.creation_date = (
				SELECT 	MAX(ldu1.creation_date) 
				FROM 	PER_LDAP_USERS ldu1 
				WHERE 	ldu1.username 	= ldu.username 
				AND 	ldu1.user_guid 	= ldu.user_guid
			)
		)
	) AS LAST_NAME
	,NVL(
		pea.email_address,(
			SELECT 	ldu.email FROM PER_LDAP_USERS ldu 
			WHERE 	ldu.username 	= pu.username 
			AND 	ldu.user_guid 	= pu.user_guid 
			AND 	ldu.creation_date = (
				SELECT 	MAX(ldu1.creation_date) 
				FROM 	PER_LDAP_USERS ldu1 
				WHERE 	ldu1.username 	= ldu.username 
				AND 	ldu1.user_guid 	= ldu.user_guid
			)
		)
	) AS EMAIL
	,pu.active_flag
FROM
	 per_users pu
	,per_all_people_f papf
	,per_person_names_f ppnf
	,per_email_addresses pea
WHERE	1=1
AND	pu.PERSON_ID = papf.person_id (+) 
AND pu.person_id = ppnf.person_id (+) 
AND pu.person_id = pea.person_id  (+) 
AND pu.username in( 'username')
AND NVL(ppnf.name_type,'GLOBAL') 	= 'GLOBAL'
AND NVL(pea.email_type,'W1') 		= 'W1'
AND papf.effective_start_date = (
		select max(papf1.effective_start_date) from per_all_people_f papf1 
		where papf1.person_id =papf.person_id 
	);
;


SELECT usr.username,
       NAME.full_name,
       email.email_address,
       role_name.role_common_name,
       role_name.role_name,
       role_name.description,
       usr.active_flag,
       usr.creation_date,
       usr.last_update_date,
       usr.last_updated_by
FROM   per_users usr,
       per_person_names_f_v NAME,
       per_email_addresses_v email,
       per_user_roles role,
       per_roles_dn_vl role_name
WHERE  1 = 1
       AND NAME.person_id = usr.person_id
       AND email.person_id = usr.person_id
       AND NAME.effective_end_date > sysdate + 1
       AND role.user_id = usr.user_id
       AND role_name.role_id = role.role_id
       AND Upper(role_name.role_common_name) LIKE Nvl(Upper(:p_role_name), '%')
       AND Upper(usr.username) LIKE Nvl(Upper(:p_username), '%')
       AND Upper(NAME.full_name) LIKE Nvl(Upper(:p_fullname), '%')
ORDER  BY NAME.full_name ASC ;

Source : https://docs.oracle.com/ 

Comments

All Categories

Call Fusion BIP Report2 Change Password1 Code Combinations2 Compute Instance2 CTE1 Custom Images1 Customer1 Data Aggregation2 Database5 Date Conversion1 DB Adapter2 Decryption1 Development1 EBS5 Encryption1 ESS Jobs3 Examine1 FBDI3 Fusion APIs1 Fusion BIP7 GIT2 GL3 GL Journals1 GL_DAILY_CONVERSION_TYPES1 GL_DAILY_RATES1 ICS1 Identity Domain1 Integrations1 Java1 Journal Import1 Keys1 Legal Entity1 LookupTypeLOV1 LOV1 LOVs1 MultiPartAPIs1 Networking1 NVL2 NVL in OIC2 OCI13 OCI Billing1 OCI Compute6 OCI Cost Management1 OCI Events Service1 OCI Free Tier3 oci networking1 OCI Notifification Service1 OCI Security3 OIC4 OIC Mapper2 Oracle26 Oracle ADF17 Oracle APEX1 Oracle Apps60 Oracle Apps R127 Oracle ATP1 Oracle BIP8 Oracle Cloud13 Oracle Cloud Free Tier1 Oracle cloud Infrastructure10 Oracle Cloud Security2 Oracle Cloud VM1 Oracle DB4 oracle ebs6 Oracle ERP4 Oracle ERP Adapter2 Oracle ERP Cloud7 Oracle financials2 Oracle Forms1 Oracle Fusion57 Oracle Fusion BIP4 Oracle Fusion ERP17 Oracle Fusion Financials18 Oracle Integration Cloud3 Oracle OAF17 Oracle OCI14 Oracle OIC22 Oracle SOA 12c10 Oracle SQL17 Oracle VBCS1 Oracle VBS2 Oracle Visual Builder Cloud Service1 Oracle Visual Builder Studio2 Oracle Workflow Notifications1 OracleCloudTutorial1 Others10 Payables2 Payables Import1 Programs1 Properties1 R121 Register BIP as ESS Job1 Reset Password1 Responsibility1 REST4 Security List1 Site Map1 SOAP2 SOAP API2 SOAP UI3 SQL16 SQL Functions3 SQL Queries14 SQL Query8 SQL Tips3 SSH1 TCA1 Value Sets1 VBCS1 vcn1 Virtual Machine2 Virtual Machines1 XML1 XSLT1
Show more