Posted By

wh0emPah on 04/02/10


Tagged


Versions (?)

zerfz


 / Published in: PL/SQL
 

  1. CREATE OR REPLACE PROCEDURE P4_2_VOEG_ORDER_TOE(
  2. P_ID IN S_ORD.ID%TYPE
  3. , P_CUSTOMERID IN S_ORD.CUSTOMER_ID%TYPE
  4. , P_SALES_REP_ID IN S_ORD.SALES_REP_ID%TYPE
  5. , P_DATE_ORDERED IN S_ORD.DATE_ORDERED%TYPE
  6. , P_PAYMENT_TYPE IN S_ORD.PAYMENT_TYPE%TYPE
  7. ) AS
  8. V_JOBTITLE S_EMP.TITLE%TYPE;
  9.  
  10. E_NOPARENT EXCEPTION;
  11. PRAGMA EXCEPTION_INIT(E_NOPARENT,-2291);
  12. e_check_constraint EXCEPTION;
  13. PRAGMA EXCEPTION_INIT(E_CHECK_CONSTRAINT,-2290);
  14.  
  15. E_SALES_REP_ERROR EXCEPTION;
  16.  
  17. SELECT UPPER(TITLE)
  18. INTO v_jobtitle
  19. FROM S_EMP
  20. WHERE ID = p_sales_rep_id;
  21.  
  22. IF V_JOBTITLE = 'SALES REPRESENTATIVE' THEN
  23. INSERT INTO S_ORD(id, customer_id, SALES_REP_ID, DATE_ORDERED, PAYMENT_TYPE)
  24. VALUES(p_id, p_customerid, p_sales_rep_id, p_date_ordered, p_payment_type);
  25. DBMS_OUTPUT.PUT_LINE('Order toegevoegd');
  26. RAISE E_SALES_REP_ERROR;
  27. DBMS_OUTPUT.PUT_LINE('ID van dit order bestaat al');
  28. WHEN E_NOPARENT THEN
  29. DBMS_OUTPUT.PUT_LINE('FK Is foutief');
  30. WHEN E_CHECK_CONSTRAINT THEN
  31. DBMS_OUTPUT.PUT_LINE('Het type van betaling moet CASH OF CREDIT ZIJN');
  32. WHEN E_SALES_REP_ERROR THEN
  33. DBMS_OUTPUT.PUT_LINE('CUSTUMERID Moet een sales rep zijn.');
  34. END P4_2_VOEG_ORDER_TOE;

Report this snippet  

You need to login to post a comment.