oracle寫儲存過程
阿新 • • 發佈:2018-12-21
1儲存過程主體
--儲存過程,傳入引數,求要求的商品總價 CREATE OR REPLACE PROCEDURE P_PRO ( P_NAME VARCHAR2, U_NAME VARCHAR2 ) AS A_OVER NUMBER; BEGIN SELECT B.PRODUCT_NUM*B.PRICE INTO A_OVER FROM USER_M A, PRODUCT_RELEASE B WHERE A.USER_ID=B.PRODUCT_ID AND B.PRODUCT_NAME=P_NAME AND A.USER_NAME=U_NAME; DBMS_OUTPUT.PUT_LINE(A_OVER); EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('NO_DATA_FOUND'); END P_PRO;
2.呼叫儲存過程
DECLARE N VARCHAR2(20); P VARCHAR2(20); BEGIN N:='護膚水'; p:='張力'; P_PRO(P_NAME=>n, U_NAME=>p ); END;