Forum OpenACS Q&A: SQL statement return 0 row
with null value.
Assume there is no user with id = 3 in the table.
Select user_id, count(*) from users where user_id=3 group by use_id;
I face a problem in this type of query where query return 0 row.
Can anyone teach me how to fix it? Thanks for your help
You should handle the empty case in Tcl...
set selection [ns_db 1row $db $sql]
set selection [ns_db 1row $db [db_sql_prep $sql]]
there is why when PG return 0 row, the proc can't handle it.
If I am wrong, please correct me.
I change proc database_to_tcl_string into this format:
set selection [ns_db 0or1row $db $sql]
set selection [ns_db 0or1row $db [db_sql_prep $sql]]
However, it comes out with another error:
Error: invalid set id: ""
invalid set id: ""
"ns_set value $selection 0"
invoked from within
"return [ns_set value $selection 0]..."
Can I know what is the problem