Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE CREATE_PERSON_SP (
  2. p_person_ID VM_PERSON.PERSON_ID%TYPE,
  3. p_person_email VM_PERSON.PERSON_EMAIL%TYPE,
  4. P_person_given_name VM_PERSON.PERSON_GIVEN_NAME%TYPE,
  5. p_person_surname VM_PERSON.PERSON_SURNAME%TYPE,
  6. p_person_phone VM_PERSON.PERSON_PHONE%TYPE
  7. )
  8. IS
  9. ex_error exception;
  10. p_count number (10);
  11. err_msg_txt varchar(100) :=null;
  12.  
  13. BEGIN
  14.  
  15. select count (*)
  16. into p_count
  17. from VM_PERSON
  18. where p_person_email = PERSON_EMAIL;
  19.  
  20. if p_count > 0
  21. then
  22. err_msg_txt := 'The email already exists, try another one ';
  23. raise ex_error;
  24. elsif p_person_email is null then
  25. err_msg_txt := 'the email must not be null.';
  26. raise ex_error;
  27. end if;
  28.  
  29. INSERT INTO VM_PERSON ("PERSON_ID", "PERSON_EMAIL", "PERSON_GIVEN_NAME", "PERSON_SURNAME", "PERSON_PHONE")
  30. VALUES (p_person_id, p_person_email, p_person_given_name, p_person_surname, p_person_phone);
  31. COMMIT;
  32.  
  33. Exception
  34. when ex_error then
  35. dbms_output.put_line(err_msg_txt);
  36. rollback;
  37. when others then
  38. dbms_output.put_line(' the error code is: ' || sqlcode);
  39. dbms_output.put_line(' the error msg is: ' || sqlerrm);
  40. rollback;
  41.  
  42. END;
  43. /
  44. BEGIN
  45. CREATE_PERSON_SP(6,'OLE@MORTEN.org','Ali','Amin','+47 91919191');
  46. END;
  47. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement