Syntax & Variables
Every OQL statement follows one pattern: VERB operand [modifiers] [SET ?var]. No semicolons. No brackets. No dot notation. Statements chain with AFTER, AND, or OR.
Statement structure
Every statement starts with a verb. The operand is the primary input. Modifiers provide context (WHERE, WITH, AS, INTO, FROM, TO, AT, ON, FORMAT, USING, LIMIT, SORT BY). SET ?var captures the output. SET is optional — omit it when you only need the side effect.
Comments
Block comments use (* ... *). Inline or multi-line.
Block delimiters
OPEN NEST and CLOSE NEST wrap block bodies for control flow, operations, and nested constructs. CLOSE ALL NESTS exits all open blocks at once.
Variable types
| Prefix | Type | Scope |
|---|---|---|
?var | Scalar — mutable, holds any single value | Entire query |
?var (multi) | Multivariable — when AND branches share the same name | Entire query |
!NOW | Unix timestamp fixed at query start | Entire query |
!INDEX | 0-based position in FOREACH | Loop body only |
!VALUE | Current iteration item in FOREACH | Loop body only |
!STATE(IF) | Result of the last IF condition | Block |
!STATE(WHILE) | Current iteration count in WHILE | Loop body only |
!STATE(FOREACH) | Current iteration count in FOREACH | Loop body only |
!REQUEST(path) | URL path — Site Mode only | Entire query |
!REQUEST(method) | HTTP method — Site Mode only | Entire query |
!REQUEST(body) | Raw request body — Site Mode only | Entire query |
!REQUEST(param:name) | Query string param — Site Mode only | Entire query |
!REQUEST(form:field) | Form POST field — Site Mode only | Entire query |
!REQUEST(header:name) | Request header — Site Mode only | Entire query |
!GET(name) | Alias for !REQUEST(param:name) | Entire query |
!POST(field) | Alias for !REQUEST(form:field) | Entire query |
!COOKIE(name) | Request cookie — Site Mode only | Entire query |
!EVENT(key) | Injected event data in WATCH handlers | Handler body only |
String delimiters
Double quotes, single quotes, and backticks are interchangeable. All three produce identical tokens.
Each delimiter is literal inside the other two — no escaping needed across delimiter types:
Backticks are ideal for multi-line strings, HTML, and code — no internal escaping needed:
Welcome!
Your account is ready.
` TO "user@example.com" WITH "Welcome"Scalar variables & scope
Variables set with SET ?name are visible everywhere after the point of assignment — inside OPEN NEST blocks, inside operations, inside loops.
Property access
Access a field on an object or an element of an array using parentheses. Chain them for nested access.
String concatenation
Use & to concatenate values anywhere an expression is accepted — in operands, in modifier values, in SET bindings.
!NOW — fixed timestamp
!NOW is set once at query start and never changes during execution. Use it when you need the same timestamp across multiple steps.