CREATE FUNCTION

Creates a user-defined function.

Basic Syntax

CREATE FUNCTION [IF NOT EXISTS] function_name (
    param1 data_type,
    param2 data_type,
    ...
)
RETURNS return_type
LANGUAGE RHAI AS 'code';

Parameters

  • function_name: Name of the function
  • param1, param2, …: Parameter names and their data types
  • return_type: Return value data type
  • LANGUAGE RHAI: Specifies the language
  • AS ‘code’: The function implementation code

Supported Data Types

  • INTEGER - 64-bit signed integers
  • FLOAT - 64-bit floating-point numbers
  • TEXT - UTF-8 text strings
  • BOOLEAN - True/false values
  • TIMESTAMP - Date and time values
  • JSON - JSON documents

Examples

-- Simple arithmetic function
CREATE FUNCTION add_numbers(a INTEGER, b INTEGER)
RETURNS INTEGER
LANGUAGE RHAI AS 'a + b';

-- String manipulation
CREATE FUNCTION greet(name TEXT)
RETURNS TEXT
LANGUAGE RHAI AS '"Hello, " + name + "!"';

See User-Defined Functions for detailed documentation.


Copyright © 2025-2026 Oxibase Contributors. Gabriel Maeztu.