select 'person_id:'||ppx.person_id
from per_people_x ppx
, fnd_lookup_values_vl flv
, gl_code_combinations gcc
, ap_invoice_lines_all aila
, ap_invoice_distributions_all aid
where 1=1
and aid.distribution_line_number=1
and ppx.person_id = TO_NUMBER(flv.attribute1)
and flv.lookup_type = 'TEST'
and flv.lookup_code = gcc.segment3
and aila.invoice_id = aid.invoice_id
and gcc.code_combination_id = aid.dist_code_combination_id
and aid.line_type_lookup_code = 'ITEM'
and aila.discarded_flag = 'N'
and flv.ENABLED_FLAG = 'Y'
and aila.invoice_id = :transactionId
AND aid.INVOICE_LINE_NUMBER = aila.LINE_NUMBER
order by aila.line_number asc FETCH FIRST 1 ROW ONLY