A better solution that I came up with is to use a sequence. These are stateful and can be access in the entire scheme.
I create a sequence that counts from 0 to 1 and then starts over. I then cast the result to char and then to boolean.
CREATE SEQUENCE double_first_name_toggle MINVALUE 0 MAXVALUE 1 CYCLE; SELECT nextval('double_first_name_toggle')::char::boolean into double_first_name;
Every time the SELECT nextval('double_first_name_toggle')::char::boolean into double_first_name; is called it the result is the opposite from last time.
This is now used in the name function and no parameter needs to be sent in.
No comments:
Post a Comment