⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myldbvariant.pas

📁 一个本地database引擎,支持中文T_Sql查询,兼容DELPHI标准数据库控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
            bftSingle:          AsSingle := AsSingle / Value.AsSingle;
            bftDouble:          AsDouble := AsDouble / Value.AsDouble;
            bftExtended:        AsExtended := AsExtended / Value.AsExtended;

            bftDate:            AsMYLDBDate := AsMYLDBDate div Value.AsMYLDBDate;
            bftTime:            AsMYLDBTime := AsMYLDBTime div Value.AsMYLDBTime;
            bftDateTime:        begin
                                  dt := AsMYLDBDateTime;
                                  dt.Date := dt.Date div Value.AsMYLDBDateTime.Date;
                                  dt.Time := dt.Time div Value.AsMYLDBDateTime.Time;
                                  if (dt.Time >= MILSECS_IN_DAY) then
                                   begin
                                    dt.Date := dt.Date + dt.Time div MILSECS_IN_DAY;
                                    dt.Time := dt.Time mod MILSECS_IN_DAY;
                                   end;
                                  AsMYLDBDateTime := dt;
                                end;

            bftLogical:         AsLogical := AsLogical or Value.AsLogical;
            bftCurrency:        AsCurrency := AsCurrency / Value.AsCurrency;
            else
              raise EMYLDBException.Create(30127, ErrorGNotNumericDataType, ['/']);
          end;
        except
          on EMYLDBException do raise;
          on e: Exception do
            raise EMYLDBException.Create(30128, ErrorGDivisionError, [e.Message]);
      end;
    end;
end;//Division
 {$IFDEF RESET_OVERFLOW}
  {$Q+}
 {$ENDIF}


//------------------------------------------------------------------------------
// Compare with another Variants
//------------------------------------------------------------------------------
function TMYLDBVariant.Compare(Value: TMYLDBVariant; TrueFalseNullLogic, CaseInsensitive, PartialKey: boolean): TMYLDBCompareResult;
var
  i: Integer;
begin
  if (PartialKey) then
    // 5.07
    // fix LikeTest1
    // begin old code
    // i := min(StrLen, Value.StrLen)
    // end old code
    i := Value.StrLen
  else
    i := -1;
  Result := CompareValueBuffers(FPData, Value.FPData,
                                FDataType, Value.DataType,
                                IsNull, Value.IsNull,
                                i, CaseInsensitive);
  if (not TrueFalseNullLogic) then
   case Result of
    cmprBothNull:
      Result := cmprEqual;
    cmprLeftNull:
      Result := cmprLower;
    cmprRightNull:
      Result := cmprGreater;
   end;
end;//Compare


//------------------------------------------------------------------------------
// Return Common DataType for 2 types, or ftUnknown
//------------------------------------------------------------------------------
function GetCommonDataType(a,b: TMYLDBBaseFieldType; ForCompare: Boolean=False): TMYLDBBaseFieldType;
begin
{  if (a = b) then
    begin
      Result := a;
      Exit;
    end;
}
  Result := bftUnknown;
  case a of
    bftChar:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftChar;
        bftSignedInt16:      Result := bftChar;
        bftSignedInt32:      Result := bftChar;
        bftSignedInt64:      Result := bftChar;
        bftUnsignedInt8:     Result := bftChar;
        bftUnsignedInt16:    Result := bftChar;
        bftUnsignedInt32:    Result := bftChar;

        bftSingle:           Result := bftChar;
        bftDouble:           Result := bftChar;
        bftExtended:         Result := bftChar;

        bftDate:             if ForCompare then Result := bftDate else Result := bftChar;
        bftTime:             if ForCompare then Result := bftTime else Result := bftChar;
        bftDateTime:         if ForCompare then Result := bftDateTime else Result := bftChar;

        bftLogical:          Result := bftChar;
        bftCurrency:         Result := bftChar;

        bftClob:             Result := bftChar;
        bftWideClob:         Result := bftWideChar;
      end;
    bftWideChar:
      case b of
        bftChar:             Result := bftWideChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftWideChar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftWideChar;
        bftSignedInt16:      Result := bftWideChar;
        bftSignedInt32:      Result := bftWideChar;
        bftSignedInt64:      Result := bftWideChar;
        bftUnsignedInt8:     Result := bftWideChar;
        bftUnsignedInt16:    Result := bftWideChar;
        bftUnsignedInt32:    Result := bftWideChar;

        bftSingle:           Result := bftWideChar;
        bftDouble:           Result := bftWideChar;
        bftExtended:         Result := bftWideChar;

        bftDate:             if ForCompare then Result := bftDate else Result := bftWideChar;
        bftTime:             if ForCompare then Result := bftTime else Result := bftWideChar;
        bftDateTime:         if ForCompare then Result := bftDateTime else Result := bftWideChar;

        bftLogical:          Result := bftWideChar;
        bftCurrency:         Result := bftWideChar;

        bftClob:             Result := bftWideChar;
        bftWideClob:         Result := bftWideChar;
      end;
    bftVarchar:
      case b of
        bftChar:             Result := bftVarchar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftVarchar;
        bftSignedInt16:      Result := bftVarchar;
        bftSignedInt32:      Result := bftVarchar;
        bftSignedInt64:      Result := bftVarchar;
        bftUnsignedInt8:     Result := bftVarchar;
        bftUnsignedInt16:    Result := bftVarchar;
        bftUnsignedInt32:    Result := bftVarchar;

        bftSingle:           Result := bftVarchar;
        bftDouble:           Result := bftVarchar;
        bftExtended:         Result := bftVarchar;

        bftDate:             if ForCompare then Result := bftDate else Result := bftVarchar;
        bftTime:             if ForCompare then Result := bftTime else Result := bftVarchar;
        bftDateTime:         if ForCompare then Result := bftDateTime else Result := bftVarchar;

        bftLogical:          Result := bftVarchar;
        bftCurrency:         Result := bftVarchar;

        bftClob:             Result := bftVarchar;
        bftWideClob:         Result := bftWideVarchar;
      end;
    bftWideVarchar:
      case b of
        bftChar:             Result := bftWideVarchar;
        bftWideChar:         Result := bftWideVarchar;
        bftVarchar:          Result := bftWideVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftWideVarchar;
        bftSignedInt16:      Result := bftWideVarchar;
        bftSignedInt32:      Result := bftWideVarchar;
        bftSignedInt64:      Result := bftWideVarchar;
        bftUnsignedInt8:     Result := bftWideVarchar;
        bftUnsignedInt16:    Result := bftWideVarchar;
        bftUnsignedInt32:    Result := bftWideVarchar;

        bftSingle:           Result := bftWideVarchar;
        bftDouble:           Result := bftWideVarchar;
        bftExtended:         Result := bftWideVarchar;

        bftDate:             if ForCompare then Result := bftDate else Result := bftWideVarchar;
        bftTime:             if ForCompare then Result := bftTime else Result := bftWideVarchar;
        bftDateTime:         if ForCompare then Result := bftDateTime else Result := bftWideVarchar;

        bftLogical:          Result := bftWideVarchar;
        bftCurrency:         Result := bftWideVarchar;

        bftClob:             Result := bftWideVarchar;
        bftWideClob:         Result := bftWideVarchar;
      end;
    bftSignedInt8:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt8;
        bftSignedInt16:      Result := bftSignedInt16;
        bftSignedInt32:      Result := bftSignedInt32;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftSignedInt16;
        bftUnsignedInt16:    Result := bftUnsignedInt16;
        bftUnsignedInt32:    Result := bftUnsignedInt32;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftSignedInt8;
        bftCurrency:         Result := bftCurrency;

      end;
    bftSignedInt16:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt16;
        bftSignedInt16:      Result := bftSignedInt16;
        bftSignedInt32:      Result := bftSignedInt32;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftSignedInt16;
        bftUnsignedInt16:    Result := bftUnsignedInt16;
        bftUnsignedInt32:    Result := bftUnsignedInt32;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftSignedInt16;
        bftCurrency:         Result := bftCurrency;

      end;
    bftSignedInt32:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt32;
        bftSignedInt16:      Result := bftSignedInt32;
        bftSignedInt32:      Result := bftSignedInt32;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftSignedInt32;
        bftUnsignedInt16:    Result := bftSignedInt32;
        bftUnsignedInt32:    Result := bftSignedInt64;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftSignedInt32;
        bftCurrency:         Result := bftCurrency;

      end;
    bftSignedInt64:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt64;
        bftSignedInt16:      Result := bftSignedInt64;
        bftSignedInt32:      Result := bftSignedInt64;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftSignedInt64;
        bftUnsignedInt16:    Result := bftSignedInt64;
        bftUnsignedInt32:    Result := bftSignedInt64;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftSignedInt64;
        bftCurrency:         Result := bftCurrency;

      end;
    bftUnsignedInt8:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt16;
        bftSignedInt16:      Result := bftSignedInt16;
        bftSignedInt32:      Result := bftSignedInt32;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftUnsignedInt8;
        bftUnsignedInt16:    Result := bftUnsignedInt16;
        bftUnsignedInt32:    Result := bftUnsignedInt32;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftUnsignedInt8;
        bftCurrency:         Result := bftCurrency;

      end;
    bftUnsignedInt16:
      case b of
        bftChar:             Result := bftChar;
        bftWideChar:         Result := bftWideChar;
        bftVarchar:          Result := bftVarchar;
        bftWideVarchar:      Result := bftWideVarchar;

        bftSignedInt8:       Result := bftSignedInt32;
        bftSignedInt16:      Result := bftSignedInt32;
        bftSignedInt32:      Result := bftSignedInt32;
        bftSignedInt64:      Result := bftSignedInt64;
        bftUnsignedInt8:     Result := bftUnsignedInt16;
        bftUnsignedInt16:    Result := bftUnsignedInt16;
        bftUnsignedInt32:    Result := bftUnsignedInt32;

        bftSingle:           Result := bftSingle;
        bftDouble:           Result := bftDouble;
        bftExtended:         Result := bftExtended;

        bftDate:             Result := bftDate;
        bftTime:             Result := bftTime;
        bftDateTime:         Result := bftDateTime;

        bftLogical:          Result := bftUnsignedInt16;
        bftCurrency:         Result := bftCurrency;

      end;
    bftUnsignedInt32:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -