I know I could do the following with a inner join and a select with a correspondence table, but would rather have a function.
Let's says I have a query such as select * from foobar where is_valid in ('yes', 'no'). Unfortunately foobar.is_valid is an integer, 0 or 1 only.
I'ld like to create a function that maps the varchar to integers, something like select * from foobar where is_valid in fn_yesno_to_int('yes', 'no'). Is this even possible?
I'm not at liberty to change the in clause to something else, nor am I at liberty to call the function for each value in the in clause (no in (func('yes'), func('no'))).
My last resort would be to create a correspondence table such as {{0, 'no'}, {1, 'yes'}} and use it and drop the idea of using a function. Another, probably better, option would be to flip the issue around and call the function on foobar.is_valid mapping the 0,1 to no,yes; but I'm very curious to know if the function taking an array and returning an array in my case is even possible.
in (to= any (?