Common SQL Errors

MySQL Error 1414 ER_SP_NOT_VAR_ARG - OUT or INOUT argument not a variable

Galaxy Team
August 7, 2025

<p>The error appears when a stored procedure or function receives an OUT or INOUT argument that is not a writable variable.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1414 ER_SP_NOT_VAR_ARG?

<p>MySQL Error 1414 ER_SP_NOT_VAR_ARG occurs when an OUT or INOUT parameter is supplied with a literal, expression, or NEW pseudo-variable instead of a writable variable. Pass a user or local variable (e.g., @out_val) or move the call to an AFTER trigger to fix the issue.</p>

Error Highlights

Typical Error Message

OUT or INOUT argument %d for routine %s is not a variable

Error Type

Stored Routine Error

Language

MySQL

Symbol

ER_SP_NOT_VAR_ARG

Error Code

1414

SQL State

42000

Explanation

Table of Contents

What is MySQL Error 1414 ER_SP_NOT_VAR_ARG?

MySQL returns error 1414 when a stored procedure or function expects an OUT or INOUT parameter but the caller supplies something that cannot be written to, such as a literal, expression, constant, or the NEW pseudo-variable inside a BEFORE trigger.

The engine needs a true variable so it can write the outgoing value. If the argument is not writable the server aborts the statement and issues SQLSTATE 42000.

What Causes This Error?

The error fires most often when developers pass numeric or string literals to an OUT parameter, call the routine inside a BEFORE trigger, or forward the argument from a view, subquery, or expression that resolves to a temporary column.

Another cause is using session variables incorrectly, for example omitting the @ prefix or trying to reuse the same literal in multiple places.

How to Fix MySQL Error 1414 ER_SP_NOT_VAR_ARG

Always supply a variable that the server can modify. Create a user variable (@var_name), declare a local variable with DECLARE inside another routine, or use a prepared host variable in your client code.

In triggers choose an AFTER trigger instead of BEFORE when you need to capture output from a routine call, because BEFORE triggers cannot assign to NEW.

Common Scenarios and Solutions

If you called a procedure like CALL get_totals(1,2); rewrite it as SET @out:=0; CALL get_totals(1,@out); SELECT @out;

In a BEFORE UPDATE trigger move the logic to an AFTER UPDATE trigger or store the output in a declared variable inside the trigger, then copy it to NEW columns if needed in an AFTER context.

Best Practices to Avoid This Error

Define clear parameter modes in routine headers and document expected caller syntax. Use named variables when testing procedures and include unit tests that check OUT assignments.

Enforce code reviews in Galaxy collections so peers can catch literal OUT parameters before they reach production.

Related Errors and Solutions

Error 1193 Unknown system variable arises when you miss the @ prefix on user variables. Error 1366 Incorrect integer value appears when type casting fails inside routine parameters. The fixes are similar: supply correct variable references and data types.

Common Causes

Literal Passed Instead of Variable

Supplying 0 or 'text' instead of @out_var is the top trigger because literals are read-only.

Expression or Function Result Used

Passing NOW() or CONCAT(...) to an OUT parameter creates a temporary, unwritable result.

Using NEW Inside BEFORE Trigger

NEW.column is read-only before the row exists; writing to it causes error 1414.

Related Errors

Error 1193 Unknown system variable

Raised when a user variable is referenced without the @ prefix.

Error 1228 Variable not found in given context

Occurs when a DECLARE variable is used outside its scope.

Error 1327 Undeclared variable

Appears in triggers when OLD or NEW are referenced incorrectly.

FAQs

Can I pass a column value as an OUT parameter?

No. Columns are read-only in CALL statements. Copy the value to a user variable first.

Why does the error only appear in BEFORE triggers?

BEFORE triggers cannot assign to NEW because the row is not yet created. Use AFTER triggers instead.

Is there a workaround without rewriting the trigger?

Store the procedure output in a local variable inside the trigger and use it later rather than assigning directly to NEW.

Does Galaxy help avoid this error?

Yes. Galaxy highlights literal OUT parameters in real time and suggests declaring a variable, reducing runtime failures.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo