We are in the process of moving from .Net Framework to .Net Core. We currently use the Informix Client SDK ADO.Net drivers to access Informix databases using ADO.Net.
When we tried to migrate to the IBM Data Server Driver (IBM.Data.DB2.dll) we found that calling stored procedures worked except for some types (TEXT, BYTE and BOOLEAN). We contacted IBM and were told to use a workaround to call the stored procedures using TEXT and BYTE types, however this workaround does not follow the best practices set down by Microsoft for calling stored procedures from ADO.Net code. Also due to the generic way our products deal with different database providers, the workaround is not going to work for us.
Workaround suggested was to call the stored procedure using:
command.CommandType = CommandType.Text;
command.CommandText = "CALL test_db2text1(?::TEXT)";
rather than the standard best practise of
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "test_db2text1";
We've been given no response to the question about the BOOLEAN type.
After many weeks of communication about the issue we were told to either wait an unknown period of time for the new "native" Informix .NET Core provider or raise an RFE here. We are pursuing both options at the moment as this is blocking several projects.
If neither of these give a satisfactory result then we will need consider other options, including moving all our Informix customers to another database provider.
-----------
Example to replicate the issue (example for TEXT, but BYTE has the same behaviour) (please note the code below is purely test code to show the issue, it is not production code.)
For example with a test stored procedure like:
CREATE PROCEDURE "informix".test_db2text1 (in_test REFERENCES TEXT)
RETURNING REFERENCES TEXT;
DEFINE p_text REFERENCES TEXT;
LET p_Text = in_test;
return p_Text;
END PROCEDURE;
And code like:
string parameterValue = "The quick brown fox jumps over the lazy dog.";
int parameterSize = parameterValue.Length;
using (DB2Connection connection = new DB2Connection("Server=mydbserver:9089;Database=mydb1;User Id=myuser;Password=mypassword;Pooling=true"))
{
connection.Open();
using (DB2Command command = connection.CreateCommand())
{
DB2Parameter parameter = new DB2Parameter("in_test", DB2Type.Clob)
{
Value = parameterValue,
Size = parameterSize
};
command.Parameters.Add(parameter);
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "test_db2text1";
DB2DataReader dataReader = command.ExecuteReader();
// This will only read 1 row.
while (dataReader.Read())
{
if (!dataReader.IsDBNull(0))
{
displayBuilder.AppendLine(dataReader.GetValue(0).ToString());
}
else
{
displayBuilder.AppendLine("Value was NULL");
}
}
dataReader.Close();
}
}
We get the error:
IBM.Data.DB2.DB2Exception (0x80004005): ERROR [IX000] [IBM][IDS/UNIX64] Routine (test_db2text1) can not be resolved.
at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method, DB2CursorType reqCursorType, Boolean abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows, Boolean skipInitialValidation)
at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method)
at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)
at IBM.Data.DB2.DB2Command.ExecuteReader()
----------
Example of issue for BOOLEAN
C# line like:
DB2Parameter parameter = new DB2Parameter("test", DB2Type.Boolean);
Will throw the error:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Invalid DB2 Type enumeration value=1015.
at IBM.Data.DB2.TypeMap.FromDB2Type(DB2Type db2Type)
at IBM.Data.DB2.DB2Parameter.set_DB2Type(DB2Type value)
at IBM.Data.DB2.DB2Parameter..ctor(String szName, DB2Type db2Type)
----------
The informix article
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.swg.im.dbclient.adonet.ref.doc/doc/DB2TypeEnumeration.html
does list the Boolean issue as a limitation of the driver. It does not list any issues for Text and Byte types.
Concerningly it also lists several other Informix types (like NVARCHAR, etc) that throw exceptions at runtime.