I need to use a map to assign a specific value yearbased on a value year_code. At the moment, I have a big if statement, which is obviously difficult to maintain.
IF year_code = 'Y' THEN year := 2000; END IF;
IF year_code = '1' THEN year := 2001; END IF;
IF year_code = '2' THEN year := 2002; END IF;
The obvious solution would be to use a table and select a value, however, I was instructed to save all this within the framework of one postgres function in order to quickly execute it. Later I plan to store all this in tables.
So, I can create a temporary map and select it to get the value for the year. Actually, I just want to clear this ugly code. Thank.
source
share