- let c = pgc () in
- let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ s ^ "'")) in
- let q = "select t" ^ tv ^ "." ^ prop ^ " from t" ^ tv ^ " where prop_id= '" ^ mpid ^ "'" in
- print_endline q;
+ let c = MQIConn.pgc handle in
+ let quoted_s =
+ Str.global_substitute (Str.regexp "'")
+ (function _ -> "\\'") s in
+ let tv = pgresult_to_string (c#exec ("select distinct id from registry where uri='" ^ quoted_s ^ "' order by id")) in
+ let q = "select distinct t" ^ tv ^ "." ^ prop ^ " from t" ^ tv ^ " where prop_id= '" ^ mpid ^ "' order by t" ^ tv ^ "." ^ prop in
+ prerr_endline q;