SqlExp: Decode nonOracle variants improved

git-svn-id: svn://ultimatepp.org/upp/trunk@7878 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-11-09 17:32:52 +00:00
parent 7bdd4527c7
commit 12853cdcef

View file

@ -248,11 +248,15 @@ SqlBool SqlBoolFunc(const char *n, const SqlBool& a, const SqlBool& b, const Sql
SqlVal Decode(const SqlVal& exp, const SqlSet& variants) {
ASSERT(!variants.IsEmpty());
Vector<SqlVal> v = variants.Split();
ASSERT(v.GetCount() > 2);
ASSERT(v.GetCount() > 1);
Case cs(exp == v[0], v[1]);
for(int i = 2; i + 1 < v.GetCount(); i += 2)
int i;
for(i = 2; i + 1 < v.GetCount(); i += 2)
cs(exp == v[i], v[i + 1]);
cs(v.Top());
if(i < v.GetCount())
cs(v[i]);
else
cs(Null);
return SqlVal(SqlCase(ORACLE, "decode(" + ~exp + ", " + ~variants + ')')('(' + ~cs + ')'),
SqlS::FN);
}