SQL - CREATE FUNCTION
Creates a new Server-side function. You can execute Functions from SQL, HTTP and Java.
Syntax
CREATE FUNCTION <name> <code>
[PARAMETERS [<comma-separated list of parameters' name>]]
[IDEMPOTENT true|false]
[LANGUAGE <language>]
<name>Defines the function name.<code>Defines the function code.PARAMETERSDefines a comma-separated list of parameters bound to the execution heap. You must wrap your parameters list in square brackets [].IDEMPOTENTDefines whether the function can change the database status. This is useful given that HTTP GET can callIDEMPOTENTfunctions, while others are called by HTTP POST. By default, it is set toFALSE.LANGUAGEDefines the language to use. By default, it is set to JavaScript.
Examples
Create a function
test()in JavaScript, which takes no parameters:orientdb>CREATE FUNCTION test "print('\nTest!')"
Create a function
test(a,b)in JavaScript, which takes 2 parameters:orientdb>CREATE FUNCTION test "return a + b;" PARAMETERS [a,b]Create a function
allUsersButAdminin SQL, which takes with no parameters:orientdb>CREATE FUNCTION allUsersButAdmin "SELECT FROM ouser WHERE name <> 'admin'" LANGUAGE SQL
For more information, see