> Anyway, It will be awesome if we have a sequence data type in a future > version of postgresql. They will solve a lot of problems similar to this > one.
This clause creates the column as an identity column. It will have an implicit sequence attached to it and the column in new rows will automatically have values from the sequence assigned to it. "
What you want is a built in method to pull from different sequences depending on the value of another column or values from multiple columns in the same table.