Hi Mansi,
you have been close! It could work with the following query (I haven't tried it out, though):
_ get_query_result.xq ____________________
declare variable $n external; declare option output:item-separator "
";
let $aList := for $name in db:list() let $db := db:open($name) return xquery:eval($n, map { '': $db })
return distinct-values($aList) ______________________________________
In this code, I'm opening the database in the main loop, and I then bind it to the empty string. This way, the database will be the context of the query to be evaluated query, and you won't have to deal with bugs that arise from the concatenation of "db:open" and the query string.
- Can we assign dynamic values as a value to a map's key ?
- Can I map have more than one key, in query:eval ?
This is both possible. As you see in the following query, you'll again have to declare the variables that you want to bind. I agree this causes a lot of code, so we may simplify it again in a future version of BaseX: ______________________________________
let $n := "/a/b/c" for $db in db:list() let $query := "declare variable $db external; " || "db:open($db)" || $n return xquery:eval($query, map { 'db': $db, 'query': $n }) ______________________________________
Best, Christian