>>The gather in a function is actually the only simple and elegant solution that I saw here. Besides, there's no danger of overstepping any outside variables, as parameters always hide any variable with the same name existing in the caller or above. This has been so since the days of foxplus (learned that the hard way).
Sure- we all had to understand the whole pass by value/reference in the days when the number of variables was limited and passing by value could double the number. Open dbfs/cursors was worse- not everybody will remember when the number of open aliases was limited to 25! For nostalgia, consider that myalias->myfield works to this day.
I thought of another way to abstract the scenario: standardize your Views with blank placeholder fields- e.g.
select *,space(25) as FIELD1...
so you can insert or replace at will. That's assuming there isn't a way to avoid the issue in the first place!
However, it sounds as if the issue was solved with a single IF with 2 insert statements which isn't so tough to maintain.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us."
-- Shakespeare: Coriolanus, Act 1, scene 1