[Mono-bugs] [Bug 82150][Wis] New - Npgsql Parameter bug. likely cause of bug# 82148

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jul 20 07:44:40 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miblogic at yahoo.com.

http://bugzilla.ximian.com/show_bug.cgi?id=82150

--- shadow/82150	2007-07-20 07:44:40.000000000 -0400
+++ shadow/82150.tmp.30525	2007-07-20 07:44:40.000000000 -0400
@@ -0,0 +1,273 @@
+Bug#: 82150
+Product: Mono: Runtime
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: Ubuntu Feisty Fawn 64bit
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: io-layer
+AssignedTo: dick at ximian.com                            
+ReportedBy: miblogic at yahoo.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Npgsql Parameter bug.  likely cause of bug# 82148
+
+NpgsqlAdapter's UpdateCommand and InsertCommand's parameters must have
+match NpgsqlParameter ordering
+
+prior to placing: 
+
+this code ==> 
+insertDetail.Parameters.Add("p_ecmtp_rec_id", NpgsqlDbType.Varchar);
+insertDetail.Parameters["p_ecmtp_rec_id"].Value = ecmtRecId; 
+
+to the last statement ==>  		insertDetail.Parameters.Add("p_remark",
+NpgsqlDbType.Varchar);
+insertDetail.Parameters["p_remark"].SourceColumn = "remark";
+
+
+the NpgsqlDataAdapter always feed '0' to insertCommand's paramater
+p_ecmtp_rec_id.  see the Postgresql log file below.
+
+
+why should the order of adding NpgsqlParameter should matter in Mono's
+Npgsql?  in .NET's Npgsql, the order of adding parameters to UpdateCommand
+and InsertCommand, doesn't matter, any ways NpgsqlParamater adding
+arrangement is, it just works.
+
+
+
+
+public override void Mono_ECMTP_Save(string ecmtRecId, DataTable[] dts)
+{
+
+	NpgsqlConnection c = Connect();
+
+	NpgsqlTransaction tx = c.BeginTransaction();
+
+	NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+
+	try
+	{
+		NpgsqlCommand insertHeader = new NpgsqlCommand(
+			@"insert into ecmtp(ecmtp_rec_id, company_code, shoe_section_code,
+material_code, testing_level)
+			values(:p_ecmtp_rec_id, :p_company_code, :p_shoe_section_code,
+:p_material_code, :p_testing_level)", c);
+
+
+		insertHeader.Parameters.Add("p_ecmtp_rec_id", NpgsqlDbType.Varchar);
+		insertHeader.Parameters["p_ecmtp_rec_id"].Value = ecmtRecId;
+
+		insertHeader.Parameters.Add("p_company_code", NpgsqlDbType.Varchar);
+		insertHeader.Parameters["p_company_code"].SourceColumn = "company_code";
+
+		insertHeader.Parameters.Add("p_material_code", NpgsqlDbType.Varchar);
+		insertHeader.Parameters["p_material_code"].SourceColumn = "material_code";
+
+		insertHeader.Parameters.Add("p_shoe_section_code", NpgsqlDbType.Varchar);
+		insertHeader.Parameters["p_shoe_section_code"].SourceColumn =
+"shoe_section_code";
+
+
+		insertHeader.Parameters.Add("p_testing_level", NpgsqlDbType.Integer);
+		insertHeader.Parameters["p_testing_level"].SourceColumn = "testing_level";
+
+
+
+
+		NpgsqlCommand updateHeader = new NpgsqlCommand(
+			@"update ecmtp set
+				company_code = :p_company_code,
+				shoe_section_code = :p_shoe_section_code,
+				material_code = :p_material_code,
+				testing_level = :p_testing_level
+			where ecmtp_rec_id = :o_ecmtp_rec_id
+				and :p_ecmtp_rec_id = :o_ecmtp_rec_id
+				", c);
+
+
+
+		updateHeader.Parameters.Add("o_ecmtp_rec_id", NpgsqlDbType.Varchar);
+		updateHeader.Parameters["o_ecmtp_rec_id"].SourceColumn = "ecmtp_rec_id";
+		updateHeader.Parameters["o_ecmtp_rec_id"].SourceVersion =
+DataRowVersion.Original;
+
+		updateHeader.Parameters.Add("p_ecmtp_rec_id", NpgsqlDbType.Varchar);
+		updateHeader.Parameters["p_ecmtp_rec_id"].SourceColumn = "ecmtp_rec_id";
+		updateHeader.Parameters["p_ecmtp_rec_id"].SourceVersion =
+DataRowVersion.Current;
+
+		updateHeader.Parameters.Add("p_company_code", NpgsqlDbType.Varchar);
+		updateHeader.Parameters["p_company_code"].SourceColumn = "company_code";
+
+		updateHeader.Parameters.Add("p_material_code", NpgsqlDbType.Varchar);
+		updateHeader.Parameters["p_material_code"].SourceColumn = "material_code";
+
+		updateHeader.Parameters.Add("p_shoe_section_code", NpgsqlDbType.Varchar);
+		updateHeader.Parameters["p_shoe_section_code"].SourceColumn =
+"shoe_section_code";
+
+		updateHeader.Parameters.Add("p_testing_level", NpgsqlDbType.Integer);
+		updateHeader.Parameters["p_testing_level"].SourceColumn = "testing_level";
+
+
+		da.DeleteCommand = null;
+		da.InsertCommand = insertHeader;
+		da.UpdateCommand = updateHeader;
+
+
+		if (dts[0] != null)			
+			da.Update(dts[0]);
+
+
+
+
+		NpgsqlCommand insertDetail = new NpgsqlCommand(
+			@"insert into ecmtp_parameter(ecmtp_rec_id, ecmtp_parameter_rec_id,
+color_code, parameter_code, unit, value_span_code, value, method, remark)
+			values( :p_ecmtp_rec_id , :p_ecmtp_parameter_rec_id, :p_color_code,
+:p_parameter_code, :p_unit, :p_value_span_code, :p_value, :p_method,
+:p_remark)", c);
+
+
+
+		
+
+		insertDetail.Parameters.Add("p_ecmtp_parameter_rec_id",
+NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_ecmtp_parameter_rec_id"].SourceColumn =
+"ecmtp_parameter_rec_id";
+
+
+		insertDetail.Parameters.Add("p_color_code", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_color_code"].SourceColumn = "color_code";
+
+
+		Console.WriteLine("ecmt rec id: " + ecmtRecId);
+
+		insertDetail.Parameters.Add("p_parameter_code", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_parameter_code"].SourceColumn = "parameter_code";
+
+
+
+		insertDetail.Parameters.Add("p_unit", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_unit"].SourceColumn = "unit";
+
+
+		insertDetail.Parameters.Add("p_value_span_code", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_value_span_code"].SourceColumn =
+"value_span_code";
+
+
+		insertDetail.Parameters.Add("p_value", NpgsqlDbType.Numeric);
+		insertDetail.Parameters["p_value"].SourceColumn = "value";
+
+		insertDetail.Parameters.Add("p_method", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_method"].SourceColumn = "method";
+
+		insertDetail.Parameters.Add("p_remark", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_remark"].SourceColumn = "remark";
+
+
+
+		insertDetail.Parameters.Add("p_ecmtp_rec_id", NpgsqlDbType.Varchar);
+		insertDetail.Parameters["p_ecmtp_rec_id"].Value = ecmtRecId;
+
+
+
+
+
+		
+
+		NpgsqlCommand updateDetail = new NpgsqlCommand(
+			@"update ecmtp_parameter set
+				color_code = :p_color_code,
+				parameter_code = :p_parameter_code,
+				unit = :p_unit,
+				value_span_code = :p_value_span_code,
+				value = :p_value,
+				method = :p_method,
+				remark = :p_remark					
+			where ecmtp_parameter_rec_id = :o_ecmtp_parameter_rec_id
+				and :p_ecmtp_parameter_rec_id = :o_ecmtp_parameter_rec_id", c);
+
+
+
+
+
+		updateDetail.Parameters.Add("p_ecmtp_parameter_rec_id",
+NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_ecmtp_parameter_rec_id"].SourceColumn =
+"ecmtp_parameter_rec_id";
+		updateDetail.Parameters["p_ecmtp_parameter_rec_id"].SourceVersion =
+DataRowVersion.Current;
+
+
+		updateDetail.Parameters.Add("o_ecmtp_parameter_rec_id",
+NpgsqlDbType.Varchar);
+		updateDetail.Parameters["o_ecmtp_parameter_rec_id"].SourceColumn =
+"ecmtp_parameter_rec_id";
+		updateDetail.Parameters["o_ecmtp_parameter_rec_id"].SourceVersion =
+DataRowVersion.Original;
+
+
+		updateDetail.Parameters.Add("p_color_code", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_color_code"].SourceColumn = "color_code";
+
+
+		updateDetail.Parameters.Add("p_parameter_code", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_parameter_code"].SourceColumn = "parameter_code";
+
+		updateDetail.Parameters.Add("p_unit", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_unit"].SourceColumn = "unit";
+
+
+		updateDetail.Parameters.Add("p_value_span_code", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_value_span_code"].SourceColumn =
+"value_span_code";
+
+
+		updateDetail.Parameters.Add("p_value", NpgsqlDbType.Numeric);
+		updateDetail.Parameters["p_value"].SourceColumn = "value";
+
+		updateDetail.Parameters.Add("p_method", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_method"].SourceColumn = "method";
+
+
+		updateDetail.Parameters.Add("p_remark", NpgsqlDbType.Varchar);
+		updateDetail.Parameters["p_remark"].SourceColumn = "remark";
+
+
+		NpgsqlCommand deleteDetail = new NpgsqlCommand(
+			@"delete from ecmtp_parameter
+		   where ecmtp_parameter_rec_id = :p_ecmtp_parameter_rec_id", c);
+
+		deleteDetail.Parameters.Add("p_ecmtp_parameter_rec_id",
+NpgsqlDbType.Varchar);
+		deleteDetail.Parameters["p_ecmtp_parameter_rec_id"].SourceColumn =
+"ecmtp_parameter_rec_id";
+
+		da.DeleteCommand = deleteDetail;
+		da.UpdateCommand = updateDetail;
+		da.InsertCommand = insertDetail;
+
+
+		if (dts[1] != null)
+			da.Update(dts[1]);
+
+
+		tx.Commit();
+
+	}
+	catch (NpgsqlException ex)
+	{
+		tx.Rollback();
+		throw new Exception(ex.Message + "\n" + ex.StackTrace);
+	}
+
+}


More information about the mono-bugs mailing list