Categories
- All Categories
- 15 Oracle Analytics Sharing Center
- 14 Oracle Analytics Lounge
- 213 Oracle Analytics News
- 42 Oracle Analytics Videos
- 15.7K Oracle Analytics Forums
- 6.1K Oracle Analytics Idea Labs
- Oracle Analytics User Groups
- 78 Oracle Analytics Trainings
- 14 Oracle Analytics Data Visualizations Challenge
- Find Partners
- For Partners
have 2 sqls that work correct if run individually but UNION of the 2 causes issues

select papf.person_number, ppnf.list_name employeename, pee.effective_start_date accru_startdt, peev.effective_end_date accru_end_dt, peev.screen_entry_value hrs_to_accrue, pet.base_element_name, pee.person_id, pee.effective_start_date work_date
from pay_element_entries_f pee,
pay_element_entry_values_f peev,
pay_input_values_f piv,
pay_element_types_f pet,
PER_PERSON_NAMES_F ppnf,
per_all_people_f papf
where 1 = 1
and peev.element_entry_id = pee.element_entry_id
and piv.input_value_id = peev.input_value_id
and peev.effective_start_date between piv.effective_start_date and
piv.effective_end_date
and pee.effective_start_date between peev.effective_start_date and
peev.effective_end_date
and :eff_date3 between peev.effective_start_date and peev.effective_end_date
and pee.element_type_id = pet.element_type_id
and :eff_date3 between pet.effective_start_date and pet.effective_end_date
and :eff_date3 between ppnf.effective_start_date and ppnf.effective_end_date
and piv.base_name = 'Hours'
and peev.screen_entry_value is not null
and pee.person_id = papf.person_id
and pee.person_id = ppnf.person_id
and ppnf.NAME_TYPE='GLOBAL'
AND (:p_person_num is null or papf.person_number = :p_person_num)
and pet.base_element_name in
(select replace(pet.base_element_name, ' Earnings Results', '')
from pay_balance_types_vl pbt,
pay_balance_feeds_f pbf,
pay_element_types_f pet
where upper(pbt.balance_name) like 'ACCRUAL HOURS WORKED'
and pbf.balance_type_id = pbt.balance_type_id
and sysdate between pbf.effective_start_date and
pbf.effective_end_date
and pbf.element_type_id = pet.element_type_id)
order by papf.person_number, pee.effective_start_date
UNION
-- ABSENCES
select papf.person_number, ppnf.list_name employeename, p.start_date, p.end_date, abs(det.value), 'Absence', det.person_id, det.procd_date
from anc_per_acrl_entry_dtls det,
PER_PERSON_NAMES_F ppnf,
per_all_people_f papf,
(select ptp.start_date, ptp.end_date
from pay_time_periods ptp
where :eff_date3 between ptp.start_date and
ptp.end_date
and ptp.period_category = 'E') p
where det.type = 'ABS'
-- and det.person_id = 300000007840522
and det.person_id = papf.person_id
and det.person_id = ppnf.person_id
AND (:p_person_num is null or papf.person_number = :p_person_num)
and ppnf.NAME_TYPE='GLOBAL'
and det.voided_acrl = 'N'
and det.procd_date between p.start_date and p.end_date
and det.procd_date between ppnf.effective_start_date and ppnf.effective_end_date
and det.pl_id in
(select a.absence_plan_id
from ANC_ABSENCE_PLANS_VL a
where substr(a.name, 1, 9) in
(select substr(base_element_name, 1, 9)
from pay_balance_types_vl pbt,
pay_balance_feeds_f pbf,
pay_element_types_f pet
where upper(pbt.balance_name) like
'ACCRUAL HOURS WORKED'
and pbf.balance_type_id = pbt.balance_type_id
and sysdate between pbf.effective_start_date and
pbf.effective_end_date
and pbf.element_type_id = pet.element_type_id
and pet.classification_id in
(select a.classification_id
from pay_ele_classifications a
where a.base_classification_name = 'Absences'
and a.legislation_code is null)))
Answers
-
What issue you are facing? @Bernadette Dorris?
0 -
I have 2 sqls above that work beautifully if run individually but when I try to do a union of the 2 queries, I run into issues. I suspect that my problem is that the field peev.screen_entry_value is data type (VARCHAR2) and det.value is numeric. I tried different ways to convert the VARCHAR2 field into numeric but I am not successful. I tried the TO_NUMBER and CAST functions to no avail. Do you have any suggestions?
0 -
Have you tried the other way around converting the number to varchar cast as char. As you suspect likely to be a character type mismatch.
0 -
have you tried create table as (1st select) then insert into table (2nd select), may give you better error messages
0 -
I tried the other way around and it works but then the end user will have to convert the character field to a numeric field before they can do mathematical operations on the values.
0