Loading TOC...

MarkLogic Server 11.0 Product Documentation
op:is-defined

op:is-defined(
   $operand as item()
) as map:map

Summary

This function tests whether the value of an expression is null in the row where the expression might be as simple as a column identified by op:col.

Parameters
$operand A boolean expression, such as op:eq or op:not, that might be null.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
import module namespace osem="http://marklogic.com/optic/expression/sem"
     at "/MarkLogic/optic/optic-sem.xqy"; 
     
op:from-literals((
    map:entry("row", 1) => map:with("sparse", 6),
    map:entry("row", 2),
    map:entry("row", 3) => map:with("sparse", 4)
    ))
        => op:select(("row", "sparse", op:as("defcheck",
	               osem:if(op:is-defined(op:col("sparse")), "present", "absent")
	       )))
        => op:result()
 
  

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