- let id = int_of_string (q#param "id") in
- let sth = dbh#prepare_cached "select coalesce (name, name_deleted)
- from images
- where hostid = ? and id = ?" in
- sth#execute [`Int hostid; `Int id];
-
- let name = sth#fetch1string () in
+ let id = Int32.of_string (q#param "id") in
+ let name = Option.get (
+ List.hd (
+ PGSQL(dbh)
+ "select coalesce (name, name_deleted)
+ from images
+ where hostid = $hostid and id = $id"
+ )
+ ) in