I am getting the error below when trying to run a stored procedure using IBM.EntityFrameworkCore:
IBM.Data.Db2.DB2Exception (0x80004005): ERROR [42815] [IBM][AS] SQL0451N
The "1" definition, in the statement that defines routine "*N ",
contains a data type "FOOSCHEMA.FOONAME" that is not appropriate for a non-sourced routine
written in the given language or a routine that is defined as autonomous.
at IBM.Data.Db2.DB2Connection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode)
at IBM.Data.Db2.DB2Command.ExecuteNonQueryObject(Boolean skipInitialValidation)
at IBM.Data.Db2.DB2Command.ExecuteNonQueryObject()
at IBM.Data.Db2.DB2Command.ExecuteNonQuery()
Code
using var db2 = await db2Context.CreateDbContextAsync();
using var command = db2.Database.GetDbConnection().CreateCommand();
command.CommandText = "call FOOSCHEMA.FOONAME(?, ?, ?, ?, ?)";
command.CommandType = System.Data.CommandType.Text;
command.Parameters.Add(new DB2Parameter
{
ParameterName = "FooInputParam",
Value = "ST",
Direction = System.Data.ParameterDirection.Input,
DB2Type = DB2Type.Char,
Size = 2,
});
command.Parameters.Add(new DB2Parameter
{
ParameterName = "FooInputOutputParam",
Direction = System.Data.ParameterDirection.InputOutput,
DB2Type = DB2Type.Char,
Size = 500
});
/* 3 additional redacted input params */
await db2.Database.OpenConnectionAsync();
var commandResult = await command.ExecuteNonQueryAsync(); // ERROR HERE
Does anyone have any thoughts for things to look at? Thanks.
This is similar to a previous question on this forum here: https://community.ibm.com/community/user/datamanagement/discussion/ibmdatadb2core-sql0451n-calling-program-error
------------------------------
Ryan Buening
------------------------------