2

I have created an enum type in Postgres:

CREATE TYPE myenum AS ENUM ('a', 'b', 'c', 'd');

I have created a function:

CREATE OR REPLACE FUNCTION public.mystore(type myenum)

Now in the stored procedure how I can check if a type is 'a' or 'b' like

if(type = myenum.a or type =  myenum.b) then
   ...
end if;

In fact the last line of code is not working.

2 Answers 2

3
IF (type = 'a' OR type = 'b') THEN
  ...
END IF;
Sign up to request clarification or add additional context in comments.

Comments

2

Just use a string literal:

WHERE type = 'a' OR type = 'b'

Or:

WHERE type IN ('a', 'b')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.