Thanks for the response, Andreas.
You are correct regarding the Java SDK, which supports the IfxSmartBlob object with a session_id. However, the .NET SDK doesn't provide this object.
As a result, I'm really stuck at this point and unable to move forward.
Original Message:
Sent: Tue July 29, 2025 10:19 AM
From: Andreas Legner
Subject: Informix CDC API - Is there a way to pull the change record using .NET?
Not an expert in .NET at all, but to me this looks like it's missing the link between the "session_id" and the LO read: session_id actually is a smart blob LO fd that you'd read from using ifx_lo_read() - or however this is called in .NET.
I'd recommend looking at the cdcapi.ec esql/c demo in (server's) $INFORMIXDIR/demo/cdc, but I have a feeling that's what you modeled your .NET code after anyway ;-)
HTH,
Andreas
------------------------------
Andreas Legner
Informix Dev
HCL Software
Original Message:
Sent: Tue July 29, 2025 01:39 AM
From: George Wen
Subject: Informix CDC API - Is there a way to pull the change record using .NET?
Hi,
I'm trying to work with the Informix CDC API using the Informix .NET provider, but I haven't been able to find any sample code, and the documentation has been difficult to follow.
I've put together the following code sample, but it doesn't seem to be retrieving any change records.
The most relevant documentation I've found is here:
https://www.ibm.com/docs/en/informix-servers/12.10.0?topic=api-smart-large-object-read-functions
My test code is as below:
using IBM.Data.Informix;using System;using System.Data;using System.Data.Odbc;using System.IO;namespace IfxOdbcOledb{ class Class1 { static string _DbConnString = "User Id=informix;Password=xxx;" + "Host=localhost;Server=ol_informix1410;" + "Service=9090;Database=syscdcv1"; [STAThread] static void Main(string[] args) { IfxConnection IfxCon = new IfxConnection(_DbConnString); //execute function informix.cdc_opensess() // on the same connection //IfxBlob(IfxConnection connection)// construct it using the same connection //IfxBlob.Open(ReadOnly) // open it //IfxBlob.Read(long plofd, byte[] buff) IfxCommand Command = new IfxCommand(); try { IfxCon.Open(); Command.Connection = IfxCon; Command.CommandText = "EXECUTE FUNCTION syscdcv1:informix.cdc_opensess('ol_informix1410',0,0,10,1,1);"; Command.CommandType = CommandType.Text; object result = Command.ExecuteScalar(); long session_id = Convert.ToInt64(result); Command.CommandText = "EXECUTE FUNCTION syscdcv1:informix.cdc_set_fullrowlogging('testdb:informix.claims_history',1);"; Command.CommandType = CommandType.Text; Command.ExecuteNonQuery(); Command.CommandText = "execute function syscdcv1: informix.cdc_startcapture(?, 0, 'testdb:informix.claims_history', 'customer,clm_no,dte_serv', 1)"; Command.Parameters.Clear(); Command.Parameters.Add("?", OdbcType.VarChar).Value = session_id; Command.ExecuteNonQuery(); Command.CommandText = "EXECUTE FUNCTION syscdcv1:informix.cdc_activatesess(?, 0)"; Command.CommandType = CommandType.Text; Command.Parameters.Clear(); Command.Parameters.Add("?", OdbcType.VarChar).Value = session_id; Command.ExecuteNonQuery(); // make data change Command.CommandText = "update testdb:informix.claims_history set dte_serv = CURRENT where hpolicy = 'HP123458'"; Command.CommandType = CommandType.Text; Command.Parameters.Clear(); Command.ExecuteNonQuery(); IfxBlob ifxblob = new IfxBlob(IfxCon); ifxblob.Open(IfxSmartLOBOpenMode.ReadOnly); const int bufferSize = 8192; // 8 KB buffer is a common size. byte[] buffer = new byte[bufferSize]; long bytesRead = 0; while ((bytesRead = ifxblob.Read(buffer)) > 0) { // Write the chunk of data from our buffer into the file. //fileStream.Write(buffer, 0, bytesRead); Console.WriteLine($"Read {bytesRead} bytes..."); } Console.WriteLine("test..."); Command.CommandText = "execute function syscdcv1: informix.cdc_endcapture(?, 0, 'testdb:informix.claims_history')"; Command.Parameters.Clear(); Command.Parameters.Add("?", OdbcType.VarChar).Value = session_id; Command.ExecuteNonQuery(); Command.CommandText = "EXECUTE FUNCTION syscdcv1:informix.cdc_set_fullrowlogging('testdb:informix.claims_history',0);"; Command.Parameters.Clear(); Command.CommandType = CommandType.Text; Command.ExecuteNonQuery(); Command.CommandText = "EXECUTE FUNCTION syscdcv1:informix.cdc_closesess(?)"; Command.CommandType = CommandType.Text; Command.Parameters.Clear(); Command.Parameters.Add("?", OdbcType.VarChar).Value = session_id; Command.ExecuteNonQuery(); Console.ReadLine(); IfxCon.Close(); } catch (Exception excp) { Console.WriteLine(excp.StackTrace); } } }}
Any guidance or working examples would be greatly appreciated.
------------------------------
George Wen
------------------------------