Ejemplo n.º 1
0
SqlSelect& SqlSelect::Limit(int limit) {
    ASSERT(text.StartsWith("select "));
    String s = AsString(limit);
    text.Insert(6, SqlCode(MSSQL, " top " + s)());
    text << SqlCode(MSSQL, "")(" limit " + s);
    return *this;
}
Ejemplo n.º 2
0
SqlSet SqlSelect::AsTable(const SqlId& tab) const
{
    StringBuffer t;
    t << SqlCode(MSSQL|PGSQL, "")("(")
      << "(" << text << ") as \t" << tab.ToString() << '\t'
      << SqlCode(MSSQL|PGSQL, "")(")");
    return SqlSet(String(t), SqlSet::HIGH);
}
Ejemplo n.º 3
0
String SqlSet::operator()(int at, byte cond) const {
	if(IsEmpty()) return "null";
	if(at <= priority)
		return text;
	StringBuffer out;
	out << SqlCode(cond, "(")() << text << SqlCode(cond, ")")();
	return out;
}
Ejemplo n.º 4
0
SqlSelect& SqlSelect::SetOp(const SqlSelect& s2, const char *op)
{
    String q;
    q << SqlCode(SQLITE3, "")("((")
      << text
      << SqlCode(SQLITE3, "")(")")
      << op
      << SqlCode(SQLITE3, "")("(")
      << s2.text
      << SqlCode(SQLITE3, "")("))")
      ;
    text = q;
    return *this;
}
Ejemplo n.º 5
0
SqlWith& SqlWith::WithRecursive(SqlId table)
{
    text << (text.GetCount() ? ", " : "with ")
         << SqlCode(MSSQL, "")("recursive ")
         << table.Quoted();
    args = false;
    return *this;
}
Ejemplo n.º 6
0
SqlSelect& SqlSelect::operator-=(const SqlSelect& s2) {
    return SetOp(s2, SqlCode(MSSQL|PGSQL|SQLITE3," except ")(" minus "));
}
Ejemplo n.º 7
0
SqlSelect& SqlSelect::Get() {
    text = "select " + text + SqlCode(ORACLE, " from DUAL")("");
    valid = true;
    return *this;
}
Ejemplo n.º 8
0
SqlSelect& SqlSelect::ForUpdate() {
    text << SqlCode(SQLITE3, "")(" for update");
    return *this;
}
Ejemplo n.º 9
0
SqlVal GetYearDayIndex(const SqlVal& date)
{
    SqlVal mssql("substring(convert(varchar(max), " + ~date + ", 1), 1, 5)", SqlS::FN);
    SqlVal oracle(SqlFunc("to_char", date, "MM/DD"));
    return SqlVal(SqlCode(MSSQL, ~mssql)(~oracle), SqlS::FN);
}
Ejemplo n.º 10
0
SqlId SchemaId(const SqlId& table_id, const SqlId& alias_id)
{
    return SqlId(SchemaTableName(~table_id) + SqlCode(MSSQL, " as ")(" ") + ~alias_id);
}
Ejemplo n.º 11
0
SqlBool Like(const SqlVal& a, const SqlVal& b, bool cs) {
	return SqlBool(a, SqlCode
			(MY_SQL, cs ? " like binary " : " like ")
			(PGSQL, cs ? " like " : " ilike ")
			(" like "),	b, SqlS::COMP);
}
Ejemplo n.º 12
0
SqlBool IsSame(const SqlVal& a, const SqlVal& b)
{
	return SqlBool(a, SqlCode(MY_SQL, "<=>")(" is not distinct from "), b, SqlS::COMP);
}
Ejemplo n.º 13
0
SqlBool NotLike(const SqlVal& a, const SqlVal& b, bool cs) {
	return SqlBool(a, SqlCode
			(PGSQL, cs ? " not like " : " not ilike ")
			(" not like "), b, SqlS::COMP);
}
Ejemplo n.º 14
0
SqlSet operator-(const SqlSet& s1, const SqlSet& s2) {
	if(s1.IsEmpty() || s2.IsEmpty())
		return s1;
	return SqlSet(s1(SqlSet::SET) + SqlCode(MSSQL|PGSQL|SQLITE3, " except ")(" minus ") + s2(SqlSet::SET), SqlSet::SETOP);
}