Skip to main content

DEFINE PARAM statement

The DEFINE PARAM statement allows you to define global (database-wide) parameters that are available to every client.

Requirements

Statement syntax

SurrealQL Syntax
DEFINE PARAM [ IF NOT EXISTS ] $@name VALUE @value;

Example usage

Below shows how you can create a parameter using the DEFINE PARAM statement.

DEFINE PARAM $endpointBase VALUE "https://dummyjson.com";

Then, simply use the global parameter like you would with any variable.

RETURN http::get($endpointBase + "/products");

Using IF NOT EXISTS clause Since 1.3.0

The IF NOT EXISTS clause can be used to define a param only if it does not already exist. If the param already exists, the DEFINE PARAM statement will return an error.

-- Create a PARAM if it does not already exist
DEFINE PARAM IF NOT EXISTS $example VALUE 123;