Skip to Main Content

SQL & PL/SQL

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 calling a function: ORA-00900: invalid SQL statement

Javier PFeb 11 2020 — edited Feb 11 2020

Hi,

Am getting this error:

Capture.JPG

When calling this function.

I want to see the value it returns to test .

The function is in the Risk_Reclamaciones_pkg

function Calc_Ratio(pDateFrom date,

                            pDateTo    date,

                            pCustomerID number default null,

                            pCompanyID  number default null) return number is

vTotalSales number;

vTotalReturns number;

begin

select nvl(sum(SALES_AMOUNT), 0)

into vTotalSales

from SALES

where SALES_DATE >= pDateFrom and

    SALES\_DATE \<= pDateTo and

    CUSTOMER\_ID = nvl(pCustomerID, CUSTOMER\_ID) and

    COMPANY\_ID = nvl(pCompanyID, COMPANY\_ID);

select nvl(sum(RETURNS_AMOUNT), 0)

into vTotalReturns

from RETURNS

where RETURNS_DATE >= pDateFrom and

    RETURNS\_DATE \<= pDateTo and

    CUSTOMER\_ID = nvl(pCustomerID, CUSTOMER\_ID) and

    COMPANY\_ID = nvl(pCompanyID, COMPANY\_ID);

return (vTotalReturns / NullIf(vTotalSales, 0)) * 100; -- Nullif prevents divide by zero.

end;

/

What could be the problem??

Thanks for any help!

This post has been answered by Anton Scheffer on Feb 11 2020
Jump to Answer
Comments
Post Details
Added on Feb 11 2020
4 comments
713 views