UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Quick Start
  • Procedure Management
  • Calling Procedures
    • Procedure Body Language
    • Data Operations
    • Control Flow
    • Iterators and Traversal
    • Parallel Execution
    • Built-in Functions
    • Expressions
  • Algorithm Examples
  1. Docs
  2. /
  3. Stored Procedures
  4. /
  5. Procedure Body

Expressions

Complete reference for all expression types available in stored procedures.

Arithmetic Operators

OperatorDescriptionExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Moduloa % b
^Exponentiationa ^ b
Procedure Body Language
LET sum = x + y
LET ratio = count / total
LET remainder = i % 2
LET squared = x ^ 2

Comparison Operators

OperatorDescriptionExample
=Equala = b
<>Not equala <> b
!=Not equal (alias)a != b
<Less thana < b
>Greater thana > b
<=Less than or equala <= b
>=Greater than or equala >= b

Logical Operators

OperatorDescriptionExample
ANDLogical ANDa AND b
ORLogical ORa OR b
NOTLogical NOTNOT a
XORExclusive ORa XOR b
Procedure Body Language
IF age > 18 AND active = true {
    PRINT 'Active adult'
}

IF score > 0.9 OR rank < 10 {
    PRINT 'Notable'
}

IF NOT visited {
    n.visited = true
}

String Concatenation

Use || for string concatenation:

Procedure Body Language
LET greeting = 'Hello, ' || name || '!'
LET info = 'Count: ' || TOSTRING(count) || ', Score: ' || TOSTRING(score)

NULL Checks

ExpressionDescription
expr IS NULLTrue if value is NULL
expr IS NOT NULLTrue if value is not NULL
Procedure Body Language
IF n.email IS NOT NULL {
    PRINT n.email
}

IF p IS NULL {
    PRINT 'No path found'
}

IN / NOT IN

Check membership in a list:

Procedure Body Language
IF n._id IN ['alice', 'bob', 'charlie'] {
    PRINT 'Found known person'
}

IF nodeLabel NOT IN excluded_labels {
    -- process
}

CASE Expression

Simple CASE

Procedure Body Language
LET category = CASE status
    WHEN 'active' THEN 'A'
    WHEN 'pending' THEN 'P'
    WHEN 'inactive' THEN 'I'
    ELSE 'U'
END

General CASE

Procedure Body Language
LET tier = CASE
    WHEN score > 0.9 THEN 'platinum'
    WHEN score > 0.7 THEN 'gold'
    WHEN score > 0.5 THEN 'silver'
    ELSE 'bronze'
END

List Comprehension

Build a new list from an existing list by iterating and optionally filtering / transforming. The base form names the loop variable, then IN <list>, with an optional WHERE/FILTER clause and an optional | <expr> mapping clause.

FormMeaning
[ <var> IN <list> ]Iterate; result is the input list
[ <var> IN <list> | <expr> ]Map each element through <expr>
[ <var> IN <list> WHERE <condition> ]Keep elements matching <condition>
[ <var> IN <list> WHERE <condition> | <expr> ]Filter, then map
[ <var> IN <list> FILTER <condition> ]Same as WHERE form
[ <var> IN <list> FILTER <condition> | <expr> ]Same as WHERE + map form

Transform

Procedure Body Language
-- Map each element through an expression
LET doubled = [x IN RANGE(1, 6) | x * 2]
LET names = [n IN friends | n.name]

Filter and Transform

Procedure Body Language
-- Filter, then map
LET active_names = [n IN friends WHERE n.active = true | n.name]

-- With complex expressions on either side
LET scores = [n IN nodes WHERE OUT_DEGREE(n) > 5 | GET_SLICE_PROP(n._internal_id, 'rank')]

WHERE and FILTER are interchangeable inside a list comprehension.

REDUCE

Aggregate a list into a single value:

Procedure Body Language
LET total = REDUCE(acc = 0, x IN numbers | acc + x)
LET product = REDUCE(acc = 1, x IN values | acc * x)

Subscript Access

List Indexing

Procedure Body Language
LET first = myList[0]
LET third = myList[2]

List Slicing

Procedure Body Language
LET sub = myList[1:3]    -- elements at index 1 and 2
LET head = myList[0:5]   -- first 5 elements

Map Access

Procedure Body Language
LET v = myMap['key']
LET name = record['name']

Property Access

Procedure Body Language
-- Node properties
LET name = n.name
LET id = n._id
LET internal = n._internal_id
LET nodeLabels = n._labels

-- Edge properties
LET weight = e.weight
LET src = e._from
LET dest = e._to

Path values do not support property-style access — use functions instead:

Built-inReturns
LENGTH(path) or PATH_LENGTH(path)INTEGER hop count
NODES(path)LIST<NODE> of nodes along the path
RELATIONSHIPS(path)LIST<EDGE> of edges along the path
GQL
LET len = LENGTH(p)
LET ns = NODES(p)
LET es = RELATIONSHIPS(p)

Subquery Expression

Use a subquery as an expression to assign its result to a variable:

Procedure Body Language
LET result = (MATCH (n:Person WHERE n.age > 30) RETURN COUNT(n) AS cnt)

This returns the result of the inner query as a value.

EXISTS / NOT EXISTS

Check whether a subquery returns any results:

Procedure Body Language
IF EXISTS {
    MATCH (n)-[:KNOWS]->(m WHERE m.name = 'Alice')
} {
    PRINT 'Knows Alice'
}

IF NOT EXISTS {
    MATCH (n)-[:BLOCKED]->(m)
} {
    PRINT 'Not blocked'
}

MAP Expression

Transform each element of a list:

Procedure Body Language
LET result = MAP(x IN myList | x * 2)

Operator Precedence

From highest to lowest:

PrecedenceOperators
1 (highest). (property access), [] (subscript)
2^ (exponentiation)
3Unary -, NOT
4*, /, %
5+, -
6`
7=, <>, !=, <, >, <=, >=
8IS NULL, IS NOT NULL, IN, NOT IN
9AND
10XOR
11 (lowest)OR

Use parentheses to override default precedence:

Procedure Body Language
LET result = (a + b) * (c - d)
IF (x > 0 AND y > 0) OR z = 0 { ... }