Loading TOC...

MarkLogic 10 Product Documentation
op:bind

op:bind(
   $plan as map:map,
   $columns as columnIdentifier*
) as map:map

Summary

This function adds new columns or modifies existing columns based on expressions while preserving existing unmodified columns in the row set.

Parameters
$plan The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$columns The op:as calls that specify the column name and the expression that constructs the column values.

See Also

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

import module namespace ofn="http://marklogic.com/optic/expression/fn"
    at "/MarkLogic/optic/optic-fn.xqy";

op:from-view("main", "employees")
   => op:bind((
       op:as("FirstName", ofn:substring-before(op:col("FullName"), " ")),
       op:as("LastName",  ofn:substring-after(op:col("FullName"),  " "))
       ))
   => op:order-by("EmployeeID")
   => op:result()
  

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