Search code examples
oracleoracle11goracle10goracle-apexoracle-apex-5.1

Fetch only Number from the value Oracle Apex


I need to fetch only number from the item how to perform that.

For Ex: P2510_PAYMENT_TOTAL = 208.00 Dr

I need to fetch only 208 from the above item how to get it

I am trying to create DA to show error if P2510_SUMMARY_OS_DR <=P2510_PAYMENT_TOTAL

My Dynamic action code

:P2510_PLSQL_ERROR_MESSAGE := NULL;

IF ROUND(:P2510_SUMMARY_OS_DR,2) <= :P2510_PAYMENT_TOTAL THEN

:P2510_PLSQL_ERROR_MESSAGE := 'It looks like the values you''ve entered don''t match.' ||' The value of the Match value must match the value of Outstanding.' ||' Please try again.';

END IF;

But this DA is not working i am getting "PL/SQL: numeric or value error: character to number conversion error"


Solution

  • If item value is 208.00 Dr, then you can't round it ("Dr" isn't numeric, it raises the error).

    Try

    if to_number(substr(:P2510_SUMMARY_OS_DR, 1, instr(:P2510_SUMMARY_OS_DR, ' ') - 1)) <= 
       to_number(:P2510_PAYMENT_TOTAL) 
    then
       ...