I created a function to calculate total amount (shipping + subtototal) for customer If customer isn't cerated I want to see in the output error
DBMS_OUTPUT.PUT_LINE('IDCUSTOMER: ' || customer_id || 'This ID does not exist!');
But when I run code, I don't see in the output error. What I do wrong?
CREATE OR REPLACE FUNCTION calculate_sub_withoout_ship
(customer_id bs_basket.idcustomer%type)
RETURN NUMBER IS
sub_calc NUMBER := 0;
BEGIN
SELECT SUM(subtotal + tax)
INTO sub_calc
FROM bs_basket
WHERE idcustomer = customer_id;
RETURN sub_calc;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('IDCUSTOMER: ' || customer_id ||'This ID does not exist!');
END;
/
SELECT calculate_sub_withoout_ship(1000) FROM dual;
I get NULL and I don't see error.