I'm trying to create a procedure that takes a parameter (ID number) and output some information about that particular item. Assume that I have two tables: product( id, name, desc, price) line_item (prod_id, total, quantity, cust_id)
This is what I have so far:
CREATE OR REPLACE PROCEDURE product_query (p_id IN Number)
RETURN NUMBER
IS
v_product_id NUMBER;
v_description NUMBER;
v_sub NUMBER;
v_total_quantity NUMBER;
v_order_count NUMBER;
BEGIN
SELECT p.product_id, sum(l.subtotal), sum(l.quantity), count(*)
INTO v_product_id, v_sub, v_total_quantity, v_order_count
FROM line_item l, product p
WHERE p.product_id = p_id
AND
l.product_id = l.product_id
group by p.product_id;
DBMS_OUTPUT.PUT_LINE('ID: ' || p_product_id);
DBMS_OUTPUT.PUT_LINE('Subtotal: ' || v_sub);
DBMS_OUTPUT.PUT_LINE('Total Qt: ' || v_total_quantity);
DBMS_OUTPUT.PUT_LINE('Total Order: ' || v_order_count);
END product_query;
But it doesn't display any output. I don't see any issue with the code. Should I change the way I output the information? Is there a better way than DBMS_OUTPUT.PUT_LINE? Thanks,