>I am considering creating view programatically, instead of saving the definitions in the database. I am not (currently) asking how to do it; I will try to figure it out from the help, first.
>
>I think I may gain some flexibility, like having several slightly different versions of a view (say, with different parameters).
>
>What I do want to ask is:
>
>1) Is it very complicated to create views programatically?
>
>2) Is it worth the trouble? That is, perhaps there are too many problems involved, or perhaps there are better ways to do it.
You got the answers already. I also make the view manually, then run gendbc, then tweak a few things there (check the paths, for one, gendbc doesn't include paths to your tables, which creates problems if they're not all in the same directory).
My addition is to always keep views in a dbc of their own, so when they are created (programmatically) the dbc is created from scratch - I can do that because it has no tables in it. Second, I keep this dbc on user's temp drive, so everybody has one. Third, I re-create it as needed, which means that somewhere in oapp.init I compare the datetime of the executable with the datetime of this dbc, and recreate it as needed. The trouble with creating views programmatically is that there's no NoDataOnLoad for them at the point, so they do take time to get created, as they also open as well. A good workaround, at least for the parametrized ones, is to supply an impossible value for the parameter in the makeview_{name here} routine, so at least it doesn't pull any records, even if it has to open.