You need to test for $selection=="", either in an if after the ns_db select,
or as the first part of the while.

Jim


>
> Using AOLserver 3.3.1 with the postgres driver from openacs.org
>
> the following code gives me the error if there are no rows:
>
> exception NSDB, "Query was not a statement returning rows.")
>          while executing...
>
> --
> set selection [ns_db select $db $sql]
>
> set list_to_return [list]
> while {[ns_db getrow $db $selection]} {
>   lappend list_to_return [ns_set value $selection 0]
> }
> --
>
> It works fine if there are rows returned.
> I would have expected the 'ns_db select' to be ok but get 0 back from the
> first call to 'ns_db  getrow'
>
> I would like to return an empty list if there are now rows matching the
> query.
>
> Any suggestion/code snippets? Surely the OpenACS team has dealt with this.
>
>
> ------
> Keith Paskett                        [EMAIL PROTECTED]
> Space Dynamics Laboratory            PGP or GPG encrypted mail preferred
> 1695 North Research Parkway          435-797-4195
> Logan, Utah 84341
>

Reply via email to