CREATE OR replace FUNCTION Ord_ship_se (p_basketid IN bb_basket.idbasket%TYPE)
RETURN VARCHAR2
IS
lv_stat VARCHAR2(10);
lv_numdays CHAR;
lv_ordered bb_basket.dtordered%TYPE;
lv_created bb_basket.dtcreated%TYPE;
BEGIN
SELECT dtcreated,
dtordered
INTO lv_created, lv_ordered
FROM bb_basket
WHERE p_basketid = idbasket;
lv_numdays := To_char(lv_created - lv_ordered);
IF lv_numdays = 1 THEN
lv_stat := 'OK';
ELSE
lv_stat := 'CHECK';
END IF;
RETURN lv_stat;
END;
The above code calculates the number of days between the creation date and shipping date. I'm trying to create an anonymous block to test the outcome.
The idstage
column of the BB_BASKETSTATUS
table indicates a shipped item with the value 5, and the DTSTAGE
column is the shipping date. The dtordered
column of the BB_BASKET
table is the order date.
This is what I have so far
DECLARE
lv_numDays CHAR;
lv_stat VARCHAR2(12);
BEGIN
lv_stat := ORD_SHIP_SE(lv_numDays);
DBMS_OUTPUT.PUT_LINE(lv_stat);
END;
Why I keep getting error ORA-01403: no data found at line 10 in ord_ship_se
?