you wrote: "avoid catch ?"
Yes, avoiding catch is in general a good strategy. One thing is replace the all-exceptions-swallowing catch
by an ad_try
, at least in situations, where meaningful error codes are used (which is not the case for current db_*
commands).
But notice that this exception is only raised by by db_1row
, the function db_0or1row
returns exactly such a value expressing success or failure. Follow these guidelines:
- SQL query has to return exactly 1 tuple:
db_1row
- otherwise something is broken
- SQL query may return at most 1 tuple:
db_0or1row
- both outcomes are permissible
- all other cases see previous post in this thread
Concerning error with lmap
: Until about tree years ago, OpenACS hat an ad_proc named lmap
, which was nowhere used, but conflicts with the Tcl 8.6 built in with the same name (released 2012) [1]. Therefore, the proc was move to the acs-outdated package. Your error indicates that you are using such an old version or you are requiring acs-outdated. You should consider updating.
Below is a simple version of lmap
implemented by Richard Suchenwirth. If you overload the lmap in your system with this version, the error will go away.
proc lmap {_var list body} {
upvar 1 $_var var
set res {}
foreach var $list {lappend res [uplevel 1 $body]}
set res
}
[1] https://www.tcl.tk/man/tcl/TclCmd/lmap.htm