Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error 'ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.'

L_a_u_r_aOct 18 2022 — edited Oct 19 2022

I have an interactive grid with some columns that are editable to users. The grid was working before adding the SIUPER_FRINGE_BENEFIT_BALANCES table to the query. Then I started getting ORA-02014 Error when I try to save a change. The query I am using is below. I have tried using a pipeline function and creating a view for the balances table instead and I am still getting the same error. I am running out of ideas. Please help.

WITH fb_bal as (
select max(pay_period_start_date), 
    assignment_id,
   payroll_id,
   vac_balance,
   sick_gtd,
   SICK_1_98,
   SICK_12_83,
   SICK_1_84,
   SICK_FYD_USED
from BALANCES
where payroll_id = :PAYROLL_ID
and pay_period_start_date < to_date(:START_DATE, 'DD-MON-YYYY')
group by assignment_id,
   payroll_id,
   vac_balance,
   sick_gtd,
   SICK_1_98,
   SICK_12_83,
   SICK_1_84,
   SICK_FYD_USED
)
Select
   d.fb_header_id,
   d.FB_DETAIL_ID,
   d.CAMPUS,
   d.ORGANIZATION_ID,
   d.FULL_NAME,
   d.ASSIGNMENT_NUMBER,
   d.ASSIGNMENT_ID,
   d.PERSON_ID,
   d.VACATION,
   d.SICK,
   d.ESL,
   d.BREAVEMENT,
   d.CORRECTION_REQUESTED,
   d.JURY,
   d.CREATED_BY,
   d.CREATION_DATE,
   d.LAST_UPDATE_BY,
   d.LAST_UPDATE_DATE,
   d.EXPLANATION,
   d.NO_PTO,
   d.HR_APPROVAL,
   d.HR_COMMENT,
   d.FMLA,
   b.vac_balance,
   b.sick_gtd sick_acrd,
   b.SICK_1_98,
   b.SICK_12_83,
   b.SICK_1_84,
   b.SICK_FYD_USED
from header h,
    details d,
    fb_bal b
where h.fb_header_id = d.fb_header_id
   and h.payroll_id = :PAYROLL_ID
   and h.payroll_start_date = :START_DATE
   and processed_flag is NULL
   and batch_name is NULL
   and (d.organization_id IN (select organization_id 
                        from contacts 
                        where user_id = :USER_ID 
                            and ((:PAYROLL_ID = 2 and BW = 'Y') 
                            or (:PAYROLL_ID = 4 and SM = 'Y') 
                            or :PAYROLL_ID = 5 and MO = 'Y')
                           ) or :HR = 1)
   and h.payroll_id = :PAYROLL_ID
   and d.assignment_id = b.assignment_id(+)
   and b.payroll_id(+) = h.payroll_id
This post has been answered by Hamza Al-abbasi on Oct 18 2022
Jump to Answer
Comments
Post Details
Added on Oct 18 2022
3 comments
6,409 views