My bad. Anything wrong with doing it in the insert command itself? The logic to populate the columns is very simple. Perhaps, creating check constraints will be a very good idea to enforce data integrity and help optimizer a little bit.