public object[] GetInsertData(Session session, SqlType[] colTypes, Expression[] rowArgs) { object[] newRowData = base.BaseTable.GetNewRowData(session); session.sessionData.StartRowProcessing(); for (int i = 0; i < rowArgs.Length; i++) { Expression expression = rowArgs[i]; int index = base.InsertColumnMap[i]; if (expression.OpType == 4) { if ((base.BaseTable.IdentityColumn != index) && (base.BaseTable.ColDefaults[index] != null)) { newRowData[index] = base.BaseTable.ColDefaults[index].GetValue(session); } } else { object a = expression.GetValue(session); SqlType type = colTypes[index]; if (colTypes[index] != expression.DataType) { a = type.ConvertToType(session, a, expression.DataType); } newRowData[index] = a; } } return(newRowData); }
public override object GetValue(Session session, SqlType type) { if ((base.DataType == type) || (base.ValueData == null)) { return(base.ValueData); } return(type.ConvertToType(session, base.ValueData, base.DataType)); }
private void GetFirstRow() { if ((this.CurrentJoinData == null) || (this.CurrentJoinData.Length < this.Conditions[this.CondIndex].IndexedColumnCount)) { this.CurrentJoinData = new object[this.Conditions[this.CondIndex].IndexedColumnCount]; } for (int i = 0; i < this.Conditions[this.CondIndex].IndexedColumnCount; i++) { int num2 = 0; switch (((i == (this.Conditions[this.CondIndex].IndexedColumnCount - 1)) ? this.Conditions[this.CondIndex].OpType : this.Conditions[this.CondIndex].IndexCond[i].GetExprType())) { case 0x2f: case 0x30: case 0x4a: this.CurrentJoinData[i] = null; break; default: { SqlType dataType = this.Conditions[this.CondIndex].IndexCond[i].GetRightNode().GetDataType(); object a = this.Conditions[this.CondIndex].IndexCond[i].GetRightNode().GetValue(base.session); SqlType type2 = this.Conditions[this.CondIndex].IndexCond[i].GetLeftNode().GetDataType(); if (((type2 != dataType) && (num2 == 0)) && (type2.TypeComparisonGroup != dataType.TypeComparisonGroup)) { a = type2.ConvertToType(base.session, a, dataType); } if (i == 0) { int exprType = this.Conditions[this.CondIndex].IndexCond[0].GetExprType(); if (num2 < 0) { if ((exprType - 0x2a) > 1) { base.It = this.Conditions[this.CondIndex].RangeIndex.GetEmptyIterator(); return; } a = null; } else if (num2 > 0) { if (exprType != 0x30) { base.It = this.Conditions[this.CondIndex].RangeIndex.GetEmptyIterator(); return; } a = null; } } this.CurrentJoinData[i] = a; break; } } } base.It = this.Conditions[this.CondIndex].RangeIndex.FindFirstRow(base.session, base.Store, this.CurrentJoinData, this.Conditions[this.CondIndex].IndexedColumnCount, this.Conditions[this.CondIndex].OpType, this.Conditions[this.CondIndex].Reversed, null); }
public void MoveData(Session session, IPersistentStore other, int colindex, int adjust) { object defaultValue = null; SqlType type = null; SqlType type2 = null; if ((adjust >= 0) && (colindex != -1)) { defaultValue = ((Table)this.table).GetColumn(colindex).GetDefaultValue(session); type2 = this.table.GetColumnTypes()[colindex]; } if ((adjust <= 0) && (colindex != -1)) { type = other.GetTable().GetColumnTypes()[colindex]; } IRowIterator rowIterator = other.GetRowIterator(); Table table = (Table)this.table; try { while (rowIterator.HasNext()) { object[] rowData = rowIterator.GetNextRow().RowData; object[] emptyRowData = table.GetEmptyRowData(); object a = null; if ((adjust == 0) && (colindex != -1)) { a = rowData[colindex]; defaultValue = type2.ConvertToType(session, a, type); } if ((defaultValue != null) && type2.IsLobType()) { session.sessionData.AdjustLobUsageCount(defaultValue, 1); } if (((a != null) && (type != null)) && type.IsLobType()) { session.sessionData.AdjustLobUsageCount(a, -1); } ArrayUtil.CopyAdjustArray <object>(rowData, emptyRowData, defaultValue, colindex, adjust); table.SystemSetIdentityColumn(session, emptyRowData); table.EnforceTypeLimits(session, emptyRowData); table.EnforceRowConstraints(session, emptyRowData); Row newCachedObject = this.GetNewCachedObject(null, emptyRowData); this.IndexRow(null, newCachedObject); } } catch (OutOfMemoryException) { throw Error.GetError(460); } }
private void SetParameter(int i, UtlParameter param) { object o = param.Value; if ((o == null) || (o == DBNull.Value)) { this._parameterValues[i] = null; return; } ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy; SqlType type = this._parameterTypes[i]; int typeCode = type.TypeCode; if (typeCode <= 30) { if (typeCode > 0x15) { switch (typeCode) { case 0x19: case 30: goto Label_028B; } this._parameterValues[i] = o; return; } switch (typeCode) { case 0x15: { DataTable dataTable = o as DataTable; if (dataTable != null) { dataTable.TableName = this._parameterNames[i]; if (!((TableType)this._parameterTypes[i]).IsCompatible(dataTable)) { goto Label_0379; } goto Label_03AF; } DbDataReader reader = o as DbDataReader; if (reader == null) { goto Label_03AF; } dataTable = new DataTable(this._parameterNames[i]); UtlMetaData.PopulateDataTable(dataTable, reader); if (((TableType)this._parameterTypes[i]).IsCompatible(dataTable)) { o = dataTable; goto Label_03AF; } goto Label_0379; } } } else { if (typeCode <= 0x3d) { if (typeCode == 40) { this._parameterValues[i] = o; return; } if ((typeCode - 60) > 1) { goto Label_028B; } byte[] data = o as byte[]; if (data != null) { o = new BinaryData(data, !this._command.Connection.IsNetConnection); } else { try { if (o is string) { o = type.ConvertToDefaultType(sessionProxy, o); goto Label_03AF; } } catch (CoreException exception1) { UtlException.ThrowError(exception1); } UtlException.ThrowError(Error.GetError(0x15bd)); } goto Label_03AF; } switch (typeCode) { case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: try { if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase))) { o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar); } else { o = type.ConvertCSharpToSQL(sessionProxy, o); } } catch (CoreException exception2) { UtlException.ThrowError(exception2); } goto Label_03AF; case 0x65: case 0x66: case 0x6b: { MonthSpan span = (MonthSpan)o; o = new IntervalMonthData((long)span.TotalMonths); goto Label_03AF; } case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6c: case 0x6d: case 110: case 0x6f: case 0x70: case 0x71: { TimeSpan span2 = (TimeSpan)o; long totalSeconds = (long)span2.TotalSeconds; int nanos = (int)((span2.TotalSeconds - totalSeconds) * 1000000000.0); o = new IntervalSecondData(totalSeconds, nanos); goto Label_03AF; } case 0x457: try { if (o.GetType().IsSerializable) { o = new OtherData(o); goto Label_03AF; } } catch (CoreException exception3) { UtlException.ThrowError(exception3); } UtlException.ThrowError(Error.GetError(0x15bd)); goto Label_03AF; } } Label_028B :; try { if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase))) { o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar); } else if (param.UtlType == UtlType.Null) { o = type.ConvertToDefaultType(sessionProxy, o); } else { SqlType type2 = this.UtlType2SqlType(param.UtlType); o = type.ConvertToType(sessionProxy, o, type2); } } catch (CoreException exception4) { UtlException.ThrowError(exception4); } goto Label_03AF; Label_0379 :; try { if (param.UtlType == UtlType.Null) { o = type.ConvertToDefaultType(sessionProxy, o); } else { SqlType type3 = this.UtlType2SqlType(param.UtlType); o = type.ConvertToType(sessionProxy, o, type3); } } catch (CoreException exception5) { UtlException.ThrowError(exception5); } Label_03AF: this._parameterValues[i] = o; }
public Result GetProcedureResult(Session session) { Result updateZeroResult; object[] objArray = new object[0]; if (this._arguments.Length != 0) { objArray = new object[this._arguments.Length]; } Dictionary <string, IRowIterator> dictionary = new Dictionary <string, IRowIterator>(); for (int i = 0; i < this._arguments.Length; i++) { Expression expression = this._arguments[i]; object a = expression.GetValue(session); if (expression != null) { ColumnSchema parameter = this.Procedure.GetParameter(i); SqlType dataType = parameter.GetDataType(); objArray[i] = dataType.ConvertToType(session, a, expression.GetDataType()); if (dataType.IsTableType()) { IRowIterator argumentNavigator = this.GetArgumentNavigator(session, expression.GetColumnName()); dictionary.Add(parameter.GetName().Name, argumentNavigator); } } } session.sessionContext.Push(true); session.sessionContext.PushRoutineTables(this.Procedure.ScopeTables); foreach (KeyValuePair <string, IRowIterator> pair in dictionary) { Table parameterTable = this.Procedure.GetParameterTable(pair.Key); if (parameterTable != null) { IPersistentStore rowStore = session.sessionData.GetRowStore(parameterTable); parameterTable.ClearAllData(rowStore); IRowIterator iterator2 = pair.Value; while (iterator2.HasNext()) { object[] next = iterator2.GetNext(); parameterTable.InsertData(session, rowStore, next); } } } session.sessionContext.RoutineArguments = objArray; session.sessionContext.RoutineVariables = new object[0]; if (this.Procedure.IsPsm()) { updateZeroResult = this.ExecutePsmProcedure(session); } else { updateZeroResult = this.ExecuteClrProcedure(session); } object[] routineArguments = session.sessionContext.RoutineArguments; session.sessionContext.PopRoutineTables(); session.sessionContext.Pop(true); bool flag = false; for (int j = 0; j < this.Procedure.GetParameterCount(); j++) { if (this.Procedure.GetParameter(j).GetParameterMode() != 1) { if (this._arguments[j].IsDynamicParam()) { int parameterIndex = this._arguments[j].ParameterIndex; session.sessionContext.DynamicArguments[parameterIndex] = routineArguments[j]; flag = true; } else if (this._arguments[j].IsParameter()) { int columnIndex = this._arguments[j].GetColumnIndex(); session.sessionContext.RoutineArguments[columnIndex] = routineArguments[j]; } else { int columnIndex = this._arguments[j].GetColumnIndex(); session.sessionContext.RoutineVariables[columnIndex] = routineArguments[j]; } } } if (!updateZeroResult.IsError()) { if (updateZeroResult.IsSimpleValue()) { updateZeroResult = Result.UpdateZeroResult; } if (flag) { updateZeroResult = Result.NewCallResponse(this.GetParametersMetaData().GetParameterTypes(), base.Id, session.sessionContext.DynamicArguments); } } return(updateZeroResult); }