Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op:execute

op:execute(
   [$bindings as map:map?],
   [$options as xs:string*]
) as ()

Summary

This method executes the plan. The result is ignored. This function can be used in an Optic Update.

Parameters
$bindings This parameter provides a map with the names and values of placeholder parameters. An error is thrown if a placeholder parameter is not bound.
$options Options as a sequence of string values. Available options are:
  • "trace=ID"

    This parameter outputs the query's plan, optimization and execution details in the log while getting results. ID is the identifier to identify the query in the logs.

  • "optimize=N"

    Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized. The default is 1.

  • "seed=N"

    Sets the seed to use. The default will generate a random seed. Setting it to 0 will behave the same as the default case. The default is 0.

See Also

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $permissions := (map:entry("roleName","rest-reader")=>map:with("capability","read"),
                     map:entry("roleName","rest-writer")=>map:with("capability","update"))
let $doc-descriptors := (
    map:entry("uri", '/optic/update/execute9.xml')
      =>map:with("doc", <doc>execute9</doc>)
      =>map:with("collections", ("execute", "write"))
      =>map:with("metadata", map:entry("time", "2022-10-13T11:00:0"))
      =>map:with("permissions", $permissions)
      =>map:with("quality", 9),
    map:entry("uri", '/optic/update/execute10.xml')
      =>map:with("doc", <doc>execute10</doc>)
      =>map:with("collections", ("execute", "write"))
      =>map:with("metadata", map:entry("time", "2022-10-13T11:00:0"))
      =>map:with("permissions", $permissions)
      =>map:with("quality", 10)
  )
return op:from-doc-descriptors($doc-descriptors)
=>op:write()
=>op:execute()
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

let $permissions := (map:entry("roleName","rest-reader")=>map:with("capability","read"),
                     map:entry("roleName","rest-writer")=>map:with("capability","update"))
let $rows := (
    map:entry("uri", '/optic/update/execute5.xml')
      =>map:with("doc", <doc>execute5</doc>)
      =>map:with("collections", ("execute", "write"))
      =>map:with("metadata", map:entry("time", "2022-10-13T11:00:0"))
      =>map:with("permissions", $permissions)
      =>map:with("quality", 5),
    map:entry("uri", '/optic/update/execute6.xml')
      =>map:with("doc", <doc>execute6</doc>)
      =>map:with("collections", ("execute", "write"))
      =>map:with("metadata", map:entry("time", "2022-10-13T11:00:0"))
      =>map:with("permissions", $permissions)
      =>map:with("quality", 6)
  )
return op:from-param("bindingParam", (), op:doc-col-types())
  =>op:write()
  =>op:execute(map:entry("bindingParam",$rows), ("trace=fromParam", "optimize=1", "seed=2"))
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.