mariadb-create-procedure

Documents MariaDB-specific CREATE PROCEDURE syntax, parameter modes, privileges, and common LLM errors.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-create-procedure-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-create-procedure
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/statements/mariadb-create-procedure
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-create-procedure-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? LLMs frequently generate CREATE PROCEDURE statements that fail on MariaDB — combining OR REPLACE with IF NOT EXISTS, relying on DETERMINISTIC for procedures, or misusing parameter modes — because they apply generic or MySQL/Oracle assumptions instead of MariaDB's actual syntax and privilege behavior. ## Core Features & Use Cases - Syntax Delta Reference: Covers OR REPLACE vs IF NOT EXISTS mutual exclusion, DEFINER and SQL SECURITY DEFINER/INVOKER, IN/OUT/INOUT parameter modes, and parameter DEFAULT values (11.8+). - LLM Trap Table: Maps common incorrect outputs (e.g., two-word IN OUT outside Oracle mode, expecting advisory characteristics to be enforced) to the correct MariaDB forms. - Privilege & Invocation Guidance: Explains CREATE ROUTINE and SET USER requirements, automatic ALTER ROUTINE/EXECUTE grants, CALL-based invocation, and the client-side DELIMITER convention. - Use Case: When asked to write a stored procedure with an OUT parameter and a default-valued IN parameter for MariaDB 11.8, produce valid syntax on the first attempt without illegal clause combinations. ## Quick Start Ask the AI to write a MariaDB CREATE PROCEDURE statement with OUT and IN parameters, and it will apply the correct MariaDB-specific syntax and privilege rules.

Frequently Asked Questions about mariadb-create-procedure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a CREATE PROCEDURE statement in MariaDB?▼

Use CREATE PROCEDURE sp_name with optional OR REPLACE or IF NOT EXISTS (never both), a parameter list with IN/OUT/INOUT modes, characteristics like SQL SECURITY, and a routine body. Invoke the procedure with CALL, never SELECT.

Can I use OR REPLACE and IF NOT EXISTS together in MariaDB?▼

No, OR REPLACE and IF NOT EXISTS are mutually exclusive in MariaDB and combining them raises ER_WRONG_USAGE. Use OR REPLACE to drop and recreate unconditionally, or IF NOT EXISTS to no-op with a warning if the procedure exists.

Does DETERMINISTIC affect stored procedures in MariaDB?▼

No, DETERMINISTIC and NOT DETERMINISTIC are parsed but ignored for procedures; they apply only to stored functions. The data-access characteristics like CONTAINS SQL are also purely advisory and never validated against the body.

What privileges are needed to create a procedure in MariaDB?▼

Creating a procedure requires the CREATE ROUTINE privilege, and specifying a DEFINER other than the calling account requires SET USER. The creator is automatically granted ALTER ROUTINE and EXECUTE while automatic_sp_privileges is enabled.

Why does my CREATE PROCEDURE script fail in the mariadb CLI?▼

The procedure body's internal semicolons terminate the statement early in the mariadb client. Change the client-side delimiter first, for example DELIMITER //, then restore it afterward; this is a client convenience, not server syntax.

Is IN OUT valid as a parameter mode in MariaDB?▼

IN OUT as two words, along with the NOCOPY hint, is valid only under sql_mode=ORACLE. In default MariaDB mode, use INOUT as one word; IN is the default when no mode is specified.