title: How to handle a exception in a SQL function?
body: <p>I wanted to make a function that returns the maximum value between 3 different numbers.</p>
  <p>In case that two of these 3 numbers had the same value, it had to return an exception.</p>
  <p>My code returns the maximum value if the 3 numbers are different, but when two of them are the same, it returns error. What's wrong? Any help? Thank you in advance!!</p>
  <pre><code>CREATE OR REPLACE FUNCTION NUMEROMAYOR1(num1 NUMBER, num2 NUMBER, num3 NUMBER)
  RETURN NUMBER
  IS
  numeromayor NUMBER;
  igualdad EXCEPTION;
  BEGIN
  IF (num1=num2) OR (num1=num3) OR (num2=num3) THEN
     RAISE igualdad;
     END IF;
     IF (num1&gt;num2) AND (num1&gt;num3) THEN
     numeromayor:=num1;
     ELSIF (num3&gt;num2) AND (num3&gt;num1) THEN
     numeromayor:=num3;
     ELSIF (num2&gt;num1) AND (num2&gt;num3) THEN
     numeromayor:=num2;
     END IF;
     RETURN(numeromayor);
     EXCEPTION
     WHEN igualdad THEN
     dbms_output.put_line('Numbers can't be repeated');
     END;
  </code></pre>