Please see my post regarding the query extractor, which will create first-cut queryfiles for you. Download it and read my "README_PORTING" file.
I just uploaded this piece of code earlier today, however I did mention the existence of the query extractor in the thread where you mentioned that you'd started doing some porting. I believe I mentioned that we were waiting for it before getting started on query porting in a big way.
We've been waiting for it to avoid the exact tedium you describe.
As far as dynamic queries you can just keep the Tcl code in the query. The query dispatcher returns the query completed with the embedded Tcl, and the db API executor does a subst on the query in the caller's context. In other words it does exactly what it did when inline.
We don't have a clean solution where the dynamic query is db-dependent. In these (rare) cases we probably will need to check the db_type in the .tcl file, as gross as that is (unless anyone has a better idea).