Functions

A Function is an executable unit of code that can take parameters and return a result. Using Functions you can perform Functional programming where logic and data are all together in a central place. Functions are similar to the Stored Procedures of RDBMS.

NOTE: This guide refers to the last available release of OrientDB. For past revisions look at Compatibility.

OrientDB Functions features:

  • are persistent
  • can be written in SQL or Javascript (Ruby, Scala, Java and other languages are coming)
  • can be executed via SQL, Java, REST and Studio
  • can call each other
  • supports recursion
  • have automatic mapping of parameters by position and name
  • plugins can inject new objects to being used by functions

The OrientDB SQL dialect supports many functions written in the native language. To get better performance, you can write your own native functions in the Java language and register them to the engine.

For more information, see Custom Functions in Java.

Compatibility

1.5.0 and before

OrientDB binds the following variables:

  • db, that is the current document database instance
  • gdb, that is the current graph database instance