Unable to call stored procedure with OUT argument
Posted by: Jose Tejada
Date: December 30, 2013 02:54AM

I am converting a Ms SQL Server application to work with MySQL. I am not able to call stored procedures with OUT arguments. I have looked through the documentation but I cannot figure out how to do it from my .NET code. This is what I am doing:

Stored Procedure:

CREATE PROCEDURE AsientoSencillo
(
IN _deudora nchar(10),
IN _acreedora nchar(10),
IN _cantidad decimal(9,3),
IN _comentario nchar(255),
IN _fecha datetime,
OUT _nuevo_asiento int
)

...

C# Code:

using(MySqlConnection conn = DBCon.Connect()) {
conn.Open();
MySqlCommand cmd = new MySqlCommand("CALL AsientoSencillo(@deudora, @acreedora, @cantidad, @comentario, @fecha, @nuevo);", conn);
cmd.Parameters.AddWithValue("@deudora", deudora);
cmd.Parameters.AddWithValue("@acreedora", acreedora);
cmd.Parameters.AddWithValue("@cantidad", cantidad);
cmd.Parameters.AddWithValue("@comentario", comentario);
cmd.Parameters.AddWithValue("@fecha", fecha);
MySqlParameter p = cmd.CreateParameter();
p.ParameterName = "@nuevo";
p.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
}

And the error is:

OUT or INOUT argument 6 for routine conta2.AsientoSencillo is not a variable or NEW pseudo-variable in BEFORE trigger

This type of code would have worked well with Ms SQL Server. I cannot see what is wrong with it. Please, could you help me?

Options: ReplyQuote


Subject
Written By
Posted
Unable to call stored procedure with OUT argument
December 30, 2013 02:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.