I want to print a tax report using Oracle Apex using plsql dynamic content.
The result must be for all clients during a certain period, and this period is determined by two items, from_date and to_date
An error appears when the exact drag returns (SQL Error: ORA-01422: exact fetch returns more than requested number of rows)
I tried to do it with another condition, which is the cust_id, but I got the same error
Any Help?
this is a part of my query
<code> htp.p('<tr>');
htp.p('<th>م</th>');
htp.p('<th> كود الفاتورة</th>');
htp.p('<th> تاريخ الفاتورة</th>');
htp.p('<th> اجمالي الفاتورة</th>');
htp.p('<th> اجمالي الضريبة</th>');
htp.p('<th> اسم العميل</th>');
htp.p('<th> كود العميل</th>');
htp.p('<th> الرقم الضريبي للعميل</th>');
htp.p('</tr>');
FOR item_row IN invoice_details LOOP
BEGIN
select z.inv_code,z.inv_date,z.inv_total,z.vta_total,cust_name,cust_id,cust_vat
INTO V_INV_CODE ,v_inv_date,v_inv_total,v_vta_total,V_CUST_NAME,V_CUST_ID,V_CUST_VAT
from INV_MASTER z,CRM_CUSTOMER CRM
where inv_date between :P87_FROM_DATE and :P87_TO_DATE
--and z.customer_name = CRM.cust_id
order by inv_code;
htp.p('<tr>');
htp.p('<td>' || counter || '</td>');
htp.p('<td>' || item_row.inv_code|| '</td>');
htp.p('<td>' || item_row.inv_date || '</td>');
htp.p('<td>' || item_row.inv_total || '</td>');
htp.p('<td>' || item_row.vta_total || '</td>');
htp.p('<td>' || item_row.cust_name || '</td>');
htp.p('<td>' || item_row.cust_id || '</td>');
htp.p('<td>' || item_row.cust_vat || '</td>');
htp.p('</tr>');
counter := counter + 1; ```
and this is the error i had got[![the error][1]][1]
[1]: https://i.sstatic.net/26fF48aM.png
</code>
<code> htp.p('<tr>');
htp.p('<th>م</th>');
htp.p('<th> كود الفاتورة</th>');
htp.p('<th> تاريخ الفاتورة</th>');
htp.p('<th> اجمالي الفاتورة</th>');
htp.p('<th> اجمالي الضريبة</th>');
htp.p('<th> اسم العميل</th>');
htp.p('<th> كود العميل</th>');
htp.p('<th> الرقم الضريبي للعميل</th>');
htp.p('</tr>');
FOR item_row IN invoice_details LOOP
BEGIN
select z.inv_code,z.inv_date,z.inv_total,z.vta_total,cust_name,cust_id,cust_vat
INTO V_INV_CODE ,v_inv_date,v_inv_total,v_vta_total,V_CUST_NAME,V_CUST_ID,V_CUST_VAT
from INV_MASTER z,CRM_CUSTOMER CRM
where inv_date between :P87_FROM_DATE and :P87_TO_DATE
--and z.customer_name = CRM.cust_id
order by inv_code;
htp.p('<tr>');
htp.p('<td>' || counter || '</td>');
htp.p('<td>' || item_row.inv_code|| '</td>');
htp.p('<td>' || item_row.inv_date || '</td>');
htp.p('<td>' || item_row.inv_total || '</td>');
htp.p('<td>' || item_row.vta_total || '</td>');
htp.p('<td>' || item_row.cust_name || '</td>');
htp.p('<td>' || item_row.cust_id || '</td>');
htp.p('<td>' || item_row.cust_vat || '</td>');
htp.p('</tr>');
counter := counter + 1; ```
and this is the error i had got[![the error][1]][1]
[1]: https://i.sstatic.net/26fF48aM.png
</code>
htp.p('<tr>');
htp.p('<th>م</th>');
htp.p('<th> كود الفاتورة</th>');
htp.p('<th> تاريخ الفاتورة</th>');
htp.p('<th> اجمالي الفاتورة</th>');
htp.p('<th> اجمالي الضريبة</th>');
htp.p('<th> اسم العميل</th>');
htp.p('<th> كود العميل</th>');
htp.p('<th> الرقم الضريبي للعميل</th>');
htp.p('</tr>');
FOR item_row IN invoice_details LOOP
BEGIN
select z.inv_code,z.inv_date,z.inv_total,z.vta_total,cust_name,cust_id,cust_vat
INTO V_INV_CODE ,v_inv_date,v_inv_total,v_vta_total,V_CUST_NAME,V_CUST_ID,V_CUST_VAT
from INV_MASTER z,CRM_CUSTOMER CRM
where inv_date between :P87_FROM_DATE and :P87_TO_DATE
--and z.customer_name = CRM.cust_id
order by inv_code;
htp.p('<tr>');
htp.p('<td>' || counter || '</td>');
htp.p('<td>' || item_row.inv_code|| '</td>');
htp.p('<td>' || item_row.inv_date || '</td>');
htp.p('<td>' || item_row.inv_total || '</td>');
htp.p('<td>' || item_row.vta_total || '</td>');
htp.p('<td>' || item_row.cust_name || '</td>');
htp.p('<td>' || item_row.cust_id || '</td>');
htp.p('<td>' || item_row.cust_vat || '</td>');
htp.p('</tr>');
counter := counter + 1; ```
and this is the error i had got[![the error][1]][1]
[1]: https://i.sstatic.net/26fF48aM.png