Hi all, I have the following defined in my database:
CREATE TYPE side AS ENUM ('right', 'left');
And I've defined a function that with a parameter of this type.
CREATE OR REPLACE FUNCTION test_input ( p_side side ) ...
Now I test the function with an invalid value:
db=# select test_input('blue');
ERROR: invalid input value for enum side: "blue"
I want to trap the exception in my function
EXCEPTION
WHEN ??? THEN
RAISE EXCEPTION ...
I tried the obvious INVALID_INPUT_VALUE with no success.
Two questions:
1) What is the actual name of the condition (and, yes, I looked through appendix A trying to figure it out) for invalid enum input?
2) Is there a way to retrieve the error code so that I don't have to guess at the condition name? (I've been playing this game a lot with other exceptions and I don't understand WHY the condition or code isn't provided when an untrapped error occurs) Clearly, I'm missing something!
As always, help or informative redirects muchly appreciated!
- Leon