sql - ORA-00907: missing right parenthesis - Following error is coming when i am putting Case statement in where clause -




$ following code highlights clause of bi publisher query, in have input paramter :p_country, through recieving values either ph/my/cn on basis of have put clause.

where     prg.payroll_relationship_id = peu.payroll_relationship_id      , peu.element_entry_id = pee.element_entry_id      , pee.element_type_id = pet.element_type_id      , prg.assignment_id = paaf.assignment_id      , ppsv.person_id = ppnf.person_id      , ppsv.person_id = paaf.person_id      --and  ppnf.person_id  = ccpp.person_id      , paaf.primary_assignment_flag = 'y'      , paaf.assignment_type = 'e'      , paaf.period_of_service_id = ppos.period_of_service_id      , ppos.person_id = paaf.person_id      , ppos.legal_entity_id = ple.organization_id      , ppnf.name_type = 'global'      ,    (case   when (:p_country = 'ph') (upper(pet.element_name) in ('phctc ext'))                     when (:p_country = 'my') (upper(pet.element_name) in ('myctc ext'))                     when (:p_country = 'cn') (upper(pet.element_name) in ('cnctc ext'))             end)      , paaf.grade_id = pg.grade_id 

what want more like:

where     prg.payroll_relationship_id = peu.payroll_relationship_id      , peu.element_entry_id = pee.element_entry_id      , pee.element_type_id = pet.element_type_id      , prg.assignment_id = paaf.assignment_id      , ppsv.person_id = ppnf.person_id      , ppsv.person_id = paaf.person_id      --and  ppnf.person_id  = ccpp.person_id      , paaf.primary_assignment_flag = 'y'      , paaf.assignment_type = 'e'      , paaf.period_of_service_id = ppos.period_of_service_id      , ppos.person_id = paaf.person_id      , ppos.legal_entity_id = ple.organization_id      , ppnf.name_type = 'global'      , upper(pet.element_name) =             case   when :p_country = 'ph' 'phctc ext'                    when :p_country = 'my' 'myctc ext'                    when :p_country = 'cn' 'cnctc ext'             end      , paaf.grade_id = pg.grade_id 

there no need of parenthesis using, , no need use of in when comparing 1 value.

another alternative away case , use series of grouped conditional clauses:

where     prg.payroll_relationship_id = peu.payroll_relationship_id      , peu.element_entry_id = pee.element_entry_id      , pee.element_type_id = pet.element_type_id      , prg.assignment_id = paaf.assignment_id      , ppsv.person_id = ppnf.person_id      , ppsv.person_id = paaf.person_id      --and  ppnf.person_id  = ccpp.person_id      , paaf.primary_assignment_flag = 'y'      , paaf.assignment_type = 'e'      , paaf.period_of_service_id = ppos.period_of_service_id      , ppos.person_id = paaf.person_id      , ppos.legal_entity_id = ple.organization_id      , ppnf.name_type = 'global'      , (         (:p_country = 'ph' , upper(pet.element_name) = 'phctc ext') or         (:p_country = 'my' , upper(pet.element_name) = 'myctc ext') or         (:p_country = 'cn' , upper(pet.element_name) = 'cnctc ext')      )      , paaf.grade_id = pg.grade_id 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -