0PricingLogin
Neo4j Graph Database Fundamentals · Lesson

Stored Procedures and UDFs

Learn to write and deploy custom stored procedures and user-defined functions to encapsulate complex logic and extend Cypher.

Extending Neo4j's Capabilities

Welcome to extending Neo4j! Sometimes, Cypher isn't enough for complex logic or specific integrations. That's where custom code comes in.

Neo4j allows you to extend its functionality using Stored Procedures and User-Defined Functions (UDFs), typically written in Java.

  • Stored Procedures perform actions, like creating nodes or running complex algorithms.
  • User-Defined Functions (UDFs) return values, just like built-in Cypher functions.

They encapsulate complex logic, improve query readability, and boost performance for repetitive tasks.

Procedures vs. User-Defined Functions

It's crucial to understand the difference between procedures and UDFs:

  • Stored Procedures:
    - Called with CALL package.procedure()
    - Can perform side effects (create, update, delete data)
    - Return tabular results (rows and columns)
    - Can access the graph database directly
  • User-Defined Functions (UDFs):
    - Called within Cypher expressions (e.g., RETURN my.udf(n.property))
    - Must be pure functions (no side effects)
    - Return a single scalar value (e.g., string, number, boolean, list)
    - Cannot modify the graph or access it directly

All lessons in this course

  1. Stored Procedures and UDFs
  2. Integrating with BI and Visualization Tools
  3. Advanced Data Ingestion Pipelines
  4. Full-Text and Vector Search in Neo4j
← Back to Neo4j Graph Database Fundamentals