Explorar el Código

2008-09-06 Daniel Morgan <[email protected]>

	* Test/TestOracleClient.cs: get oracle connected tests
	going again
	
	*  System.Data.OracleClient.Oci/OciDefineHandle.cs
	* System.Data.OracleClient/OracleDataReader.cs
	* System.Data.OracleClient/OracleCommand.cs: fix character
	field value for a reader that was retrieved from a REF CURSOR.
	It was failing due to OCI_INVALID_HANDLE - resolve the error
	by passing a connection object which has a valid environment
	handle.

	* System.Data.OracleClient.Oci/OciCalls.cs: correct 
	call to OCIDefineByPos

	* System.Data.OracleClient/OracleParameter.cs: better way to
	determine if the input value Is Null instead of using reflection.
	Flush - Re-arraning how variables are being bound.

	* System.Data.OracleClient/OciGlue.cs: add function
	to convert OCI Return / Error Status Code to a String Description
 
	* System.Data.OracleClient.Oci/OciErrorHandle.cs: better
	error handling

svn path=/trunk/mcs/; revision=112419
Daniel Morgan hace 17 años
padre
commit
61c5bd311b

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

@@ -1,3 +1,29 @@
+2008-09-06  Daniel Morgan <[email protected]>
+
+	* Test/TestOracleClient.cs: get oracle connected tests
+	going again
+	
+	*  System.Data.OracleClient.Oci/OciDefineHandle.cs
+	* System.Data.OracleClient/OracleDataReader.cs
+	* System.Data.OracleClient/OracleCommand.cs: fix character
+	field value for a reader that was retrieved from a REF CURSOR.
+	It was failing due to OCI_INVALID_HANDLE - resolve the error
+	by passing a connection object which has a valid environment
+	handle.
+
+	* System.Data.OracleClient.Oci/OciCalls.cs: correct 
+	call to OCIDefineByPos
+
+	* System.Data.OracleClient/OracleParameter.cs: better way to
+	determine if the input value Is Null instead of using reflection.
+	Flush - Re-arraning how variables are being bound.
+
+	* System.Data.OracleClient/OciGlue.cs: add function
+	to convert OCI Return / Error Status Code to a String Description
+ 
+	* System.Data.OracleClient.Oci/OciErrorHandle.cs: better
+	error handling
+
 2008-09-04  Daniel Morgan <[email protected]>
 
 	* System.Data.OracleClient/OracleDataReader.cs: return true

+ 3 - 3
mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciCalls.cs

@@ -172,7 +172,7 @@ namespace System.Data.OracleClient.Oci
 
 			[DllImport ("oci")]
 			internal static extern int OCIDefineByPos (IntPtr stmtp,
-				ref IntPtr defnpp,
+				out IntPtr defnpp,
 				IntPtr errhp,
 				[MarshalAs (UnmanagedType.U4)] int position,
 				IntPtr valuep,
@@ -660,7 +660,7 @@ namespace System.Data.OracleClient.Oci
 			out uint fsec);
 
 		internal static int OCIDefineByPos (IntPtr stmtp,
-			ref IntPtr defnpp,
+			out IntPtr defnpp,
 			IntPtr errhp,
 			int position,
 			IntPtr valuep,
@@ -674,7 +674,7 @@ namespace System.Data.OracleClient.Oci
 			#if TRACE
 			Trace.WriteLineIf(traceOci, "OCIDefineByPos", "OCI");
 			#endif
-			return OciNativeCalls.OCIDefineByPos (stmtp, ref defnpp, errhp, position, valuep,
+			return OciNativeCalls.OCIDefineByPos (stmtp, out defnpp, errhp, position, valuep,
 				value_sz, dty, ref indp, ref rlenp, rcodep, mode);
 		}
 

+ 38 - 39
mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciDefineHandle.cs

@@ -54,7 +54,6 @@ namespace System.Data.OracleClient.Oci
 
 		OciLobLocator lobLocator;
 		OciDateTimeDescriptor dateTimeDesc;
-		//byte[] date;
 
 		#endregion // Fields
 
@@ -77,7 +76,7 @@ namespace System.Data.OracleClient.Oci
 
 			Define (position, connection);
 
-			//parameter.Dispose ();
+			parameter.Dispose ();
 		}
 
 		#endregion // Constructors
@@ -125,46 +124,46 @@ namespace System.Data.OracleClient.Oci
 		{
 			switch (definedType) {
 			case OciDataType.Date:
-				DefineDate (position);
+				DefineDate (position, connection);
 				return;
 			case OciDataType.TimeStamp:
-				DefineTimeStamp (position);
+				DefineTimeStamp (position, connection);
 				return;
 			case OciDataType.Clob:
 			case OciDataType.Blob:
 				DefineLob (position, definedType, connection);
 				return;
 			case OciDataType.Raw:
-				DefineRaw( position);
+				DefineRaw( position, connection);
 				return;
 			case OciDataType.RowIdDescriptor:
 				definedSize = 10;
-				DefineChar (position);
+				DefineChar (position, connection);
 				return;
 			case OciDataType.Integer:
 			case OciDataType.Number:
 			case OciDataType.Float:
-				DefineNumber (position);
+				DefineNumber (position, connection);
 				return;
 			case OciDataType.Long:
 			case OciDataType.LongVarChar:
-				DefineLong (position);
+				DefineLong (position, connection);
 				return;
 			default:
-				DefineChar (position); // HANDLE ALL OTHERS AS CHAR FOR NOW
+				DefineChar (position, connection); // HANDLE ALL OTHERS AS CHAR FOR NOW
 				return;
 			}
 		}
 
-		void DefineTimeStamp (int position)
+		void DefineTimeStamp (int position, OracleConnection connection)
 		{
 			definedSize = -1;
 			ociType = OciDataType.TimeStamp;
 			fieldType = typeof(System.DateTime);
 
-			dateTimeDesc = (OciDateTimeDescriptor) Parent.Parent.Allocate (OciHandleType.TimeStamp);
+			dateTimeDesc = (OciDateTimeDescriptor) connection.Environment.Allocate (OciHandleType.TimeStamp);
 			if (dateTimeDesc == null) {
-				OciErrorInfo info = ErrorHandle.HandleError ();
+				OciErrorInfo info = connection.ErrorHandle.HandleError ();
 				throw new OracleException (info.ErrorCode, info.ErrorMessage);
 			}
 
@@ -188,12 +187,12 @@ namespace System.Data.OracleClient.Oci
 			definedSize = 11;
 
 			if (status != 0) {
-				OciErrorInfo info = ErrorHandle.HandleError ();
+				OciErrorInfo info = connection.ErrorHandle.HandleError ();
 				throw new OracleException (info.ErrorCode, info.ErrorMessage);
 			}
 		}
 
-		void DefineDate (int position)
+		void DefineDate (int position, OracleConnection connection)
 		{
 			definedSize = 7;
 			ociType = OciDataType.Date;
@@ -204,7 +203,7 @@ namespace System.Data.OracleClient.Oci
 			int status = 0;
 
 			status = OciCalls.OCIDefineByPos (Parent,
-						ref handle,
+						out handle,
 						ErrorHandle,
 						position + 1,
 						value,
@@ -221,7 +220,7 @@ namespace System.Data.OracleClient.Oci
 			}
 		}
 
-		void DefineLong (int position)
+		void DefineLong (int position, OracleConnection connection)
 		{
 			fieldType = typeof (System.String);
 
@@ -241,7 +240,7 @@ namespace System.Data.OracleClient.Oci
 
 			int status = 0;
 			status = OciCalls.OCIDefineByPos (Parent,
-				ref handle,
+				out handle,
 				ErrorHandle,
 				position + 1,
 				value,
@@ -259,7 +258,7 @@ namespace System.Data.OracleClient.Oci
 			}
 		}
 
-		void DefineChar (int position)
+		void DefineChar (int position, OracleConnection connection)
 		{
 			fieldType = typeof (System.String);
 
@@ -271,7 +270,7 @@ namespace System.Data.OracleClient.Oci
 			int status = 0;
 
 			status = OciCalls.OCIDefineByPos (Parent,
-						ref handle,
+						out handle,
 						ErrorHandle,
 						position + 1,
 						value,
@@ -281,14 +280,10 @@ namespace System.Data.OracleClient.Oci
 						ref rlenp,
 						IntPtr.Zero,
 						0);
-
-			if (status != 0) {
-				OciErrorInfo info = ErrorHandle.HandleError ();
-				throw new OracleException (info.ErrorCode, info.ErrorMessage);
-			}
+			OciErrorHandle.ThrowExceptionIfError (ErrorHandle, status);
 		}
 
-		void DefineNumber (int position)
+		void DefineNumber (int position, OracleConnection connection)
 		{
 			fieldType = typeof (System.Decimal);
 			value = OciCalls.AllocateClear (definedSize);
@@ -298,7 +293,7 @@ namespace System.Data.OracleClient.Oci
 			int status = 0;
 
 			status = OciCalls.OCIDefineByPos (Parent,
-				ref handle,
+				out handle,
 				ErrorHandle,
 				position + 1,
 				value,
@@ -328,17 +323,16 @@ namespace System.Data.OracleClient.Oci
 
 			definedSize = -1;
 
-			lobLocator = (OciLobLocator) Parent.Parent.Allocate (OciHandleType.LobLocator);
+			lobLocator = (OciLobLocator) connection.Environment.Allocate (OciHandleType.LobLocator);
 
 			if (lobLocator == null) {
-				OciErrorInfo info = ErrorHandle.HandleError ();
+				OciErrorInfo info = connection.ErrorHandle.HandleError ();
 				throw new OracleException (info.ErrorCode, info.ErrorMessage);
 			}
 
 			value = lobLocator.Handle;
-			lobLocator.ErrorHandle = ErrorHandle;
+			lobLocator.ErrorHandle = connection.ErrorHandle;
 			lobLocator.Service = connection.ServiceContext;
-			//lobLocator.Service = ((OciStatementHandle) Parent).Service;
 
 			status = OciCalls.OCIDefineByPosPtr (Parent,
 							out handle,
@@ -355,12 +349,12 @@ namespace System.Data.OracleClient.Oci
 			definedSize = Int32.MaxValue;
 
 			if (status != 0) {
-				OciErrorInfo info = ErrorHandle.HandleError ();
+				OciErrorInfo info = connection.ErrorHandle.HandleError ();
 				throw new OracleException (info.ErrorCode, info.ErrorMessage);
 			}
 		}
 
-		void DefineRaw (int position)
+		void DefineRaw (int position, OracleConnection connection)
 		{
 			ociType = OciDataType.Raw;
 			fieldType = typeof (byte[]);
@@ -370,7 +364,7 @@ namespace System.Data.OracleClient.Oci
 			int status = 0;
 
 			status = OciCalls.OCIDefineByPos (Parent,
-							ref handle,
+							out handle,
 							ErrorHandle,
 							position + 1,
 							value,
@@ -412,7 +406,7 @@ namespace System.Data.OracleClient.Oci
 			return new OracleLob (lobLocator, ociType);
 		}
 
-                public object GetValue (IFormatProvider formatProvider)
+                public object GetValue (IFormatProvider formatProvider, OracleConnection conn)
 		{
 			object tmp;
 
@@ -431,12 +425,15 @@ namespace System.Data.OracleClient.Oci
 
 				// Get length of returned string
 				int 	rsize = 0;
-				IntPtr	env = Parent.Parent;	// Parent is statement, grandparent is environment
-				OciCalls.OCICharSetToUnicode (env, null, buffer, out rsize);
+				//IntPtr	env = Parent.Parent;	// Parent is statement, grandparent is environment
+				IntPtr env = conn.Environment;
+				int status = OciCalls.OCICharSetToUnicode (env, null, buffer, out rsize);
+				OciErrorHandle.ThrowExceptionIfError (ErrorHandle, status);
 
 				// Get string
 				StringBuilder ret = new StringBuilder(rsize);
-				OciCalls.OCICharSetToUnicode (env, ret, buffer, out rsize);
+				status = OciCalls.OCICharSetToUnicode (env, ret, buffer, out rsize);
+				OciErrorHandle.ThrowExceptionIfError (ErrorHandle, status);
 
 				return ret.ToString ();
 			case OciDataType.LongVarChar:
@@ -471,14 +468,16 @@ namespace System.Data.OracleClient.Oci
 			case OciDataType.Blob:
 			case OciDataType.Clob:
 				return GetOracleLob ();
+			default:
+				throw new Exception("OciDataType not implemented: " + DataType.ToString ());
 			}
 
 			return DBNull.Value;
 		}
 
-                internal object GetOracleValue (IFormatProvider formatProvider)
+                internal object GetOracleValue (IFormatProvider formatProvider, OracleConnection conn)
 		{
-                        object ovalue = GetValue (formatProvider);
+                        object ovalue = GetValue (formatProvider, conn);
 
 			switch (DataType) {
 			case OciDataType.Raw:

+ 45 - 38
mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci/OciErrorHandle.cs

@@ -47,47 +47,54 @@ namespace System.Data.OracleClient.Oci {
 			}
 		}
 
+		public static void ThrowExceptionIfError (OciHandle hwnd, int status)
+		{
+			if (status == 0)
+				return;
+			OciErrorInfo info = HandleError (hwnd, status);
+			throw new OracleException (info.ErrorCode, info.ErrorMessage);
+		}
+
 		public static OciErrorInfo HandleError (OciHandle hwnd, int status) 
 		{		
 			OciErrorInfo info;
-			info.ErrorCode = 0;
-			info.ErrorMessage = String.Empty;
-
-			int errbufSize = 4096;
-			IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
-
-			OciCalls.OCIErrorGet (hwnd,
-				1,
-				IntPtr.Zero,
-				out info.ErrorCode,
-				errbuf,
-				(uint) errbufSize,
-				OciHandleType.Error);
-
-			byte[] bytea = new byte[errbufSize];
-			Marshal.Copy (errbuf, bytea, 0, errbufSize);
-			errbufSize = 0;
-
-			OciHandle h = hwnd;
-			if (h == null)
-				throw new Exception ("Internal driver error: handle is null.");
-
-			// first call to OCICharSetToUnicode gets the size
-			OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
-			StringBuilder str = new StringBuilder (errbufSize);
-
-			// second call to OCICharSetToUnicode gets the string
-			OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
-
-			string errmsg = String.Empty;
-			if (errbufSize > 0)
-				errmsg = str.ToString ();
-			else
-				errmsg = "Internal driver error. Could not retrieve error message.  Status: " + status.ToString();
-
-			info.ErrorMessage = String.Copy (errmsg);
-			Marshal.FreeHGlobal (errbuf);
-
+			info.ErrorCode = status;
+			info.ErrorMessage = OciGlue.ReturnCodeToString (status);
+
+			if (status == OciGlue.OCI_ERROR || status == OciGlue.OCI_SUCCESS_WITH_INFO) {
+				OciHandle h = hwnd;
+				if (h == null)
+					throw new Exception ("Internal driver error: handle is null.");
+	
+				int errbufSize = 4096;
+				IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
+
+				OciCalls.OCIErrorGet (hwnd,
+					1,
+					IntPtr.Zero,
+					out info.ErrorCode,
+					errbuf,
+					(uint) errbufSize,
+					OciHandleType.Error);
+
+				byte[] bytea = new byte[errbufSize];
+				Marshal.Copy (errbuf, bytea, 0, errbufSize);
+				errbufSize = 0;
+
+				// first call to OCICharSetToUnicode gets the size
+				OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
+				StringBuilder str = new StringBuilder (errbufSize);
+
+				// second call to OCICharSetToUnicode gets the string
+				OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
+
+				string errmsg = String.Empty;
+				if (errbufSize > 0) {
+					errmsg = str.ToString ();
+					info.ErrorMessage = String.Copy (errmsg);
+				}
+				Marshal.FreeHGlobal (errbuf);
+			}
 			return info;
 		}
 

+ 29 - 3
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OciGlue.cs

@@ -37,13 +37,13 @@ namespace System.Data.OracleClient.Oci {
 		OciServiceHandle service;
 		OciSessionHandle session;
 
-		// other codes
+		// OCI Return Codes
 		public const int OCI_DEFAULT = 0;
 		public const int OCI_SUCCESS = 0;
-		public const int OCI_SUCCESS_WITH_INFO = 1;
+		public const int OCI_SUCCESS_WITH_INFO = 1; // Diagnostic or Warning message - call OCIErrorGet 
 		public const int OCI_RESERVED_FOR_INT_USE = 200;
 		public const int OCI_NO_DATA = 100;
-		public const int OCI_ERROR = -1;
+		public const int OCI_ERROR = -1; // use error handle to get error code and description - call OCIErrorGet
 		public const int OCI_INVALID_HANDLE = -2;
 		public const int OCI_NEED_DATA = 99;
 		public const int OCI_STILL_EXECUTING = -3123;
@@ -199,6 +199,32 @@ namespace System.Data.OracleClient.Oci {
 			}
 		}
 
+		public static string ReturnCodeToString (int status) 
+		{
+			switch (status) {
+			case OCI_DEFAULT:
+				return "OCI_DEFAULT or OCI_SUCCESS"; // both are zero
+			case OCI_SUCCESS_WITH_INFO:
+				return "OCI_SUCCESS_WITH_INFO"; 
+			case OCI_RESERVED_FOR_INT_USE:
+				return "OCI_RESERVED_FOR_INT_USE";
+			case OCI_NO_DATA:
+				return "OCI_NO_DATA";
+			case OCI_ERROR:
+				return "OCI_ERROR";
+			case OCI_INVALID_HANDLE:
+				return "OCI_INVALID_HANDLE";
+			case OCI_NEED_DATA:
+				return "OCI_NEED_DATA";
+			case OCI_STILL_EXECUTING:
+				return "OCI_STILL_EXECUTING";
+			case OCI_CONTINUE:
+				return "OCI_CONTINUE";
+			}
+			return "Unknown Error";
+		}
+
 		#endregion // Methods
 	}
 }
+

+ 3 - 3
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleCommand.cs

@@ -496,7 +496,7 @@ namespace System.Data.OracleClient
 					if (statement.Fetch ()) {
 						OciDefineHandle defineHandle = (OciDefineHandle) statement.Values [0];
 						if (!defineHandle.IsNull)
-							output = defineHandle.GetOracleValue (Connection.SessionFormatProvider);
+							output = defineHandle.GetOracleValue (Connection.SessionFormatProvider, Connection);
 						switch (defineHandle.DataType) {
 						case OciDataType.Blob:
 						case OciDataType.Clob:
@@ -637,14 +637,14 @@ namespace System.Data.OracleClient
 							case OciDataType.Blob:
 							case OciDataType.Clob:
 								OracleLob lob = (OracleLob) defineHandle.GetValue (
-									Connection.SessionFormatProvider);
+									Connection.SessionFormatProvider, Connection);
 								lob.connection = Connection;
 								output = lob.Value;
 								lob.Close ();
 								break;
 							default:
 								output = defineHandle.GetValue (
-									Connection.SessionFormatProvider);
+									Connection.SessionFormatProvider, Connection);
 								break;
 							}
 						}

+ 2 - 2
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleDataReader.cs

@@ -401,7 +401,7 @@ namespace System.Data.OracleClient
 				throw new InvalidOperationException("The value is null");
 
 			OracleLob output = (OracleLob) ((OciDefineHandle) statement.Values [i]).GetValue (
-				command.Connection.SessionFormatProvider);
+				command.Connection.SessionFormatProvider, command.Connection);
 			output.connection = command.Connection;
 			return output;
 		}
@@ -794,7 +794,7 @@ namespace System.Data.OracleClient
 				lob.Close ();
 				return value;
 			default:
-				return defineHandle.GetValue (command.Connection.SessionFormatProvider);
+				return defineHandle.GetValue (command.Connection.SessionFormatProvider, command.Connection);
 			}
 		}
 

+ 84 - 15
mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs

@@ -389,24 +389,92 @@ namespace System.Data.OracleClient
 
 			bool isnull = false;
 			if (direction == ParameterDirection.Input || direction == ParameterDirection.InputOutput) {
-				try {
-					Type nullable = v.GetType ().GetInterface ("System.Data.SqlTypes.INullable", false);
-					if (nullable != null) {
-						INullable mynullable = (INullable)v;
+				if (v == null || v == DBNull.Value)
+					isnull = true;
+				else {
+					INullable mynullable = v as INullable;
+					if (mynullable != null)
 						isnull = mynullable.IsNull;
-					}
-				}
-				catch(Exception e) {
-					System.IO.TextWriter.Null.WriteLine(e.Message);
-				}
-			}		
+				}					
+			} 
 
-			// TODO: handle InputOutput and Return parameters
-			if (direction == ParameterDirection.Output) {
-				// TODO: need to figure out how OracleParameter
-				//       which uses OciBindHandle to share code
-				//       with OciDefineHandle
+			if (isnull == true && direction == ParameterDirection.Input) {
+				indicator = 0;
+				bindType = OciDataType.VarChar2;
+				bindSize = 0;
+			} else {
+/*
 				switch(ociType) {
+				case OciDataType.VarChar2:
+				case OciDataType.String:
+				case OciDataType.VarChar:
+				case OciDataType.Char:
+				case OciDataType.CharZ:
+				case OciDataType.OciString:
+					//BindString();
+					bindType = OciDataType.Char;
+					if (direction == ParameterDirection.Input || 
+						direction == ParameterDirection.InputOutput) {
+						
+						// coerce (convert) value from type to type
+						string svalue = v.ToString () + '\0';
+						// set bind length to actual length of data value
+					} else {
+						// set bind length to defined length of data value
+					}
+					// allocate unmanaged memory based on bind length
+					if (direction == ParameterDirection.Input ||
+						direction == ParameterDirection.InputOutput) {
+						
+						// convert managed type to unmanaged data allocated earlier
+					}
+					// do actual bind via OCI Bind call
+					break;
+				case OciDataType.RowIdDescriptor:
+					//BindRowIdDescriptor (); // bind via BindString() with defined size of 10 or 18?
+					// set bind type to OciDataType
+					if (direction == ParameterDirection.Input || 
+						direction == ParameterDirection.InputOutput) {
+						
+						// coerce (convert) value from type to type
+						//string svalue = v.ToString () + '\0';
+						// set bind length to actual length of data value
+					} else {
+						// set bind length to defined length of data value
+					}
+					// allocate unmanaged memory based on bind length
+					if (direction == ParameterDirection.Input ||
+						direction == ParameterDirection.InputOutput) {
+						
+						// convert managed type to unmanaged data allocated earlier
+					}
+					// do actual bind via OCI Bind call
+					
+					break;
+				case OciDataType.Date:
+					BindDate ();
+					break;
+				case OciDataType.TimeStamp:
+					BindTimestamp ();
+					break;
+				case OciDataType.Number:
+					BindNumber ();
+					break;
+				case OciDataType.Long:
+				case OciDataType.LongVarChar:
+					BindLongVarChar ();
+					break;
+				case OciDataType.Blob:
+				case OciDataType.Clob:
+					BindLob ();
+					break;
+				case OciDataType.RSet: // REF CURSOR
+					BindRefCursor ();
+					break;
+				}
+*/
+		if (direction == ParameterDirection.Output || direction == ParameterDirection.InputOutput || direction == ParameterDirection.ReturnValue) {
+					switch(ociType) {
 					case OciDataType.VarChar2:
 					case OciDataType.String:
 					case OciDataType.VarChar:
@@ -633,6 +701,7 @@ namespace System.Data.OracleClient
 					bindSize = svalue.Length;
 				}
 			}
+}
 
 			// Now, call the appropriate OCI Bind function;
 

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

@@ -1255,6 +1255,8 @@ namespace Test.OracleClient
 			StringBuilder sb2 = new StringBuilder();
 			for (int z = 0; z < bytes.Length; z++) {
 				byte byt = bytes[z];
+				if (byt < 0x10)
+					sb2.Append ("0");
 				sb2.Append (byt.ToString("x"));
 			}
 			if (sb2.Length > 0)
@@ -1545,7 +1547,7 @@ namespace Test.OracleClient
 			cmd3.ExecuteNonQuery ();
 			DateTime outValue = (DateTime) myParameter2.Value;
 			Console.WriteLine ("    Out Value should be: 2004-12-18");
-			Console.WriteLine ("    Out Value: {0}", outValue.ToString ("yyyy-mm-dd"));
+			Console.WriteLine ("    Out Value: {0}", outValue.ToString ("yyyy-MM-dd"));
 		}
 
 		static void ShowConnectionProperties (OracleConnection con) 
@@ -1642,13 +1644,16 @@ namespace Test.OracleClient
 			Console.WriteLine("Setup Oracle package curspkg_join...");
 		
 			OracleCommand cmd = con.CreateCommand();
-
+
+			Console.Error.WriteLine("    create or replace package curspkg_join...");
 			cmd.CommandText = 
 				"CREATE OR REPLACE PACKAGE curspkg_join AS\n" +
 				"TYPE t_cursor IS REF CURSOR;\n" +
 				"Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor);\n" +
 				"END curspkg_join;";
-			cmd.ExecuteNonQuery();
+			cmd.ExecuteNonQuery();
+
+			Console.Error.WriteLine("    create or replace package body curspkg_join...");			
 			cmd.CommandText = 
 				"CREATE OR REPLACE PACKAGE BODY curspkg_join AS\n" +
 				"   Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor)\n" +
@@ -1658,26 +1663,29 @@ namespace Test.OracleClient
 				"        IF n_EMPNO <> 0 THEN\n" +
 				"             OPEN v_cursor FOR\n" +
 				"             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME\n" +
-				"                  FROM EMP, DEPT\n" +
+				"                  FROM SCOTT.EMP, SCOTT.DEPT\n" +
 				"                  WHERE EMP.DEPTNO = DEPT.DEPTNO\n" +
 				"                  AND EMP.EMPNO = n_EMPNO;\n" +
 				"\n" +
 				"        ELSE\n" +
 				"             OPEN v_cursor FOR\n" +
 				"             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME\n" +
-				"                  FROM EMP, DEPT\n" +
+				"                  FROM SCOTT.EMP, SCOTT.DEPT\n" +
 				"                  WHERE EMP.DEPTNO = DEPT.DEPTNO;\n" +
 				"\n" +
 				"        END IF;\n" +
 				"        io_cursor := v_cursor;\n" +
 				"   END open_join_cursor1;\n" +
 				"END curspkg_join;";
+			cmd.ExecuteNonQuery();
+
+			cmd.CommandText = "commit";
 			cmd.ExecuteNonQuery();
 		}
 
 		public static void RefCursorTest4(OracleConnection connection) 
 		{
-			Console.WriteLine("Setup test package and data...");
+			Console.WriteLine("Setup test package and data for RefCursorTest4...");
 			OracleCommand cmddrop = connection.CreateCommand();
 
 			cmddrop.CommandText = "DROP TABLE TESTTABLE";
@@ -1696,7 +1704,7 @@ namespace Test.OracleClient
 			cmd.CommandText = 
 				"create table TESTTABLE (\n" +
 				" col1 numeric(18,0),\n" +
-				" col2 varchar(32),\n" +
+				" col2 char(32),\n" +
 				" col3 date)";
 			cmd.ExecuteNonQuery();
 
@@ -1767,7 +1775,7 @@ namespace Test.OracleClient
 				Console.WriteLine("Row {0}", r);
 				for (int f = 0; f < reader.FieldCount; f ++) {
 					object val = reader.GetValue(f);
-					Console.WriteLine("    Field {0} Value: {1}", f, val);
+					Console.WriteLine("    Field {0} Value: {1}", f, val.ToString());
 				}
 				r ++;
 			}