I agree with Robert that having three files for each page quickly becomes a hassle, and would make the learning curve very steep. I seriously like the idea of a query dispatcher, though.
Wouldn't it be more convenient create something along the lines of the proc_doc scheme?
proc_sql { rdbms version query_proc } {
if { rdbms and version match this_install} {
register_query query_proc ;# or something
}
}
You could then either execute the query just by Tcl function name, which would require some smart source file query ordering so that the most specific query comes first upon sourcing of the library. Or you could execute by calling the query dispatcher (or a hybrid of the two). Sadly, we lose the ability to resource the query after change - forcing us to keep reloading nsd.
I know that this could lead to a large Tcl library, but some said (this week IIRC) hardware is cheap, programmers are expensive.
Excuse my poor knowledge of Tcl or (Open)ACS if this is not at all possible.