Răsfoiți Sursa

2005-07-17 Daniel Morgan <[email protected]>

    * System.Data.OracleClient/OracleCommandBuilder.cs:
    implemented a working OracleCommandBuilder based on
    current SqlCommandBuilder	

	* System.Data.OracleClient/OracleCommand.cs: added 
	placeholder for DeriveParamters

	* System.Data.OracleClient/OracleDataReader.cs:
		- sometimes trying to get records affected 
		  throws an exception
		- set BaseColumnName to the ColumnName 
		  in the Schema table
		  if the command behavior is KeyInfo
		- only try to Read if there are rows to read

	* Test/OracleAdapterTest.cs: removed file
	because adapter tests added to TestOracleClient.cs
		  
	* Test/TestOracleClient.cs: added tests
		- test ExecuteReader and records affected
		  executing a Non-Query
		- test Inserts/Updates/Deletes with a
		  DataSet, Data Adapter, and Command Builder

svn path=/trunk/mcs/; revision=47362
Daniel Morgan 20 ani în urmă
părinte
comite
dc0406b44d

+ 26 - 0
mcs/class/System.Data.OracleClient/ChangeLog

@@ -1,3 +1,29 @@
+2005-07-17  Daniel Morgan <[email protected]>
+
+    * System.Data.OracleClient/OracleCommandBuilder.cs:
+    implemented a working OracleCommandBuilder based on
+    current SqlCommandBuilder	
+
+	* System.Data.OracleClient/OracleCommand.cs: added 
+	placeholder for DeriveParamters
+
+	* System.Data.OracleClient/OracleDataReader.cs:
+		- sometimes trying to get records affected 
+		  throws an exception
+		- set BaseColumnName to the ColumnName 
+		  in the Schema table
+		  if the command behavior is KeyInfo
+		- only try to Read if there are rows to read
+
+	* Test/OracleAdapterTest.cs: removed file
+	because adapter tests added to TestOracleClient.cs
+		  
+	* Test/TestOracleClient.cs: added tests
+		- test ExecuteReader and records affected
+		  executing a Non-Query
+		- test Inserts/Updates/Deletes with a
+		  DataSet, Data Adapter, and Command Builder
+
 2005-07-10  Daniel Morgan <[email protected]>
 
 	* System.Data.OracleClient/OracleCommand.cs: support

+ 10 - 0
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleCommand.cs

@@ -276,6 +276,16 @@ namespace System.Data.OracleClient {
 			return new OracleParameter ();
 		}
 
+		internal void DeriveParameters () 
+		{
+			if (commandType != CommandType.StoredProcedure)
+				throw new InvalidOperationException (String.Format ("OracleCommandBuilder DeriveParameters only supports CommandType.StoredProcedure, not CommandType.{0}", commandType));
+
+			//OracleParameterCollection localParameters = new OracleParameterCollection (this);
+
+			throw new NotImplementedException ();
+		}
+
 		private int ExecuteNonQueryInternal (OciStatementHandle statement, bool useAutoCommit)
 		{
 			if (preparedStatement == null)

+ 162 - 173
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleCommandBuilder.cs

@@ -1,16 +1,15 @@
 //
-// System.Data.Oracle.OracleCommandBuilder
+// System.Data.OracleClient.OracleCommandBuilder.cs
+//
+// based on the SqlCommandBuilder in mcs/class/System.Data/System.Data.SqlClient
 //
 // Authors:
 //	Atsushi Enomoto <[email protected]>
 //      Tim Coleman ([email protected])
 //      Daniel Morgan <[email protected]>
 //
-// (C)2004 Novell Inc.
 // Copyright (C) Tim Coleman, 2002
 // Copyright (C) Daniel Morgan, 2005
-//
-//
 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
@@ -40,10 +39,12 @@ using System.Data;
 using System.Data.Common;
 using System.Text;
 
-namespace System.Data.OracleClient
-{
-	public sealed class OracleCommandBuilder : Component
-	{
+namespace System.Data.OracleClient {
+#if NET_2_0
+	public sealed class OracleCommandBuilder : DbCommandBuilder
+#else
+	public sealed class OracleCommandBuilder : Component {
+#endif // NET_2_0
 		#region Fields
 
 		bool disposed = false;
@@ -60,15 +61,14 @@ namespace System.Data.OracleClient
 		OracleCommand updateCommand;
 
 		// Used to construct WHERE clauses
-		static readonly string clause1 = "({0} IS NULL AND :{1} IS NULL)";
-		static readonly string clause2 = "({0} = :{1})";
+		static readonly string clause1 = "({0} IS NULL AND {1} IS NULL)";
+		static readonly string clause2 = "({0} = {1})";
 
 		#endregion // Fields
 
 		#region Constructors
 
-		public OracleCommandBuilder () 
-		{
+		public OracleCommandBuilder () {
 			dbSchemaTable = null;
 			adapter = null;
 			quoteSuffix = String.Empty;
@@ -76,8 +76,7 @@ namespace System.Data.OracleClient
 		}
 
 		public OracleCommandBuilder (OracleDataAdapter adapter)
-			: this ()
-		{
+			: this () {
 			DataAdapter = adapter;
 		}
 
@@ -87,10 +86,14 @@ namespace System.Data.OracleClient
 
 		[DataSysDescription ("The DataAdapter for which to automatically generate OracleCommands")]
 		[DefaultValue (null)]
-		public OracleDataAdapter DataAdapter {
+		public new OracleDataAdapter DataAdapter {
 			get { return adapter; }
 			set { 
+				if (adapter != null)
+					adapter.RowUpdating -= new OracleRowUpdatingEventHandler (RowUpdatingHandler);
+
 				adapter = value; 
+
 				if (adapter != null)
 					adapter.RowUpdating += new OracleRowUpdatingEventHandler (RowUpdatingHandler);
 			}
@@ -103,7 +106,11 @@ namespace System.Data.OracleClient
 		[Browsable (false)]
 		[DataSysDescription ("The character used in a text command as the opening quote for quoting identifiers that contain special characters.")]
 		[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-		public string QuotePrefix {
+		public 
+#if NET_2_0
+		override
+#endif // NET_2_0
+			string QuotePrefix {
 			get { return quotePrefix; }
 			set { 
 				if (dbSchemaTable != null)
@@ -115,7 +122,11 @@ namespace System.Data.OracleClient
 		[Browsable (false)]
 		[DataSysDescription ("The character used in a text command as the closing quote for quoting identifiers that contain special characters.")]
 		[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-		public string QuoteSuffix {
+		public 
+#if NET_2_0
+		override
+#endif // NET_2_0
+			string QuoteSuffix {
 			get { return quoteSuffix; }
 			set {
 				if (dbSchemaTable != null)
@@ -136,7 +147,7 @@ namespace System.Data.OracleClient
 
 		#region Methods
 
-		private void BuildCache (bool closeConnection)
+		private void BuildCache (bool closeConnection) 
 		{
 			OracleCommand sourceCommand = SourceCommand;
 			if (sourceCommand == null)
@@ -160,42 +171,37 @@ namespace System.Data.OracleClient
 			}
 		}
 		
-		private void BuildInformation (DataTable schemaTable)
+		private void BuildInformation (DataTable schemaTable) 
 		{
 			tableName = String.Empty;
-
-			//foreach (DataRow schemaRow in schemaTable.Rows) {
-				//if (tableName == String.Empty) 
-				//	tableName = schemaRow.IsNull ("BaseTableName") ? null : (string) schemaRow ["BaseTableName"];
-				//else if (schemaRow.IsNull ("BaseTableName")) {
-				//	if (tableName != null)
-				//		throw new InvalidOperationException ("Dynamic SQL generation is not supported against multiple base tables.");
-				//} else if (tableName != (string) schemaRow["BaseTableName"])
-				//	throw new InvalidOperationException ("Dynamic SQL generation is not supported against multiple base tables.");
-			//}
+			foreach (DataRow schemaRow in schemaTable.Rows) {
+				if (tableName == String.Empty) 
+					tableName = schemaRow.IsNull ("BaseTableName") ? null : (string) schemaRow ["BaseTableName"];
+				else if (schemaRow.IsNull ("BaseTableName")) {
+					if (tableName != null)
+						throw new InvalidOperationException ("Dynamic SQL generation is not supported against multiple base tables.");
+				} else if (tableName != (string) schemaRow["BaseTableName"])
+					throw new InvalidOperationException ("Dynamic SQL generation is not supported against multiple base tables.");
+			}
 			dbSchemaTable = schemaTable;
 		}
 
 		private OracleCommand CreateDeleteCommand (DataRow row, DataTableMapping tableMapping) 
 		{
-			if (tableName == String.Empty)
-				tableName = row.Table.TableName;
-
 			// If no table was found, then we can't do an delete
 			if (QuotedTableName == String.Empty)
 				return null;
 
+
 			CreateNewCommand (ref deleteCommand);
 
 			string command = String.Format ("DELETE FROM {0} ", QuotedTableName);
-			StringBuilder columns = new StringBuilder ();
 			StringBuilder whereClause = new StringBuilder ();
 			string dsColumnName = String.Empty;
 			bool keyFound = false;
 			int parmIndex = 1;
 
-			foreach (DataRow schemaRow in dbSchemaTable.Rows) 
-			{
+			foreach (DataRow schemaRow in dbSchemaTable.Rows) {
 				if (!IncludedInWhereClause (schemaRow)) 
 					continue;
 
@@ -208,11 +214,15 @@ namespace System.Data.OracleClient
 				if (!isKey) {
 					parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-					dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+					dsColumnName = parameter.SourceColumn;
+					if (tableMapping != null 
+						&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+						dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+				
 					if (row != null)
-						parameter.Value = row [dsColumnName, DataRowVersion.Current];
+						parameter.Value = row [dsColumnName, DataRowVersion.Original];
 					whereClause.Append ("(");
-					whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
+					whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), ":" + parameter.ParameterName));
 					whereClause.Append (" OR ");
 				}
 				else
@@ -220,12 +230,15 @@ namespace System.Data.OracleClient
 					
 				parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-				//dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
-				dsColumnName = schemaRow["ColumnName"].ToString ();
+				dsColumnName = parameter.SourceColumn;
+				if (tableMapping != null 
+					&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+					dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+
 				if (row != null)
 					parameter.Value = row [dsColumnName, DataRowVersion.Original];
 
-				whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
+				whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), ":" + parameter.ParameterName));
 
 				if (!isKey)
 					whereClause.Append (")");
@@ -241,17 +254,9 @@ namespace System.Data.OracleClient
 
 		private OracleCommand CreateInsertCommand (DataRow row, DataTableMapping tableMapping) 
 		{
-			if (tableName == String.Empty)
-				tableName = row.Table.TableName;
-			
 			if (QuotedTableName == String.Empty)
 				return null;
-			
-			//for (int c = 0; c < row.Table.Columns.Count; c++) {
-			//	DataColumn dc = row.Table.Columns[c];
-			//	Console.WriteLine("     ColumnName: " + dc.ColumnName);
-			//}
-			
+
 			CreateNewCommand (ref insertCommand);
 
 			string command = String.Format ("INSERT INTO {0}", QuotedTableName);
@@ -261,10 +266,9 @@ namespace System.Data.OracleClient
 			string dsColumnName = String.Empty;
 
 			int parmIndex = 1;
-
 			foreach (DataRow schemaRow in dbSchemaTable.Rows) {
-				//if (!IncludedInInsert (schemaRow))
-				//	continue;
+				if (!IncludedInInsert (schemaRow))
+					continue;
 
 				if (parmIndex > 1) {
 					columns.Append (" , ");
@@ -273,38 +277,24 @@ namespace System.Data.OracleClient
 
 				OracleParameter parameter = insertCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-				//dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
-				dsColumnName = schemaRow["ColumnName"].ToString ();
+				dsColumnName = parameter.SourceColumn;
+				if (tableMapping != null 
+					&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+					dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+
 				if (row != null)
 					parameter.Value = row [dsColumnName];
 
-				//DataColumn dc = row.Table.Columns[dsColumnName];
-
 				columns.Append (GetQuotedString (parameter.SourceColumn));
 				values.Append (":" + parameter.ParameterName);
 			}
 
 			sql = String.Format ("{0}( {1} ) VALUES ( {2} )", command, columns.ToString (), values.ToString ());
-
 			insertCommand.CommandText = sql;
-
-			// debug
-			//Console.WriteLine("[Insert SQL Begin]");
-			//Console.WriteLine(sql);
-			//Console.WriteLine("[Insert SQL End]");
-			//Console.WriteLine("Parmeters: " + insertCommand.Parameters.Count.ToString());
-			//for (int p = 0; p < insertCommand.Parameters.Count; p++) {
-			//	OracleParameter parm = insertCommand.Parameters[p];
-			//	Console.WriteLine("Parm " + p.ToString());
-			//	Console.WriteLine("     Name: " + parm.ParameterName);
-			//	Console.WriteLine("    Value: " + parm.Value.ToString());
-			//}
-
 			return insertCommand;
 		}
 
-		private void CreateNewCommand (ref OracleCommand command)
-		{
+		private void CreateNewCommand (ref OracleCommand command) {
 			OracleCommand sourceCommand = SourceCommand;
 			if (command == null) {
 				command = sourceCommand.Connection.CreateCommand ();
@@ -316,9 +306,6 @@ namespace System.Data.OracleClient
 
 		private OracleCommand CreateUpdateCommand (DataRow row, DataTableMapping tableMapping) 
 		{
-			if (tableName == String.Empty)
-				tableName = row.Table.TableName;
-
 			// If no table was found, then we can't do an update
 			if (QuotedTableName == String.Empty)
 				return null;
@@ -328,7 +315,7 @@ namespace System.Data.OracleClient
 			string command = String.Format ("UPDATE {0} SET ", QuotedTableName);
 			StringBuilder columns = new StringBuilder ();
 			StringBuilder whereClause = new StringBuilder ();
-			int parmIndex = 0;
+			int parmIndex = 1;
 			string dsColumnName = String.Empty;
 			bool keyFound = false;
 
@@ -339,21 +326,22 @@ namespace System.Data.OracleClient
 
 				OracleParameter parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-				//dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
-				dsColumnName = schemaRow["ColumnName"].ToString ();
+				dsColumnName = parameter.SourceColumn;
+				if (tableMapping != null 
+					&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+					dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
 
 				if (row != null)
 					parameter.Value = row [dsColumnName];
-					//parameter.Value = row [dsColumnName, DataRowVersion.Proposed];
 
-				columns.Append (String.Format ("{0} = :{1}", GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
+				columns.Append (String.Format ("{0} = {1}", GetQuotedString (parameter.SourceColumn), ":" + parameter.ParameterName));
 			}
 
 			// Now, create the WHERE clause.  This may be optimizable, but it would be ugly to incorporate
-			// into the loop above.  
+			// into the loop above.  "Premature optimization is the root of all evil." -- Knuth
 			foreach (DataRow schemaRow in dbSchemaTable.Rows) {
-				//if (!IncludedInWhereClause (schemaRow)) 
-				//	continue;
+				if (!IncludedInWhereClause (schemaRow)) 
+					continue;
 
 				if (whereClause.Length > 0) 
 					whereClause.Append (" AND ");
@@ -364,29 +352,32 @@ namespace System.Data.OracleClient
 				if (!isKey) {
 					parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-					//dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
-					dsColumnName = schemaRow["ColumnName"].ToString ();
+					dsColumnName = parameter.SourceColumn;
+					if (tableMapping != null 
+						&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+						dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
 
 					if (row != null)
-						parameter.Value = row [dsColumnName];
+						parameter.Value = row [dsColumnName, DataRowVersion.Original];
 
 					whereClause.Append ("(");
-					whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
+					whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), ":" + parameter.ParameterName));
 					whereClause.Append (" OR ");
 				}
-				else {
+				else
 					keyFound = true;
-				}
-
+					
 				parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
 
-				//dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
-				dsColumnName = schemaRow["ColumnName"].ToString ();
+				dsColumnName = parameter.SourceColumn;
+				if (tableMapping != null 
+					&& tableMapping.ColumnMappings.Contains (parameter.SourceColumn))
+					dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
 
 				if (row != null)
-					parameter.Value = row [dsColumnName,DataRowVersion.Original];
+					parameter.Value = row [dsColumnName, DataRowVersion.Original];
 
-				whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
+				whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), ":" + parameter.ParameterName));
 
 				if (!isKey)
 					whereClause.Append (")");
@@ -394,82 +385,30 @@ namespace System.Data.OracleClient
 			if (!keyFound)
 				throw new InvalidOperationException ("Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.");
 
-			// finish the UPDATE SQL statement
+			// We're all done, so bring it on home
 			string sql = String.Format ("{0}{1} WHERE ( {2} )", command, columns.ToString (), whereClause.ToString ());
 			updateCommand.CommandText = sql;
-
-			//Console.WriteLine("[Update SQL Begin]");
-			//Console.WriteLine(sql);
-			//Console.WriteLine("[Update SQL End]");
-
-			// debug
-			//Console.WriteLine("[Update SQL Begin]");
-			//Console.WriteLine(sql);
-			//Console.WriteLine("[Update SQL End]");
-			//Console.WriteLine("Parmeters: " + updateCommand.Parameters.Count.ToString());
-			//for (int p = 0; p < updateCommand.Parameters.Count; p++) {
-			//	OracleParameter parm = updateCommand.Parameters[p];
-			//	Console.WriteLine("Parm " + p.ToString());
-			//	Console.WriteLine("     Name: " + parm.ParameterName);
-			//	Console.WriteLine("    Value: " + parm.Value.ToString());
-			//}
-
 			return updateCommand;
 		}
 
-		private OracleParameter CreateParameter (int parmIndex, DataRow schemaRow)
+		private OracleParameter CreateParameter (int parmIndex, DataRow schemaRow) 
 		{
 			string name = String.Format ("p{0}", parmIndex);
-			string sourceColumn = (string) schemaRow ["ColumnName"];
-			Type dataType = (Type) schemaRow ["DataType"];
+
+			string sourceColumn = (string) schemaRow ["BaseColumnName"];
 			int providerType = (int) schemaRow ["ProviderType"];
-			bool isLong = (bool) schemaRow ["IsLong"];
-			OracleType oratype = (OracleType) providerType;
-			
-			OracleParameter parm = new OracleParameter (name, oratype);
-			parm.SourceColumn = sourceColumn;
-
-			switch (oratype) {
-			case OracleType.Char:
-			case OracleType.VarChar:
-			case OracleType.NChar:
-			case OracleType.NVarChar:
-				int size = (int) schemaRow ["ColumnSize"];
-				parm.Size = size;
-				break;
-			case OracleType.Float:
-			case OracleType.Int16:
-			case OracleType.Int32:
-			case OracleType.Number:
-				//parm.Size = 22;
-				//byte precision = (byte) schemaRow ["NumericPrecision"];
-				//byte scale = (byte) schemaRow ["NumbericScale"];
-				//parm.Precision = precision;
-				//parm.Scale = scale;
-				// let the Bind() call handle this
-				break;
-			case OracleType.Blob:
-			case OracleType.Clob:
-				break;
-			case OracleType.DateTime:
-				//parm.Size = 7;
-				break;
-			default:
-				throw new NotImplementedException ();
-			}
+			OracleType providerDbType = (OracleType) providerType;
+			int size = (int) schemaRow ["ColumnSize"];
 
-			//return new OracleParameter (name, oratype, size, sourceColumn);
-			return parm;
+			return new OracleParameter (name, providerDbType, size, sourceColumn);
 		}
 
-		public static void DeriveParameters (OracleCommand command)
+		public static void DeriveParameters (OracleCommand command) 
 		{
-			// TODO: only to be used for building parameters 
-			// based on a stored procedure
-			//command.DeriveParameters ();
+			command.DeriveParameters ();
 		}
 
-		protected override void Dispose (bool disposing)
+		protected override void Dispose (bool disposing) 
 		{
 			if (!disposed) {
 				if (disposing) {
@@ -486,19 +425,27 @@ namespace System.Data.OracleClient
 			}
 		}
 
-		public OracleCommand GetDeleteCommand ()
+		public 
+#if NET_2_0
+		new
+#endif // NET_2_0
+			OracleCommand GetDeleteCommand () 
 		{
 			BuildCache (true);
 			return CreateDeleteCommand (null, null);
 		}
 
-		public OracleCommand GetInsertCommand ()
+		public 
+#if NET_2_0
+		new
+#endif // NET_2_0
+			OracleCommand GetInsertCommand () 
 		{
 			BuildCache (true);
 			return CreateInsertCommand (null, null);
 		}
 
-		private string GetQuotedString (string value)
+		private string GetQuotedString (string value) 
 		{
 			if (value == String.Empty || value == null)
 				return value;
@@ -507,47 +454,79 @@ namespace System.Data.OracleClient
 			return String.Format ("{0}{1}{2}", quotePrefix, value, quoteSuffix);
 		}
 
-		public OracleCommand GetUpdateCommand ()
+		public 
+#if NET_2_0
+		new
+#endif // NET_2_0
+			OracleCommand GetUpdateCommand () 
 		{
 			BuildCache (true);
 			return CreateUpdateCommand (null, null);
 		}
 
-		private bool IncludedInInsert (DataRow schemaRow)
+		private bool IncludedInInsert (DataRow schemaRow) 
 		{
 			// If the parameter has one of these properties, then we don't include it in the insert:
-
-			//if (!schemaRow.IsNull ("IsExpression") && (bool) schemaRow ["IsExpression"])
-			//	return false;
+			if (!schemaRow.IsNull ("IsExpression") && (bool) schemaRow ["IsExpression"])
+				return false;
 			return true;
 		}
 
-		private bool IncludedInUpdate (DataRow schemaRow)
-		{
+		private bool IncludedInUpdate (DataRow schemaRow) {
 			// If the parameter has one of these properties, then we don't include it in the insert:
+			// AutoIncrement, Hidden, RowVersion
 
 			return true;
 		}
 
-		private bool IncludedInWhereClause (DataRow schemaRow)
-		{
+		private bool IncludedInWhereClause (DataRow schemaRow) {
 			if ((bool) schemaRow ["IsLong"])
 				return false;
 			return true;
 		}
 
 		[MonoTODO ("Figure out what else needs to be cleaned up when we refresh.")]
-		public void RefreshSchema () 
+		public 
+#if NET_2_0
+		override
+#endif // NET_2_0
+			void RefreshSchema () 
 		{
 			tableName = String.Empty;
 			dbSchemaTable = null;
 		}
 
+#if NET_2_0
+                [MonoTODO]
+                protected override void ApplyParameterInfo (IDbDataParameter dbParameter, DataRow row)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                protected override string GetParameterName (int position)
+                {
+                        throw new NotImplementedException ();                        
+                }
+                
+
+                [MonoTODO]
+                protected override string GetParameterPlaceholder (int position)
+                {
+                        throw new NotImplementedException ();                        
+                }
+                
+                [MonoTODO]
+                protected override DbProviderFactory ProviderFactory
+                {
+                        get {throw new NotImplementedException ();}
+                }
+#endif // NET_2_0
 		#endregion // Methods
 
 		#region Event Handlers
 
-		private void RowUpdatingHandler (object sender, OracleRowUpdatingEventArgs e)
+		private void RowUpdatingHandler (object sender, OracleRowUpdatingEventArgs e) 
 		{
 			if (e.Status != UpdateStatus.Continue)
 				return;
@@ -585,8 +564,9 @@ namespace System.Data.OracleClient
 				}
 
 				if (e.Command != null && e.Row != null) {
-					e.Row.AcceptChanges ();
-					e.Status = UpdateStatus.SkipCurrentRow;
+					if (e.StatementType != StatementType.Delete)
+						e.Row.AcceptChanges ();
+					e.Status = UpdateStatus.Continue;
 				}
 			}
 			catch (Exception exception) {
@@ -595,6 +575,15 @@ namespace System.Data.OracleClient
 			}
 		}
 
+#if NET_2_0
+                [MonoTODO]
+                protected override void SetRowUpdatingHandler (DbDataAdapter adapter)
+                {
+                        throw new NotImplementedException ();
+                }
+#endif // NET_2_0
+
 		#endregion // Event Handlers
 	}
 }
+

+ 16 - 8
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleDataReader.cs

@@ -404,8 +404,13 @@ namespace System.Data.OracleClient {
 
 		private int GetRecordsAffected ()
 		{
-			if (recordsAffected == -1) 
-				recordsAffected = statement.GetAttributeInt32 (OciAttributeType.RowCount, command.ErrorHandle);
+			if (recordsAffected == -1) {
+				try {
+					recordsAffected = statement.GetAttributeInt32 (OciAttributeType.RowCount, command.ErrorHandle);
+				}
+				catch { }
+			}
+			
 			return recordsAffected;
 		}
 
@@ -540,6 +545,7 @@ namespace System.Data.OracleClient {
 				}
 			}
 		}
+
 		public DataTable GetSchemaTable ()
 		{
 			StringCollection keyinfo = null;
@@ -590,10 +596,9 @@ namespace System.Data.OracleClient {
 						row ["IsKey"] = false;
 
 					row ["IsUnique"]	= DBNull.Value; // TODO: only set this if CommandBehavior.KeyInfo, otherwise, null
-					row ["BaseSchemaName"]	= DBNull.Value;  // TODO: only set this if CommandBehavior.KeyInfo, otherwise, null
+					row ["BaseSchemaName"]	= DBNull.Value; // TODO: only set this if CommandBehavior.KeyInfo, otherwise, null
 					row ["BaseTableName"]	= table;
-					row ["BaseColumnName"]	= DBNull.Value;  // TODO: only set this if CommandBehavior.KeyInfo, otherwise, null
-
+					row ["BaseColumnName"]	= row ["ColumnName"];
 				}	
 				else {
 					row ["IsKey"]		= DBNull.Value;	
@@ -681,9 +686,12 @@ namespace System.Data.OracleClient {
 
 		public bool Read ()
 		{
-			bool retval = statement.Fetch ();
-			hasRows = retval;
-			return retval;
+			if (hasRows) {
+				bool retval = statement.Fetch ();
+				hasRows = retval;
+				return retval;
+			}
+			return false;
 		}
 
 		#endregion // Methods

+ 0 - 475
mcs/class/System.Data.OracleClient/Test/OracleAdapterTest.cs

@@ -1,475 +0,0 @@
-//
-// OracleAdapterTest.cs - tests select/insert/update/delete of
-//                        a DataSet/DataTable with 
-//                        OracleDataAdapter and OracleCommandBuilder
-//
-// Author:
-//      Daniel Morgan <[email protected]>
-//
-// Copyright (C) Daniel Morgan, 2005
-//
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.IO;
-using System.Data;
-using System.Data.Common;
-using System.Data.OracleClient;
-using System.Text;
-
-class OracleAdapterTest 
-{
-	static string infilename = @"mono-win32-setup-dark.bmp";
-
-	public static void Main(string[] args) 
-	{
-		if(args.Length != 3) {
-			Console.WriteLine("Usage: mono TestOracleClient database userid password");
-			return;
-		}
-
-		string connectionString = String.Format(
-			"Data Source={0};" +
-			"User ID={1};" +
-			"Password={2}",
-			args[0], args[1], args[2]);
-
-		OracleConnection con = new OracleConnection ();
-		con.ConnectionString = connectionString;
-		con.Open ();
-		
-		Setup (con);
-		ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
-		
-		GetMetaData (con);
-
-		Insert (con);
-		ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
-		
-		Update (con);
-		ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
-
-		//Delete (con);
-		//ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
-		
-		con.Close ();		
-	}
-
-	public static void GetMetaData(OracleConnection con) 
-	{
-		OracleCommand cmd = null;
-		OracleDataReader rdr = null;
-		
-		cmd = con.CreateCommand();
-		cmd.CommandText = "select * from mono_adapter_test";
-
-		Console.WriteLine("Read Schema With KeyInfo");
-		rdr = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly);
-		
-		DataTable dt;
-		dt = rdr.GetSchemaTable();
-		foreach (DataRow schemaRow in dt.Rows) {
-			foreach (DataColumn schemaCol in dt.Columns) {
-				Console.WriteLine(schemaCol.ColumnName + 
-					" = " + 
-					schemaRow[schemaCol]);
-				Console.WriteLine("---Type: " + schemaRow[schemaCol].GetType ().ToString());
-			}
-			Console.WriteLine("");
-		}
-
-		Console.WriteLine("Read Schema with No KeyInfo");
-
-		rdr = cmd.ExecuteReader();
-
-		dt = rdr.GetSchemaTable();
-		foreach (DataRow schemaRow in dt.Rows) {
-			foreach (DataColumn schemaCol in dt.Columns) {
-				Console.WriteLine(schemaCol.ColumnName + 
-					" = " + 
-					schemaRow[schemaCol]);
-				Console.WriteLine("---Type: " + schemaRow[schemaCol].GetType ().ToString());
-				Console.WriteLine();
-			}
-		}
-
-	}
-
-
-	public static void Setup (OracleConnection con)
-	{
-		Console.WriteLine ("  Drop table mono_adapter_test ...");
-		try {
-			OracleCommand cmd2 = con.CreateCommand ();
-			cmd2.CommandText = "DROP TABLE mono_adapter_test";
-			cmd2.ExecuteNonQuery ();
-		}
-		catch (OracleException oe1) {
-			// ignore if table already exists
-		}
-
-		OracleCommand cmd = null;
-		int rowsAffected = 0;
-
-		Console.WriteLine("  Creating table mono_adapter_test...");
-		cmd = new OracleCommand ();
-		cmd.Connection = con;
-		cmd.CommandText = "CREATE TABLE mono_adapter_test ( " +
-			" varchar2_value VarChar2(32),  " +
-			" number_whole_value Number(18) PRIMARY KEY, " +
-			" number_scaled_value Number(18,2), " +
-			" number_integer_value Integer, " +
-			" float_value Float, " +
-			" date_value Date, " +
-			" char_value Char(32), " +
-			" clob_value Clob, " +
-			" blob_value Blob ) ";
-
-		rowsAffected = cmd.ExecuteNonQuery();
-
-		Console.WriteLine("  Begin Trans for table mono_adapter_test...");
-		OracleTransaction trans = con.BeginTransaction ();
-
-		Console.WriteLine("  Inserting value into mono_adapter_test...");
-		cmd = new OracleCommand();
-		cmd.Connection = con;
-		cmd.Transaction = trans;
-		cmd.CommandText = "INSERT INTO mono_adapter_test " +
-			" ( varchar2_value,  " +
-			"  number_whole_value, " +
-			"  number_scaled_value, " +
-			"  number_integer_value, " +
-			"  float_value, " +
-			"  date_value, " +
-			"  char_value, " +
-			"  clob_value, " +
-			"  blob_value " +
-			") " +
-			" VALUES( " +
-			"  'Mono', " +
-			"  11, " +
-			"  456.78, " +
-			"  8765, " +
-			"  235.2, " +
-			"  TO_DATE( '2004-12-31', 'YYYY-MM-DD' ), " +
-			"  'US', " +
-			"  EMPTY_CLOB(), " +
-			"  EMPTY_BLOB() " +
-			")";
-
-		rowsAffected = cmd.ExecuteNonQuery();
-
-		Console.WriteLine("  Select/Update CLOB columns on table mono_adapter_test...");
-
-		// update BLOB and CLOB columns
-		OracleCommand select = con.CreateCommand ();
-		select.Transaction = trans;
-		select.CommandText = "SELECT CLOB_VALUE, BLOB_VALUE FROM mono_adapter_test FOR UPDATE";
-		OracleDataReader reader = select.ExecuteReader ();
-		if (!reader.Read ())
-			Console.WriteLine ("ERROR: RECORD NOT FOUND");
-		// update clob_value
-		Console.WriteLine("     Update CLOB column on table mono_adapter_test...");
-		OracleLob clob = reader.GetOracleLob (0);
-		byte[] bytes = null;
-		UnicodeEncoding encoding = new UnicodeEncoding ();
-		bytes = encoding.GetBytes ("Mono is fun!");
-		clob.Write (bytes, 0, bytes.Length);
-		clob.Close ();
-		// update blob_value
-		Console.WriteLine("     Update BLOB column on table mono_adapter_test...");
-		OracleLob blob = reader.GetOracleLob (1);
-		bytes = new byte[6] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x036 };
-		blob.Write (bytes, 0, bytes.Length);
-		blob.Close ();
-			
-		Console.WriteLine("  Commit trans for table mono_adapter_test...");
-		trans.Commit ();
-
-		CommitCursor (con);
-	}
-
-	public static void Insert (OracleConnection con) 
-	{
-		Console.WriteLine("================================");
-		Console.WriteLine("=== Adapter Insert =============");
-		Console.WriteLine("================================");
-		OracleTransaction transaction = con.BeginTransaction ();
-		
-		Console.WriteLine("   Create adapter...");
-		OracleDataAdapter da = new OracleDataAdapter("select * from mono_adapter_test", con);
-		da.SelectCommand.Transaction = transaction;
-		
-		Console.WriteLine("   Create command builder...");
-		OracleCommandBuilder mycb = new OracleCommandBuilder(da);
-
-		Console.WriteLine("   Create data set ...");
-		DataSet ds = new DataSet();
-
-		Console.WriteLine("Set missing schema action...");
-		da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-		
-		Console.WriteLine("Get data from file...");
-		FileStream fs = new FileStream(infilename, FileMode.OpenOrCreate, FileAccess.Read);
-		Byte[] mydata = new Byte[fs.Length];			
-		fs.Read(mydata, 0, (int) fs.Length);
-		fs.Close();
-		
-		Console.WriteLine("Fill data set via adapter...");
-		da.Fill(ds, "mono_adapter_test");
-
-		Console.WriteLine("New Row...");
-		DataRow myRow;
-		myRow = ds.Tables["mono_adapter_test"].NewRow();
-
-		byte[] bytes = new byte[] { 0x45,0x46,0x47,0x48,0x49,0x50 };
-
-		Console.WriteLine("Set values in the new DataRow...");
-		myRow["varchar2_value"] = "OracleClient";
-		myRow["number_whole_value"] = 22;
-		myRow["number_scaled_value"] = 12.34;
-		myRow["number_integer_value"] = 456;
-		myRow["float_value"] = 98.76;
-		myRow["date_value"] = new DateTime(2001,07,09);
-		myRow["char_value"] = "Romeo";
-		myRow["clob_value"] = "clobtest";
-		myRow["blob_value"] = bytes;
-
-		Console.WriteLine("Add DataRow to DataTable...");		
-		ds.Tables["mono_adapter_test"].Rows.Add(myRow);
-
-		Console.WriteLine("da.Update(ds...");
-		da.Update(ds, "mono_adapter_test");
-
-		transaction.Commit();
-	}
-
-	public static void Update (OracleConnection con) 
-	{
-		Console.WriteLine("================================");
-		Console.WriteLine("=== Adapter Update =============");
-		Console.WriteLine("================================");
-
-		OracleTransaction transaction = con.BeginTransaction ();
-
-		Console.WriteLine("   Create adapter...");
-		OracleCommand selectCmd = con.CreateCommand ();
-		selectCmd.Transaction = transaction;
-		selectCmd.CommandText = "SELECT * FROM mono_adapter_test";
-		OracleDataAdapter da = new OracleDataAdapter(selectCmd);
-		Console.WriteLine("   Create command builder...");
-		OracleCommandBuilder mycb = new OracleCommandBuilder(da);
-		Console.WriteLine("   Create data set ...");
-		DataSet ds = new DataSet();
-
-		Console.WriteLine("Set missing schema action...");
-		da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-		
-		Console.WriteLine("Fill data set via adapter...");
-		da.Fill(ds, "mono_adapter_test");
-		DataRow myRow;
-
-		Console.WriteLine("New Row...");
-		myRow = ds.Tables["mono_adapter_test"].Rows[0];
-
-		Console.WriteLine("Tables Count: " + ds.Tables.Count.ToString());
-
-		DataTable table = ds.Tables["mono_adapter_test"];
-		DataRowCollection rows;
-		rows = table.Rows;
-		Console.WriteLine("Row Count: " + rows.Count.ToString());
-		myRow = rows[0];
-
-		byte[] bytes = new byte[] { 0x45,0x46,0x47,0x48,0x49,0x50 };
-
-		Console.WriteLine("Set values in the new DataRow...");
-		
-		Console.WriteLine("Columns count: " + table.Columns.Count.ToString());
-
-		myRow["varchar2_value"] = "Puppy Power!";
-		myRow["number_whole_value"] = 33;
-		myRow["number_scaled_value"] = 12.34;
-		myRow["number_scaled_value"] = 12.34;
-		myRow["number_integer_value"] = 456;
-		myRow["float_value"] = 98.76;
-		myRow["date_value"] = new DateTime(2001,07,09);
-		myRow["char_value"] = "Romeo";
-		myRow["clob_value"] = "clobtest";
-		myRow["blob_value"] = bytes;
-
-		Console.WriteLine("da.Update(ds...");
-		da.Update(ds, "mono_adapter_test");
-
-		transaction.Commit();
-	}
-
-	public static void Delete (OracleConnection con) 
-	{
-		Console.WriteLine("================================");
-		Console.WriteLine("=== Adapter Delete =============");
-		Console.WriteLine("================================");
-		OracleTransaction transaction = con.BeginTransaction ();
-		
-		Console.WriteLine("   Create adapter...");
-		OracleDataAdapter da = new OracleDataAdapter("SELECT * FROM mono_adapter_test", con);
-		da.SelectCommand.Transaction = transaction;
-
-		Console.WriteLine("   Create command builder...");
-		OracleCommandBuilder mycb = new OracleCommandBuilder(da);
-
-		Console.WriteLine("   Create data set ...");
-		DataSet ds = new DataSet();
-
-		Console.WriteLine("Set missing schema action...");
-		da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
-		
-		Console.WriteLine("Fill data set via adapter...");
-		da.Fill(ds, "mono_adapter_test");
-
-		Console.WriteLine("Get DataRow...");
-		DataTable table = ds.Tables["mono_adapter_test"];
-		DataRowCollection rows = table.Rows;
-		DataRow myRow = rows[0];
-
-		Console.WriteLine("row remove...");
-		rows.Remove(myRow);
-
-		Console.WriteLine("da.Update(table...");
-		da.Update(table);
-
-		Console.WriteLine("Commit...");
-		transaction.Commit();
-	}
-
-	static void CommitCursor (OracleConnection con) 
-	{
-		OracleCommand cmd = con.CreateCommand ();
-		cmd.CommandText = "COMMIT";
-		cmd.ExecuteNonQuery ();
-		cmd.Dispose ();
-		cmd = null;
-	}
-
-	static void ReadSimpleTest (OracleConnection con, string selectSql) 
-	{
-		OracleCommand cmd = null;
-		OracleDataReader reader = null;
-		
-		cmd = con.CreateCommand ();
-		cmd.CommandText = selectSql;
-		reader = cmd.ExecuteReader ();
-		
-		Console.WriteLine("  Results...");
-		Console.WriteLine("    Schema");
-		DataTable table;
-		table = reader.GetSchemaTable ();
-		for (int c = 0; c < reader.FieldCount; c++) {
-			Console.WriteLine("  Column " + c.ToString ());
-			DataRow row = table.Rows[c];
-			
-			string strColumnName = row["ColumnName"].ToString();
-			string strBaseColumnName = row["BaseColumnName"].ToString();
-			string strColumnSize = row["ColumnSize"].ToString();
-			string strNumericScale = row["NumericScale"].ToString();
-			string strNumericPrecision = row["NumericPrecision"].ToString();
-			string strDataType = row["DataType"].ToString();
-			string strBaseTableName = row["BaseTableName"].ToString();
-			string strBaseSchemaName = row["BaseSchemaName"].ToString();
-
-			Console.WriteLine("      ColumnName: " + strColumnName);
-			Console.WriteLine("      BaseColumnName: " + strBaseColumnName);
-			Console.WriteLine("      ColumnSize: " + strColumnSize);
-			Console.WriteLine("      NumericScale: " + strNumericScale);
-			Console.WriteLine("      NumericPrecision: " + strNumericPrecision);
-			Console.WriteLine("      DataType: " + strDataType);
-			Console.WriteLine("      BaseTableName: " + strBaseTableName);
-			Console.WriteLine("      BaseSchemaName: " + strBaseSchemaName);
-		}
-		
-		int r = 0;
-		Console.WriteLine ("    Data");
-		while (reader.Read ()) {
-			r++;
-			Console.WriteLine ("       Row: " + r.ToString ());
-			for (int f = 0; f < reader.FieldCount; f++) {
-				string sname = "";
-				object ovalue = "";
-				string svalue = "";
-				string sDataType = "";
-				string sFieldType = "";
-				string sDataTypeName = "";
-				string sOraDataType = "";
-
-				sname = reader.GetName (f);
-
-				if (reader.IsDBNull (f)) {
-					ovalue = DBNull.Value;
-					svalue = "";
-					sDataType = "DBNull.Value";
-					sOraDataType = "DBNull.Value";
-				}
-				else {
-					ovalue = reader.GetOracleValue (f);
-					object oravalue = null;
-					
-					sDataType = ovalue.GetType ().ToString ();
-					switch (sDataType) {
-					case "System.Data.OracleClient.OracleString":
-						oravalue = ((OracleString) ovalue).Value;
-						break;
-					case "System.Data.OracleClient.OracleNumber":
-						oravalue = ((OracleNumber) ovalue).Value;
-						break;
-					case "System.Data.OracleClient.OracleLob":
-						OracleLob lob = (OracleLob) ovalue;
-						oravalue = lob.Value;
-						lob.Close ();
-						break;
-					case "System.Data.OracleClient.OracleDateTime":
-						oravalue = ((OracleDateTime) ovalue).Value;
-						break;
-					default:
-						oravalue = "*** no test available ***";
-						break;
-					}
-					
-					sOraDataType = oravalue.GetType ().ToString ();
-					if (sOraDataType.Equals ("System.Byte[]")) 
-						svalue = GetHexString ((byte[]) oravalue);
-					else
-						svalue = oravalue.ToString();
-						
-				}
-				sFieldType = reader.GetFieldType(f).ToString();
-				sDataTypeName = reader.GetDataTypeName(f);
-
-				Console.WriteLine("           Field: " + f.ToString());
-				Console.WriteLine("               Name: " + sname);
-				Console.WriteLine("               Value: " + svalue);
-				//Console.WriteLine("               Oracle Data Type: " + sOraDataType);
-				//Console.WriteLine("               Data Type: " + sDataType);
-				//Console.WriteLine("               Field Type: " + sFieldType);
-				//Console.WriteLine("               Data Type Name: " + sDataTypeName);
-			}
-		}
-		if(r == 0)
-			Console.WriteLine("  No data returned.");
-	}
-
-	public static string GetHexString (byte[] bytes) 
-	{ 			
-		string bvalue = "";
-			
-		StringBuilder sb2 = new StringBuilder();
-		for (int z = 0; z < bytes.Length; z++) {
-			byte byt = bytes[z];
-			sb2.Append (byt.ToString("x"));
-		}
-		if (sb2.Length > 0)
-			bvalue = "0x" + sb2.ToString ();
-	
-		return bvalue;
-	}
-}
-

+ 531 - 7
mcs/class/System.Data.OracleClient/Test/TestOracleClient.cs

@@ -291,8 +291,8 @@ namespace Test.OracleClient
 						sOraDataType = "DBNull.Value";
 					}
 					else {
-						ovalue = reader.GetValue (f);
-						//ovalue = reader.GetOracleValue (f);
+						//ovalue = reader.GetValue (f);
+						ovalue = reader.GetOracleValue (f);
 						object oravalue = null;
 					
 						sDataType = ovalue.GetType ().ToString ();
@@ -315,12 +315,12 @@ namespace Test.OracleClient
 							oravalue = GetHexString((byte[])ovalue);
 							break;
 						case "System.Decimal":
-							Console.WriteLine("           *** Get Decimal, Int16, Int32, Int64, Float, Double, ...");
+							//Console.WriteLine("           *** Get Decimal, Int16, Int32, Int64, Float, Double, ...");
 							decimal dec = reader.GetDecimal (f);
-							Console.WriteLine("             GetDecimal: " + dec.ToString ());
+							//Console.WriteLine("             GetDecimal: " + dec.ToString ());
 
 							oravalue = (object) dec;
-
+/*
 							try {
 								reader.GetInt16 (f);
 							} catch (NotSupportedException e) {
@@ -339,7 +339,7 @@ namespace Test.OracleClient
 							} catch (OverflowException oe1) {
 								Console.WriteLine ("            ** Overflow exception for numbers to big or too small: " + oe1.Message);
 								}
-						
+							*/
 							break;
 						default:
 							oravalue = ovalue.ToString ();
@@ -400,6 +400,419 @@ namespace Test.OracleClient
 			}
 		}
 
+		public static void DataAdapterTest2 (OracleConnection con) 
+		{
+			DataAdapterTest2_Setup (con);
+			ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
+		
+			GetMetaData (con, "SELECT * FROM mono_adapter_test");
+
+			DataAdapterTest2_Insert (con);
+			ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
+		
+			DataAdapterTest2_Update (con);
+			ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
+
+			DataAdapterTest2_Delete (con);
+			ReadSimpleTest (con, "SELECT * FROM mono_adapter_test");
+		}
+
+		public static void GetMetaData (OracleConnection con, string sql) 
+		{
+			OracleCommand cmd = null;
+			OracleDataReader rdr = null;
+		
+			cmd = con.CreateCommand();
+			cmd.CommandText = sql;
+
+			Console.WriteLine("Read Schema With KeyInfo");
+			rdr = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly);
+		
+			DataTable dt;
+			dt = rdr.GetSchemaTable();
+			foreach (DataRow schemaRow in dt.Rows) {
+				foreach (DataColumn schemaCol in dt.Columns) {
+					Console.WriteLine(schemaCol.ColumnName + 
+						" = " + 
+						schemaRow[schemaCol]);
+					Console.WriteLine("---Type: " + schemaRow[schemaCol].GetType ().ToString());
+				}
+				Console.WriteLine("");
+			}
+
+			Console.WriteLine("Read Schema with No KeyInfo");
+
+			rdr = cmd.ExecuteReader();
+
+			dt = rdr.GetSchemaTable();
+			foreach (DataRow schemaRow in dt.Rows) {
+				foreach (DataColumn schemaCol in dt.Columns) {
+					Console.WriteLine(schemaCol.ColumnName + 
+						" = " + 
+						schemaRow[schemaCol]);
+					Console.WriteLine("---Type: " + schemaRow[schemaCol].GetType ().ToString());
+					Console.WriteLine();
+				}
+			}
+
+		}
+
+		public static void DataAdapterTest2_Setup (OracleConnection con) 
+		{
+			Console.WriteLine ("  Drop table mono_adapter_test ...");
+			try {
+				OracleCommand cmd2 = con.CreateCommand ();
+				cmd2.CommandText = "DROP TABLE mono_adapter_test";
+				cmd2.ExecuteNonQuery ();
+			}
+			catch (OracleException oe1) {
+				// ignore if table already exists
+			}
+
+			OracleCommand cmd = null;
+			int rowsAffected = 0;
+
+			Console.WriteLine("  Creating table mono_adapter_test...");
+			cmd = new OracleCommand ();
+			cmd.Connection = con;
+			cmd.CommandText = "CREATE TABLE mono_adapter_test ( " +
+				" varchar2_value VarChar2(32),  " +
+				" number_whole_value Number(18) PRIMARY KEY, " +
+				" number_scaled_value Number(18,2), " +
+				" number_integer_value Integer, " +
+				" float_value Float, " +
+				" date_value Date, " +
+				" clob_value Clob, " +
+				" blob_value Blob ) ";
+		
+			// FIXME: char_value does not work
+			/*
+			cmd.CommandText = "CREATE TABLE mono_adapter_test ( " +
+				" varchar2_value VarChar2(32),  " +
+				" number_whole_value Number(18) PRIMARY KEY, " +
+				" number_scaled_value Number(18,2), " +
+				" number_integer_value Integer, " +
+				" float_value Float, " +
+				" date_value Date, " +
+				" char_value Char(32), " +
+				" clob_value Clob, " +
+				" blob_value Blob ) ";
+			*/
+
+			rowsAffected = cmd.ExecuteNonQuery();
+
+			Console.WriteLine("  Begin Trans for table mono_adapter_test...");
+			OracleTransaction trans = con.BeginTransaction ();
+
+			Console.WriteLine("  Inserting value into mono_adapter_test...");
+			cmd = new OracleCommand();
+			cmd.Connection = con;
+			cmd.Transaction = trans;
+		
+			cmd.CommandText = "INSERT INTO mono_adapter_test " +
+				" ( varchar2_value,  " +
+				"  number_whole_value, " +
+				"  number_scaled_value, " +
+				"  number_integer_value, " +
+				"  float_value, " +
+				"  date_value, " +
+				"  clob_value, " +
+				"  blob_value " +
+				") " +
+				" VALUES( " +
+				"  'Mono', " +
+				"  11, " +
+				"  456.78, " +
+				"  8765, " +
+				"  235.2, " +
+				"  TO_DATE( '2004-12-31', 'YYYY-MM-DD' ), " +
+				"  EMPTY_CLOB(), " +
+				"  EMPTY_BLOB() " +
+				")";
+
+			/*
+					cmd.CommandText = "INSERT INTO mono_adapter_test " +
+						" ( varchar2_value,  " +
+						"  number_whole_value, " +
+						"  number_scaled_value, " +
+						"  number_integer_value, " +
+						"  float_value, " +
+						"  date_value, " +
+						"  char_value, " +
+						"  clob_value, " +
+						"  blob_value " +
+						") " +
+						" VALUES( " +
+						"  'Mono', " +
+						"  11, " +
+						"  456.78, " +
+						"  8765, " +
+						"  235.2, " +
+						"  TO_DATE( '2004-12-31', 'YYYY-MM-DD' ), " +
+						"  'US', " +
+						"  EMPTY_CLOB(), " +
+						"  EMPTY_BLOB() " +
+						")";
+			*/
+			rowsAffected = cmd.ExecuteNonQuery();
+
+			Console.WriteLine("  Select/Update CLOB columns on table mono_adapter_test...");
+		
+			// update BLOB and CLOB columns
+			OracleCommand select = con.CreateCommand ();
+			select.Transaction = trans;
+			select.CommandText = "SELECT CLOB_VALUE, BLOB_VALUE FROM mono_adapter_test FOR UPDATE";
+			OracleDataReader reader = select.ExecuteReader ();
+			if (!reader.Read ())
+				Console.WriteLine ("ERROR: RECORD NOT FOUND");
+		
+			// update clob_value
+			Console.WriteLine("     Update CLOB column on table mono_adapter_test...");
+			OracleLob clob = reader.GetOracleLob (0);
+			byte[] bytes = null;
+			UnicodeEncoding encoding = new UnicodeEncoding ();
+			bytes = encoding.GetBytes ("Mono is fun!");
+			clob.Write (bytes, 0, bytes.Length);
+			clob.Close ();
+		
+			// update blob_value
+			Console.WriteLine("     Update BLOB column on table mono_adapter_test...");
+			OracleLob blob = reader.GetOracleLob (1);
+			bytes = new byte[6] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x036 };
+			blob.Write (bytes, 0, bytes.Length);
+			blob.Close ();
+			
+			Console.WriteLine("  Commit trans for table mono_adapter_test...");
+			trans.Commit ();
+
+			CommitCursor (con);
+		}
+
+		public static void DataAdapterTest2_Insert (OracleConnection con) 
+		{
+			Console.WriteLine("================================");
+			Console.WriteLine("=== Adapter Insert =============");
+			Console.WriteLine("================================");
+			OracleTransaction transaction = con.BeginTransaction ();
+		
+			Console.WriteLine("   Create adapter...");
+			OracleDataAdapter da = new OracleDataAdapter("select * from mono_adapter_test", con);
+			da.SelectCommand.Transaction = transaction;
+		
+			Console.WriteLine("   Create command builder...");
+			OracleCommandBuilder mycb = new OracleCommandBuilder(da);
+
+			Console.WriteLine("   Create data set ...");
+			DataSet ds = new DataSet();
+		
+			Console.WriteLine("   Fill data set via adapter...");
+			da.Fill(ds, "mono_adapter_test");
+
+			Console.WriteLine("   New Row...");
+			DataRow myRow;
+			myRow = ds.Tables["mono_adapter_test"].NewRow();
+
+			byte[] bytes = new byte[] { 0x45,0x46,0x47,0x48,0x49,0x50 };
+
+			Console.WriteLine("   Set values in the new DataRow...");
+			myRow["varchar2_value"] = "OracleClient";
+			myRow["number_whole_value"] = 22;
+			myRow["number_scaled_value"] = 12.34;
+			myRow["number_integer_value"] = 456;
+			myRow["float_value"] = 98.76;
+			myRow["date_value"] = new DateTime(2001,07,09);
+			Console.WriteLine("   *** FIXME; char value not working");
+			//myRow["char_value"] = "Romeo";
+			myRow["clob_value"] = "clobtest";
+			myRow["blob_value"] = bytes;
+		
+			Console.WriteLine("    Add DataRow to DataTable...");		
+			ds.Tables["mono_adapter_test"].Rows.Add(myRow);
+
+			Console.WriteLine("da.Update(ds...");
+			da.Update(ds, "mono_adapter_test");
+
+			transaction.Commit();
+		}
+
+		public static void DataAdapterTest2_Update (OracleConnection con) 
+		{
+			Console.WriteLine("================================");
+			Console.WriteLine("=== Adapter Update =============");
+			Console.WriteLine("================================");
+
+			OracleTransaction transaction = con.BeginTransaction ();
+
+			Console.WriteLine("   Create adapter...");
+			OracleCommand selectCmd = con.CreateCommand ();
+			selectCmd.Transaction = transaction;
+			selectCmd.CommandText = "SELECT * FROM mono_adapter_test";
+			OracleDataAdapter da = new OracleDataAdapter(selectCmd);
+			Console.WriteLine("   Create command builder...");
+			OracleCommandBuilder mycb = new OracleCommandBuilder(da);
+			Console.WriteLine("   Create data set ...");
+			DataSet ds = new DataSet();
+
+			Console.WriteLine("   Set missing schema action...");
+		
+			Console.WriteLine("  Fill data set via adapter...");
+			da.Fill(ds, "mono_adapter_test");
+			DataRow myRow;
+
+			Console.WriteLine("   New Row...");
+			myRow = ds.Tables["mono_adapter_test"].Rows[0];
+
+			Console.WriteLine("Tables Count: " + ds.Tables.Count.ToString());
+
+			DataTable table = ds.Tables["mono_adapter_test"];
+			DataRowCollection rows;
+			rows = table.Rows;
+			Console.WriteLine("   Row Count: " + rows.Count.ToString());
+			myRow = rows[0];
+
+			byte[] bytes = new byte[] { 0x62,0x63,0x64,0x65,0x66,0x67 };
+
+			Console.WriteLine("   Set values in the new DataRow...");
+
+			myRow["varchar2_value"] = "Super Power!";
+		
+			myRow["number_scaled_value"] = 12.35;
+			myRow["number_integer_value"] = 457;
+			myRow["float_value"] = 198.76;
+			myRow["date_value"] = new DateTime(2002,08,09);
+			//myRow["char_value"] = "Juliet";
+			myRow["clob_value"] = "this is a clob";
+			myRow["blob_value"] = bytes;
+
+			Console.WriteLine("da.Update(ds...");
+			da.Update(ds, "mono_adapter_test");
+
+			transaction.Commit();
+		}
+
+		public static void DataAdapterTest2_Delete (OracleConnection con) 
+		{
+			Console.WriteLine("================================");
+			Console.WriteLine("=== Adapter Delete =============");
+			Console.WriteLine("================================");
+			OracleTransaction transaction = con.BeginTransaction ();
+		
+			Console.WriteLine("   Create adapter...");
+			OracleDataAdapter da = new OracleDataAdapter("SELECT * FROM mono_adapter_test", con);
+			Console.WriteLine("   Create command builder...");
+			OracleCommandBuilder mycb = new OracleCommandBuilder(da);
+			Console.WriteLine("   set transr...");
+			da.SelectCommand.Transaction = transaction;
+
+			Console.WriteLine("   Create data set ...");
+			DataSet ds = new DataSet();
+		
+			Console.WriteLine("Fill data set via adapter...");
+			da.Fill(ds, "mono_adapter_test");
+
+			Console.WriteLine("delete row...");
+			ds.Tables["mono_adapter_test"].Rows[0].Delete();
+
+			Console.WriteLine("da.Update(table...");
+			da.Update(ds, "mono_adapter_test");
+
+			Console.WriteLine("Commit...");
+			transaction.Commit();
+		}
+
+		static void TestNonQueryUsingExecuteReader(OracleConnection con) 
+		{
+			OracleDataReader reader = null;
+			OracleTransaction trans = null;
+
+			Console.WriteLine("   drop table mono_adapter_test...");
+			OracleCommand cmd = con.CreateCommand();
+
+			cmd.CommandText = "DROP TABLE MONO_ADAPTER_TEST";
+			trans = con.BeginTransaction();
+			cmd.Transaction = trans;
+			try {
+				reader = cmd.ExecuteReader();
+				Console.WriteLine("   RowsAffected before read: " + reader.RecordsAffected.ToString());
+				reader.Read();
+				Console.WriteLine("   RowsAffected after read: " + reader.RecordsAffected.ToString());
+				reader.Close();
+				trans.Commit();
+			}
+			catch(OracleException e) {
+				Console.WriteLine("   OracleException caught: " + e.Message);
+				trans.Commit();
+			}
+
+			Console.WriteLine("   Create table mono_adapter_test...");
+			cmd.CommandText = "CREATE TABLE MONO_ADAPTER_TEST ( " +
+				" varchar2_value VarChar2(32),  " +
+				" number_whole_value Number(18,0) PRIMARY KEY ) ";
+			trans = con.BeginTransaction();
+			cmd.Transaction = trans;
+			reader = cmd.ExecuteReader();
+			Console.WriteLine("   RowsAffected before read: " + reader.RecordsAffected.ToString());
+			reader.Read();
+			Console.WriteLine("   RowsAffected after read: " + reader.RecordsAffected.ToString());
+			reader.Close();
+			trans.Commit();
+
+			Console.WriteLine("Insert into table mono_adapter_test...");
+			
+			string sql =
+				"INSERT INTO MONO_ADAPTER_TEST " +
+				"(VARCHAR2_VALUE,NUMBER_WHOLE_VALUE) " +
+				"VALUES(:p1,:p2)";
+
+			OracleCommand cmd2 = con.CreateCommand();
+			trans = con.BeginTransaction();
+			cmd2.Transaction = trans;
+			cmd2.CommandText = sql;
+			
+			OracleParameter myParameter1 = new OracleParameter("p1", OracleType.VarChar, 32);
+			myParameter1.Direction = ParameterDirection.Input;
+		
+			OracleParameter myParameter2 = new OracleParameter("p2", OracleType.Number);
+			myParameter2.Direction = ParameterDirection.Input;
+
+			myParameter2.Value = 182;
+			myParameter1.Value = "Mono";
+
+			cmd2.Parameters.Add (myParameter1);
+			cmd2.Parameters.Add (myParameter2);
+			
+			// insert 1 record
+			reader = cmd2.ExecuteReader();
+			Console.WriteLine("   RowsAffected before read: " + reader.RecordsAffected.ToString());
+			reader.Read();
+			Console.WriteLine("   RowsAffected after read: " + reader.RecordsAffected.ToString());
+			reader.Close();
+
+			// insert another record
+			Console.WriteLine("   Insert another record...");
+			myParameter2.Value = 183;
+			myParameter1.Value = "Oracle";
+			reader = cmd2.ExecuteReader();
+			Console.WriteLine("   RowsAffected before read: " + reader.RecordsAffected.ToString());
+			reader.Read();
+			Console.WriteLine("   RowsAffected after read: " + reader.RecordsAffected.ToString());
+			reader.Close();
+
+			trans.Commit();
+			trans = null;
+			
+			ReadSimpleTest(con, "SELECT * FROM MONO_ADAPTER_TEST");
+		}
+
+		static void CommitCursor (OracleConnection con) 
+		{
+			OracleCommand cmd = con.CreateCommand ();
+			cmd.CommandText = "COMMIT";
+			cmd.ExecuteNonQuery ();
+			cmd.Dispose ();
+			cmd = null;
+		}
+
 		static void RollbackTest (OracleConnection connection)
 		{
 			OracleTransaction transaction = connection.BeginTransaction ();
@@ -468,7 +881,106 @@ namespace Test.OracleClient
 			transaction.Commit ();
 		}
 
-		public static void ParameterTest (OracleConnection connection)
+		public static void ParameterTest2 (OracleConnection connection)
+		{
+			Console.WriteLine("  Setting NLS_DATE_FORMAT...");
+
+			OracleCommand cmd2 = connection.CreateCommand();
+			cmd2.CommandText = "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'";
+		
+			cmd2.ExecuteNonQuery ();
+
+			Console.WriteLine("  Drop table MONO_TEST_TABLE2...");
+			try {
+				cmd2.CommandText = "DROP TABLE MONO_TEST_TABLE7";
+				cmd2.ExecuteNonQuery ();
+			}
+			catch(OracleException oe1) {
+				// ignore if table already exists
+			}
+
+			Console.WriteLine("  Create table MONO_TEST_TABLE7...");
+
+			cmd2.CommandText = "CREATE TABLE MONO_TEST_TABLE7(" +
+				" COL1 VARCHAR2(8) NOT NULL, " +
+				" COL2 VARCHAR2(32), " +
+				" COL3 NUMBER(18,2), " +
+				" COL4 NUMBER(18,2), " +
+				" COL5 DATE NOT NULL, " +
+				" COL6 DATE, " +
+				" COL7 BLOB NOT NULL, " +
+				" COL8 BLOB, " +
+				" COL9 CLOB NOT NULL, " +
+				" COL10 CLOB " +
+				")";
+			cmd2.ExecuteNonQuery ();
+
+			Console.WriteLine("  COMMIT...");
+			cmd2.CommandText = "COMMIT";
+			cmd2.ExecuteNonQuery ();
+
+			Console.WriteLine("  create insert command...");
+
+			OracleTransaction trans = connection.BeginTransaction ();
+			OracleCommand cmd = connection.CreateCommand ();
+			cmd.Transaction = trans;
+
+			cmd.CommandText = "INSERT INTO MONO_TEST_TABLE7 " + 
+				"(COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8,COL9,COL10) " + 
+				"VALUES(:P1,:P2,:P3,:P4,:P5,:P6,:P7,:P8,:P9,:P10)";
+		
+			Console.WriteLine("  Add parameters...");
+
+			OracleParameter parm1 = cmd.Parameters.Add (":P1", OracleType.VarChar, 8);
+			OracleParameter parm2 = cmd.Parameters.Add (":P2", OracleType.VarChar, 32);
+		
+			OracleParameter parm3 = cmd.Parameters.Add (":P3", OracleType.Number);
+			OracleParameter parm4 = cmd.Parameters.Add (":P4", OracleType.Number);
+		
+			OracleParameter parm5 = cmd.Parameters.Add (":P5", OracleType.DateTime);
+			OracleParameter parm6 = cmd.Parameters.Add (":P6", OracleType.DateTime);
+
+			// FIXME: fix BLOBs and CLOBs in OracleParameter
+
+			OracleParameter parm7 = cmd.Parameters.Add (":P7", OracleType.Blob);
+			OracleParameter parm8 = cmd.Parameters.Add (":P8", OracleType.Blob);
+
+			OracleParameter parm9 = cmd.Parameters.Add (":P9", OracleType.Clob);
+			OracleParameter parm10 = cmd.Parameters.Add (":P10", OracleType.Clob);
+
+			// TODO: implement out, return, and ref parameters
+
+			string s = "Mono";
+			decimal d = 123456789012345.678M;
+			DateTime dt = DateTime.Now;
+
+			string clob = "Clob";
+			byte[] blob = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 };
+		
+			Console.WriteLine("  Set Values...");
+
+			parm1.Value = s;
+			parm2.Value = DBNull.Value;
+		
+			parm3.Value = d;
+			parm4.Value = DBNull.Value;
+		
+			parm5.Value = dt;
+			parm6.Value = DBNull.Value;
+		
+			parm7.Value = blob;
+			parm8.Value = DBNull.Value;
+
+			parm9.Value = clob;
+			parm10.Value = DBNull.Value;
+		
+			Console.WriteLine("  ExecuteNonQuery...");
+
+			cmd.ExecuteNonQuery ();
+			trans.Commit();
+		}
+
+		public static void ParameterTest (OracleConnection connection) 
 		{
 			Console.WriteLine("  Setting NLS_DATE_FORMAT...");
 
@@ -1252,6 +1764,12 @@ namespace Test.OracleClient
 
 			Wait ("");
 
+			Console.WriteLine ("DataAdapter Test 2 BEGIN...");
+			DataAdapterTest2(con1);
+			Console.WriteLine ("DataAdapter Test 2 END.");
+
+			Wait ("");
+
 			Console.WriteLine ("Rollback Test BEGIN...");
                         RollbackTest(con1);
 			Console.WriteLine ("Rollback Test END.");
@@ -1297,6 +1815,12 @@ namespace Test.OracleClient
 
 			Wait ("");
 
+			Console.WriteLine ("Test a Non Query using Execute Reader BEGIN...");
+			TestNonQueryUsingExecuteReader (con1);
+			Console.WriteLine ("Test a Non Query using Execute Reader END...");
+
+			Wait ("");
+
 			Console.WriteLine ("Null Aggregate Warning BEGIN test...");
 			NullAggregateTest (con1);
 			Console.WriteLine ("Null Aggregate Warning END test...");