SPOOL /Users/gongjiaxi/Desktop/solution2
SET ECHO ON
SET FEEDBACK ON
SET LINESIZE 100
SET PAGESIZE 200
SET SERVEROUTPUT ON
create PROCEDURE INSERT_ORDER_DETAIL(order_id ORDER_DETAIL.ORDER_ID%TYPE,
product_name ORDER_DETAIL.PRODUCT_NAME%TYPE,
unit_price ORDER_DETAIL.UNIT_PRICE%TYPE,
quantity ORDER_DETAIL.QUANTITY%TYPE,
discount ORDER_DETAIL.DISCOUNT%TYPE)
IS
discontinued PRODUCT.DISCONTINUED%TYPE;
BEGIN
IF discontinued = 'N' THEN
INSERT INTO ORDER_DETAIL(ORDER_ID, PRODUCT_NAME, UNIT_PRICE, QUANTITY, DISCOUNT)
VALUES (order_id, product_name, unit_price, quantity, discount);
end if;
IF discontinued = 'Y' THEN
DBMS_OUTPUT.PUT_LINE('The product is not availiable');
end if;
end;
/
EXECUTE INSERT_ORDER_DETAIL(1000,'Chai',18.00,1002,0.9);
EXECUTE INSERT_ORDER_DETAIL(1000,'Alice Mutton', 39.00,1000,0.8);
SPOOL OFF
But the result is
Procedure INSERT_ORDER_DETAIL compiled
SQL> EXECUTE INSERT_ORDER_DETAIL(1000,'Chai',18.00,1002,0.9);
PL/SQL procedure successfully completed.
SQL> EXECUTE INSERT_ORDER_DETAIL(1000,'Alice Mutton', 39.00,1000,0.8);
PL/SQL procedure successfully completed."
One of the two pieces of data I executed should insert one piece of data into the table, and the other one should call DBMS_OUTPUT. But none of them succeeded.