本文整理匯總了C#中RDBMS_DBCORE.DbFunctionTools.AllocNullValue方法的典型用法代碼示例。如果您正苦於以下問題:C# DbFunctionTools.AllocNullValue方法的具體用法?C# DbFunctionTools.AllocNullValue怎麽用?C# DbFunctionTools.AllocNullValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RDBMS_DBCORE.DbFunctionTools
的用法示例。
在下文中一共展示了DbFunctionTools.AllocNullValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: INSTR
public static DbValue INSTR(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "INSTR";
args.EnsureMinCount(FunctionName, 2);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (Types.IsNullValue(arg1))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg1type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
}
int startIndex = 0;
if (args.Length > 2)
{
DbType arg2type;
ByteSlice arg2 = args[2].Eval(out arg2type);
if (arg2type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 0, "input INT, got " + arg2type.Name.ToUpper());
}
if (!Types.IsNullValue(arg2))
{
startIndex = tools.GetInt(arg2);
}
}
mstring sentence = tools.GetString(arg0);
mstring word = tools.GetString(arg1);
int index = -1;
if (startIndex < sentence.Length)
{
if (startIndex > 0)
{
sentence = sentence.SubstringM(startIndex);
}
index = sentence.IndexOf(word);
if (index > -1)
{
index += startIndex;
}
}
return tools.AllocValue(index);
}
示例2: ADD_MONTHS
public static DbValue ADD_MONTHS(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "ADD_MONTHS";
args.EnsureCount(FunctionName, 2);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.DATETIME)
{
args.Expected(FunctionName, 0, "input DATETIME, got " + arg0type.Name.ToUpper());
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (Types.IsNullValue(arg1))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg1type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 0, "input INT, got " + arg1type.Name.ToUpper());
}
DateTime dt = tools.GetDateTime(arg0);
int months = tools.GetInt(arg1);
dt = dt.AddMonths(months);
return tools.AllocValue(dt);
}
示例3: _BITWISE
private static DbValue _BITWISE(string aggregatorName, DbFunctionTools tools, DbAggregatorArguments args, int whatop)
{
if (args.Length == 0)
{
return tools.AllocNullValue();
}
DbType arg0type = DbType.PrepareNull();
for (int iarg = 0; iarg < args.Length; iarg++)
{
args[iarg].EnsureCount(aggregatorName, 1);
ByteSlice arg0 = args[iarg][0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue();
}
if (bitopbuf == null || bitopbuf.Length != arg0type.Size)
{
bitopbuf = new byte[arg0type.Size];
}
if (iarg == 0)
{
for (int ib = 0; ib < arg0.Length; ib++)
{
bitopbuf[ib] = arg0[ib];
}
continue;
}
for (int ib = 1; ib < arg0.Length; ib++)
{
switch (whatop)
{
case 1:
bitopbuf[ib] = (byte)(bitopbuf[ib] & arg0[ib]);
break;
case 2:
bitopbuf[ib] = (byte)(bitopbuf[ib] | arg0[ib]);
break;
default:
bitopbuf[ib] = (byte)(bitopbuf[ib] ^ arg0[ib]);
break;
}
}
}
ByteSlice bs = ByteSlice.Prepare(bitopbuf);
return tools.AllocValue(bs, arg0type);
}
示例4: MONTHS_BETWEEN
public static DbValue MONTHS_BETWEEN(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "MONTHS_BETWEEN";
args.EnsureCount(FunctionName, 2);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.DATETIME)
{
args.Expected(FunctionName, 0, "input DATETIME, got " + arg0type.Name.ToUpper());
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (Types.IsNullValue(arg1))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg1type.ID != DbTypeID.DATETIME)
{
args.Expected(FunctionName, 0, "input DATETIME, got " + arg1type.Name.ToUpper());
}
DateTime dt0 = tools.GetDateTime(arg0);
DateTime dt1 = tools.GetDateTime(arg1);
int daysInMonth0 = DateTime.DaysInMonth(dt0.Year, dt0.Month);
int daysInMonth1 = DateTime.DaysInMonth(dt1.Year, dt1.Month);
double btw = 0;
if (dt0.Year == dt1.Year && dt0.Month == dt1.Month) //same month and same year
{
btw = (double)(dt0.Day - dt1.Day) / (double)daysInMonth0;
}
else if (dt0.Day == daysInMonth0 && dt1.Day == daysInMonth1) //both fall on the last day of their months
{
btw = 12 * (dt0.Year - dt1.Year) + dt0.Month - dt1.Month;
}
else
{
TimeSpan sp = dt0 - dt1;
btw = sp.TotalDays / 31d;
}
return tools.AllocValue(btw);
}
示例5: SPACE
public static DbValue SPACE(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "SPACE";
args.EnsureCount(FunctionName, 1);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 0, "input INT, got " + arg0type.Name.ToUpper());
return null;
}
int len = tools.GetInt(arg0);
if (len < 1)
{
return tools.AllocValue(mstring.Prepare(""));
}
else
{
mstring s = mstring.Prepare();
for (int i = 0; i < len; i++)
{
s = s.AppendM(" ");
}
return tools.AllocValue(s);
}
}
示例6: ROUND
public static DbValue ROUND(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "ROUND";
args.EnsureCount(FunctionName, 2);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.DOUBLE)
{
args.Expected(FunctionName, 0, "input DOUBLE, got " + arg0type.Name.ToUpper());
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (arg1type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 1, "digits INT, got " + arg1type.Name.ToUpper());
}
int digits = tools.GetInt(arg1);
double x = tools.GetDouble(arg0);
x = Math.Round(x, digits);
return tools.AllocValue(x);
}
示例7: REVERSE
public static DbValue REVERSE(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "REVERSE";
args.EnsureCount(FunctionName, 1);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
}
mstring x = tools.GetString(arg0);
mstring r = mstring.Prepare();
for (int i = x.Length-1; i >= 0; i--)
{
r = r.AppendM(x.SubstringM(i, 1));
}
return tools.AllocValue(r);
}
示例8: SUBSTRING
public static DbValue SUBSTRING(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "SUBSTRING";
args.EnsureCount(FunctionName, 3);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
return null;
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (arg1type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 1, "count INT, got " + arg1type.Name.ToUpper());
return null;
}
DbType arg2type;
ByteSlice arg2 = args[2].Eval(out arg2type);
if (arg2type.ID != DbTypeID.INT)
{
args.Expected(FunctionName, 1, "count INT, got " + arg2type.Name.ToUpper());
return null;
}
mstring x = tools.GetString(arg0);
int startIndex = tools.GetInt(arg1);
if (startIndex < 0)
{
startIndex = 0;
}
int len = tools.GetInt(arg2);
if (len < 0)
{
throw new ArgumentException(FunctionName + " length cannot be negative");
}
if (startIndex + len > x.Length)
{
return tools.AllocValue(mstring.Prepare());
}
else
{
mstring sub = x.SubstringM(startIndex, len);
return tools.AllocValue(sub);
}
}
示例9: REPLACE
public static DbValue REPLACE(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "REPLACE";
args.EnsureCount(FunctionName, 3);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
}
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (Types.IsNullValue(arg1))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg1type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
}
DbType arg2type;
ByteSlice arg2 = args[2].Eval(out arg2type);
if (Types.IsNullValue(arg2))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg2type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg2type.Name.ToUpper());
}
mstring sentence = tools.GetString(arg0);
mstring word = tools.GetString(arg1);
mstring replacement = tools.GetString(arg2);
sentence = sentence.ReplaceM(ref word, ref replacement);
return tools.AllocValue(sentence);
}
示例10: FIRST
public static DbValue FIRST(DbFunctionTools tools, DbAggregatorArguments args)
{
string AggregatorName = "FIRST";
if (args.Length > 0)
{
args[0].EnsureCount(AggregatorName, 1);
return args[0][0];
}
else
{
return tools.AllocNullValue();
}
}
示例11: FORMAT
public static DbValue FORMAT(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "FORMAT";
args.EnsureCount(FunctionName, 2);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
DbType arg1type;
ByteSlice arg1 = args[1].Eval(out arg1type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg0type.ID != DbTypeID.CHARS)
{
args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
}
if (Types.IsNullValue(arg1))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
if (arg1type.ID != DbTypeID.DATETIME)
{
args.Expected(FunctionName, 0, "input DATETIME, got " + arg1type.Name.ToUpper());
}
string formatstr = tools.GetString(arg0).ToString();
DateTime dt = tools.GetDateTime(arg1);
mstring result = mstring.Prepare(dt.ToString(formatstr));
while (result.Length < 80)
{
result.MAppend('\0');
}
return tools.AllocValue(result);
}
示例12: LAST
public static DbValue LAST(DbFunctionTools tools, DbAggregatorArguments args)
{
string AggregatorName = "LAST";
if (args.Length > 0)
{
int lastindex = args.Length - 1;
args[lastindex].EnsureCount(AggregatorName, 1);
return args[lastindex][0];
}
else
{
return tools.AllocNullValue();
}
}
示例13: MAX
public static DbValue MAX(DbFunctionTools tools, DbAggregatorArguments args)
{
string AggregatorName = "MAX";
DbValue highest = null;
DbValue nullest = null;
DbFunctionArguments compareargs = new DbFunctionArguments(new DbValue[2]);
ImmediateValue argval = null;
for (int iarg = 0; iarg < args.Length; iarg++)
{
args[iarg].EnsureCount(AggregatorName, 1);
DbType arg0type;
ByteSlice arg0 = args[iarg][0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
if (null == nullest)
{
nullest = tools.AllocValue(arg0, arg0type);
}
}
else
{
if (null == argval)
{
argval = tools.AllocValue(arg0type.ID);
}
argval.SetValue(arg0);
compareargs[0] = argval;
compareargs[1] = highest;
if (null == highest || tools.GetInt(DbFunctions.COMPARE(tools, compareargs)) > 0)
{
highest = argval; // Keep this one.
argval = null; // New one next time.
}
}
}
if (null == highest)
{
if (null == nullest)
{
return tools.AllocNullValue();
}
return nullest;
}
return highest;
}
示例14: CHOOSERND
public static DbValue CHOOSERND(DbFunctionTools tools, DbAggregatorArguments args)
{
string AggregatorName = "CHOOSERND";
if (args.Length == 0)
{
return tools.AllocNullValue();
}
if (anyRnd == -1)
{
Random rnd = new Random(System.DateTime.Now.Millisecond / 2 + System.Diagnostics.Process.GetCurrentProcess().Id / 2);
anyRnd = rnd.Next();
}
int index = anyRnd % args.Length;
args[index].EnsureCount(AggregatorName, 1);
return args[index][0];
}
示例15: ABS
public static DbValue ABS(DbFunctionTools tools, DbFunctionArguments args)
{
string FunctionName = "ABS";
args.EnsureCount(FunctionName, 1);
DbType arg0type;
ByteSlice arg0 = args[0].Eval(out arg0type);
if (Types.IsNullValue(arg0))
{
return tools.AllocNullValue(); // Give a null, take a null.
}
switch (arg0type.ID)
{
case DbTypeID.INT:
{
int x = tools.GetInt(arg0);
x = Math.Abs(x);
return tools.AllocValue(x);
}
break;
case DbTypeID.LONG:
{
long x = tools.GetLong(arg0);
x = Math.Abs(x);
return tools.AllocValue(x);
}
break;
case DbTypeID.DOUBLE:
{
double x = tools.GetDouble(arg0);
x = Math.Abs(x);
return tools.AllocValue(x);
}
break;
default:
args.Expected(FunctionName, 0, "input INT, LONG or DOUBLE, got " + arg0type.Name.ToUpper());
return null; // Doesn't reach here.
}
}