public override void Convert( DataType [] types, Exec e ) { for ( int i = 0; i < types.Length; i += 1 ) { if ( !Convert( i, types[ i ] ) ) { e.Error( "Data type conversion error to " + DTI.Name( types[ i ] ) ); } } }
public override void Bind(SqlExec e) { for (int i = 0; i < Types.Length; i += 1) { Arg[i].Bind(e); DataType t = Arg[i].Type; if (t != Types[i]) { e.Error(this + " parameter type error, arg " + i + " expected " + DTI.Name(Types[i]) + " actual " + DTI.Name(t)); } } }
public override DataType TypeCheck( SqlExec e ) { if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName ); for ( int i = 0; i < Plist.Length; i += 1 ) if ( Plist[i].Type != B.Params.Types[i] ) { Exp conv = Plist[i].Convert( B.Params.Types[i] ); if ( conv != null ) Plist[i] = conv; else e.Error( "Parameter Type Error calling function " + FuncName + " required type=" + DTI.Name( B.Params.Types[i] ) + " supplied type=" + DTI.Name( Plist[i].Type ) + " exp=" + Plist[i] ); } return Type; }
public override void Bind( SqlExec e ) { B = e.Db.GetRoutine( Schema, FuncName, true, e ); Type = B.ReturnType; e.Bind( Plist ); if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName ); for ( int i = 0; i < Plist.Length; i += 1 ) if ( Plist[ i ].Type != B.Params.Type[ i ] ) { Exp conv = Plist[ i ].Convert( B.Params.Type[ i ] ); if ( conv != null ) Plist[ i ] = conv; else e.Error( "Parameter Type Error calling function " + FuncName + " required type=" + DTI.Name( B.Params.Type[ i ] ) + " supplied type=" + DTI.Name( Plist[ i ].Type ) + " exp=" + Plist[ i ] ); } }
public override DataType TypeCheck( SqlExec e ) { DataType tL = Left.TypeCheck( e ); DataType tR = Right.TypeCheck( e ); if ( tL == DataType.Bigint && tR == DataType.Double ) { Left = new IntToDoubleExp(Left); tL = DataType.Double; } else if ( tR == DataType.Bigint && tL == DataType.Double ) { Right = new IntToDoubleExp(Right); tR = DataType.Double; } else if ( Operator != Token.VBar && ( tL >= DataType.Decimal || tR >= DataType.Decimal ) ) { if ( tR == DataType.Bigint ) tR = DTI.Decimal(18,0); else if ( tL == DataType.Bigint ) tL = DTI.Decimal(18,0); else if ( tR == DataType.Float ) { Right = Right.Convert( tL ); tR = tL; } else if ( tL == DataType.Float ) { Left = Left.Convert( tR ); tL = tR; } int sL = DTI.Scale(tL); int sR = DTI.Scale(tR); if ( sL < 0 || sR < 0 ) e.Error( "Type error involving decimal" ); switch( Operator ) { case Token.Divide: tL = DTI.Decimal( 18, sL - sR ); break; case Token.Times: tL = DTI.Decimal( 18, sL + sR ); break; case Token.Percent: break; default: if ( sL > sR ) { Right = new ExpScale( Right, tL, sL - sR ); tR = tL; } else if ( sL < sR ) { Left = new ExpScale( Left, tR, sR - sL ); tL = tR; } break; } tR = tL; } if ( tL == tR ) { if ( Operator <= Token.NotEqual ) Type = DataType.Bool; else { Type = tL; if ( !TokenInfo.OperatorValid( Operator, tL ) ) e.Error ( "Type error " + TokenInfo.Name(Operator) + " not valid for type " + DTI.Name(tL) ); } } else if ( tL == DataType.String && Operator == Token.VBar ) { Type = DataType.String; Right = Right.Convert( DataType.String ); } else e.Error( "Binary operator datatype error"); return Type; }