Blog Archives

Query to link two columns in HRMS Table structure

We have a requirement that we need to map the Payroll, Visa and Company. Initially we had Visa and Company Mapping in Table Structure in HRMS. Now we have link the same with Payroll.

We went for some options that is to map the Company name in Payroll but as it was one to many combination we left it.
Next we tried for Lookup but we came to conclusion we can create another column and link the values.

Below is the query with Visa(Values) and company(Row) Mapping that is linking table column and row.

SELECT pur.ROW_LOW_RANGE_OR_NAME company_name
FROM PAY_USER_TABLES_FV put
,PAY_USER_COLUMNS_FV puc
,pay_user_rows_f pur
,pay_user_column_instances_f puci
WHERE put.base_user_table_name = 'XX_TABLE_NAME'
AND puc.base_user_column_name = 'VISA_TYPE'
AND put.user_table_id = puc.user_table_id
AND put.user_table_id = puc.user_table_id
AND pur.user_row_id = puci.user_row_id
AND puc.user_column_id = puci.user_column_id
AND sysdate between pur.effective_start_date and pur.effective_end_date
AND sysdate between puci.effective_start_date and puci.effective_end_date
AND puci.value = p_visa_type;

With the above query as base we have created the below query. We have inputs as p_visa_type and p_payroll_id and we link two columns

ExactVisaPayroll
Company-1Visa Val-1Payr Val-1
Company-2Visa Val-2Payr Val-2

SELECT pur_visa.ROW_LOW_RANGE_OR_NAME company_name, puci_visa.value VISA, puci_payr.value PAYROLL_NAME
FROM PAY_USER_TABLES_FV put
,PAY_USER_COLUMNS_FV puc_visa
,pay_user_rows_f pur_visa
,PAY_USER_COLUMNS_FV puc_payr
,pay_user_rows_f pur_payr
,pay_user_column_instances_f puci_visa
,pay_user_column_instances_f puci_payr
WHERE put.base_user_table_name = 'XX_TABLE_NAME'
AND puc_visa.base_user_column_name = 'VISA_TYPE'
AND puc_payr.base_user_column_name = 'PAYROLL'
AND put.user_table_id = puc_visa.user_table_id
AND put.user_table_id = puc_payr.user_table_id
AND pur_visa.user_row_id = puci_visa.user_row_id
AND pur_payr.user_row_id = puci_payr.user_row_id
AND puc_visa.user_column_id = puci_visa.user_column_id
AND puc_payr.user_column_id = puci_payr.user_column_id
AND sysdate between pur_visa.effective_start_date and pur_visa.effective_end_date
AND sysdate between pur_payr.effective_start_date and pur_payr.effective_end_date
AND sysdate between puci_visa.effective_start_date and puci_visa.effective_end_date
AND sysdate between puci_payr.effective_start_date and puci_payr.effective_end_date
and pur_visa.ROW_LOW_RANGE_OR_NAME = pur_payr.ROW_LOW_RANGE_OR_NAME --Where we link the Values
AND puci.value = p_visa_type
AND puci_payr.value = (select payroll_name from pay_all_payrolls_f where sysdate between effective_start_date and effective_end_date and payroll_id = p_payroll_id);
Design a site like this with WordPress.com
Get started