IBM.Data.DB2.DB2Parameter.GetOutValue C# (CSharp) Method

GetOutValue() private method

private GetOutValue ( ) : void
return void
		internal void GetOutValue()
		{
			int length = Marshal.ReadInt32(internalLengthBuffer);
			if(length == DB2Constants.SQL_NULL_DATA)
			{
				dataVal = DBNull.Value;
				return;
			}
			switch(DB2Type) 
			{
				case DB2Type.SmallInt:
					dataVal = Marshal.ReadInt16(internalBuffer);
					break;
				case DB2Type.Integer:
					dataVal = Marshal.ReadInt32(internalBuffer);
					break;
				case DB2Type.BigInt:
					dataVal = Marshal.ReadInt64(internalBuffer);
					break;
				case DB2Type.Double:
					dataVal = Marshal.PtrToStructure(internalBuffer, typeof(Double));
					break;
				case DB2Type.Float:
					dataVal = Marshal.PtrToStructure(internalBuffer, typeof(Single));
					break;
				case DB2Type.Char:
				case DB2Type.VarChar:
				case DB2Type.LongVarChar:
				case DB2Type.Graphic:
				case DB2Type.VarGraphic:
				case DB2Type.LongVarGraphic:
				case DB2Type.Clob:
				case DB2Type.DbClob:
					dataVal = Marshal.PtrToStringUni(internalBuffer, Math.Min(Size, length / 2));
					break;
				case DB2Type.Binary:
				case DB2Type.VarBinary:
				case DB2Type.LongVarBinary:
				case DB2Type.Blob:
				case DB2Type.Datalink:
					length = Math.Min(Size, length);
					dataVal = new byte[length];
					Marshal.Copy(internalBuffer, (byte[])dataVal, 0, length);
					break;
				case DB2Type.Decimal:
					dataVal = decimal.Parse(Marshal.PtrToStringAnsi(internalBuffer, length), 
						System.Globalization.CultureInfo.InvariantCulture);
					break;
				case DB2Type.Timestamp:
					DateTime dtTmp = new DateTime(
						Marshal.ReadInt16(internalBuffer, 0),  // year
						Marshal.ReadInt16(internalBuffer, 2),  // month
						Marshal.ReadInt16(internalBuffer, 4),  // day
						Marshal.ReadInt16(internalBuffer, 6),  // hour
						Marshal.ReadInt16(internalBuffer, 8),  // minute
						Marshal.ReadInt16(internalBuffer, 10));// second
					dataVal = dtTmp.AddTicks(Marshal.ReadInt32(internalBuffer, 12) / 100); // nanoseconds 
					break;
				case DB2Type.Date:
					dataVal = new DateTime(
						Marshal.ReadInt16(internalBuffer, 0),
						Marshal.ReadInt16(internalBuffer, 2),
						Marshal.ReadInt16(internalBuffer, 4));
					break;
				case DB2Type.Time:
					dataVal = new TimeSpan(
						Marshal.ReadInt16(internalBuffer, 0),  // Hour
						Marshal.ReadInt16(internalBuffer, 2),  // Minute
						Marshal.ReadInt16(internalBuffer, 4)); // Second
					break;

				case DB2Type.Invalid:
				case DB2Type.Real:
				case DB2Type.Numeric:
				case DB2Type.RowId:
				case DB2Type.XmlReader:
					throw new NotImplementedException();
				default:
					throw new NotSupportedException("unknown data type");
			}
		}
	}