Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. VARIABLE g_message VARCHAR2(250)
  2.  
  3. DEFINE p_sal = 12000
  4.  
  5. DECLARE
  6. v_name employees.last_name%TYPE;
  7. v_sal employees.salary%TYPE := &p_sal;
  8.  
  9. table_does_not_exist exception;
  10. PRAGMA EXCEPTION_INIT(table_does_not_exist, -942);
  11.  
  12. BEGIN
  13.  
  14. SELECT last_name INTO v_name FROM employe WHERE salary = v_sal;
  15.  
  16. DBMS_OUTPUT.put_line(v_name);
  17.  
  18.  
  19. EXCEPTION
  20.  
  21. WHEN table_does_not_exist then
  22. :g_message := 'table dose not exist';
  23.  
  24.  
  25. WHEN NO_DATA_FOUND THEN
  26. :g_message := 'No employee with a salary of '||TO_CHAR(v_sal);
  27.  
  28. WHEN OTHERS THEN
  29. :g_message := 'Some other error occurred.';
  30. END;
  31. /
  32. PRINT g_message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement