예제 #1
0
  public Exp Convert( DataType t )
  {
    if ( t < DataType.Decimal ) t = DTI.Base( t );

    if ( Type == t ) return this;
    else if ( Type == DataType.Bigint ) return 
        t == DataType.String ? (Exp) new IntToStringExp( this )
      : t == DataType.Double ? (Exp) new IntToDoubleExp( this )
      : t >= DataType.Decimal ? (Exp) new IntToDecimalExp( this, t )
      : null;
    else if ( Type == DataType.Double ) return 
       t == DataType.String ? (Exp) new DoubleToStringExp( this )
     : t == DataType.Bigint ? (Exp) new DoubleToIntExp( this )
     : t >= DataType.Decimal ? (Exp) new DoubleToDecimalExp( this, t )
     : null;
    else if ( Type >= DataType.Decimal )
    {
      if ( t == DataType.String ) return new DecimalToStringExp( this );
      else if ( t == DataType.Double ) return new DecimalToDoubleExp( this );
      else if ( t >= DataType.Decimal )
      {
        int amount = DTI.Scale( t ) - DTI.Scale( Type );
        return amount == 0 ? (Exp) this
        : amount > 0 ? (Exp) new ExpScale( this, t, amount )
        : (Exp) new ExpScaleReduce( this, t, -amount );
      }
    }
    else if ( Type == DataType.Binary && t == DataType.String )
      return new BinaryToStringExp( this );
    else if ( Type == DataType.Bool && t == DataType.String )
      return new BoolToStringExp( this );
    else if ( Type == DataType.ScaledInt && t >= DataType.Decimal ) return this;
    return null;
  }
예제 #2
0
 // At least one of GetDV or the relevant GetD? must be implemented ( or an infinite recursion will happen ).
 public virtual DV GetDV()
 { 
   switch( DTI.Base( Type ) )
   {
     case DataType.Bool   : DB db = GetDB(); return ( ee ) => Value.New( db( ee ) );
     case DataType.Double : DD dd = GetDD(); return ( ee ) => Value.New( dd( ee ) );
     case DataType.String : DS ds = GetDS(); return ( ee ) => Value.New( ds( ee ) );
     case DataType.Binary : DX dx = GetDX(); return ( ee ) => Value.New( dx( ee ) );
     default:               DL dl = GetDL(); return ( ee ) => Value.New( dl( ee ) );
   }
 }
예제 #3
0
  public override void Bind( SqlExec e )
  {
    var ci = e.CI;
    if ( ci == null ) e.Error( "Undeclared variable " + ColName );
    for ( int i=0; i < ci.Count; i += 1 ) 
      if ( ci.Name[ i ] == ColName ) 
      { 
        e.Used[ i ] = true;
        ColIx = i; 
        Type = DTI.Base( ci.Type[ i ] );
        return;
      }

    e.Error( "Column " + ColName + " not found" );
  }
예제 #4
0
  public override DataType Bind( SqlExec e )
  {
    var ci = e.CI;
    if ( ci == null ) e.Error( "Undeclared variable " + ColName );
    for ( int i=0; i < ci.Count; i += 1 ) 
      if ( ci.Names[i] == ColName ) 
      { 
        e.Used[ i ] = true;
        ColIx = i; 
        Type = DTI.Base( ci.Types[i] );
        return Type;
      }

    // for ( int i=0; i < ci.Length; i += 1 ) System.Console.WriteLine( ci[i].Name );
    
    e.Error( "Column " + ColName + " not found" );
    return Type;
  }