You're touching on a couple of problems. To get the wrapper to work, try the following (note the additional backslash). I haven't tried that myself, but I suspect that will work. (You might want to consider wrapping
$code in a catch to ensure you will reach the
ns_db releasehandle statement.)
proc_doc db_with_3x_wrapper { code } {
executes $code in uplevel, after allocating a db handle named $db
} {
uplevel "
db_release_unused_handles
set db [ns_db gethandle]
$code
ns_db releasehandle $db
"
}
Can you say more about what you mean or what you did when you say that you tried different pools? In my experience, I have found the problem where you are asking for a handle from main when one has already been allocated is usually straightforward to correct, once you understand what the error message is telling you. To understand that, I recommend the URL above, as well as the AOLserver documentation for ns_db:
http://www.aolserver.com/docs/tcldev/tapi-c44.htm#172554.