CDC Through .NET 2.0
Posted in 2012
Topics: Security, Permissions & Auditing
Not sure whether this is the correct area to post this, but I'm trying to get the Change Data Capture API working against our IDS 11.70 server using .NET and having problems. [CODE] IfxConnection conn = new IfxConnection("Database=syscdcv1;Server=kells5_tcp;Host=kells5;Service=9088;User ID=informix;Password=????????;"); IfxCommand comm = new IfxCommand("EXECUTE FUNCTION cdc_opensess(\\\\"kells5_tcp\\\\",0,60,100,1,1)", conn); IfxParameter ret = new IfxParameter("@retval", IfxType.Integer); ret.Direction = ParameterDirection.ReturnValue; comm.Parameters.Add(ret); comm.ExecuteNonQuery(); int retval = Convert.ToInt32(comm.Parameters["retval"].Value); if (retval == null || retval.ToString().Trim() == "") { tb_Output.Text += "No return value for open session"; } [/CODE] Whether I access the variable ret, or the variable comm.Parameters["retval"] they both come back null from the execute function command. The cdc_opensess function should return either a positive session id or a negative error number. Without the session id, I can't call any further CDC functions. If I change the command to be a select or insert statement, I get the correct return value, so I must be calling the execute function wrong. I can't find any information on the internet other than the limited IBM documentation, so any help would be highly appreciated. Regards, Dave
I've found that I had to use ExecuteScalar for stored functions. Seems weird, but it works. This is using odbc provider but you might find it works with ifx provider. s = "execute function somefunc(" + somearg + ")"; OdbcCommand selCmd = new OdbcCommand(s, conn); Object xo = selCmd.ExecuteScalar(); if (xo != null) result = xo.ToString(); else result = "; -----Original Message----- From: DAVE VARLEY Sent: Wednesday, October 03, 2012 2:02 AM To: ids@iiug.org Subject: CDC Through .NET 2.0 [28417] Not sure whether this is the correct area to post this, but I'm trying to get the Change Data Capture API working against our IDS 11.70 server using .NET and having problems. [CODE] IfxConnection conn = new IfxConnection("Database=syscdcv1;Server=kells5_tcp;Host=kells5;Service=9088;User ID=informix;Password=????????;"); IfxCommand comm = new IfxCommand("EXECUTE FUNCTION cdc_opensess(\\\\"kells5_tcp\\\\",0,60,100,1,1)", conn); IfxParameter ret = new IfxParameter("@retval", IfxType.Integer); ret.Direction = ParameterDirection.ReturnValue; comm.Parameters.Add(ret); comm.ExecuteNonQuery(); int retval = Convert.ToInt32(comm.Parameters["retval"].Value); if (retval == null || retval.ToString().Trim() == "") { tb_Output.Text += "No return value for open session"; } [/CODE] Whether I access the variable ret, or the variable comm.Parameters["retval"] they both come back null from the execute function command. The cdc_opensess function should return either a positive session id or a negative error number. Without the session id, I can't call any further CDC functions. If I change the command to be a select or insert statement, I get the correct return value, so I must be calling the execute function wrong. I can't find any information on the internet other than the limited IBM documentation, so any help would be highly appreciated. Regards, Dave ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Yes! That works. Simple but never would have thought of it. Thank you. Dave
I can't believe how terrible the IBM documentation is for this. I have managed to connect to the syscdcv1 database, establish a session, enabled full row logging on the table of choice, start capture and finally activate session. However, at the point where I'm trying to read the CDC captured data into a IfxBlob, I just get "Method or operation not implemented". [code] IfxBlob blob = new IfxBlob(conn); blob.Open(IfxSmartLOBOpenMode.ReadOnly); blob.Read(buff); [/code] Does anyone have any links to any sample code for either IBM.Data.Informix or IBM.Data.DB2 that I could refer to. If google is anything to go by, very few people have used the .NET Provider to access CDC data.
I've moved this request/discussion into the Development Tools forum instead.