I have a table with field "mac" of type MACADDR. Now I would like to treat a situation (probably with trigger?) when somebody inserts empty string instead of mac address. I would like to turn this empty string to NULL, so postgresql will not complain: invalid input syntax for type macaddr: ""
What I have now in trigger function is this:
IF CHAR_LENGTH(NEW.mac) = 0 THEN
NEW.mac := NULL;
END IF;
But it does not seem to work. What would you do, if you want to treat this on DB level?
Thank you very much. -Jan
PS: I am a postgresql newbie. But a fascinated one :)