Forum OpenACS Q&A: error handling in db_1row

Collapse
Posted by Jay Dubanik on
Can somebody tell me how do you handle error in db_1row when "Query did not return any rows"?

Or should I use something else when selecting only one row from db and want catch error in case there is no row returned.

Collapse
Posted by Vinod Kurup on
Hi Janus,

I think you want db_0or1row

Collapse
Posted by Don Baccus on
To expand on Vinod's reference, call db_0or1row in an "if" statement.  It returns an error if multiple rows are returned,  true if one row is returned, false if no row is returned.

You don't want to catch on db_1row because you can't differentiate between its failing because no row or many rows triggered the error ...