mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
SqlExp: TABLE1(S_TABLE_2()) SqlId form
git-svn-id: svn://ultimatepp.org/upp/trunk@7757 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
64c1c62820
commit
d4d1dc2a5f
4 changed files with 34 additions and 4 deletions
|
|
@ -39,6 +39,17 @@ SqlId SqlId::operator&(const SqlId& s) const
|
|||
return ToString() + "$" + s.ToString();
|
||||
}
|
||||
|
||||
SqlId SqlId::operator()(const S_info& table) const
|
||||
{
|
||||
String x;
|
||||
for(int i = 0; i < table.GetCount(); i++)
|
||||
if(x.IsEmpty())
|
||||
PutOf0(x, table.GetId(i));
|
||||
else
|
||||
PutOf(x, table.GetId(i));
|
||||
return x;
|
||||
}
|
||||
|
||||
String SqlS::operator()() const
|
||||
{
|
||||
return String().Cat() << '(' << text << ')';
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class SqlSet;
|
|||
class SqlSelect;
|
||||
class Case;
|
||||
|
||||
struct S_info;
|
||||
|
||||
// ----------
|
||||
|
||||
struct FieldOperator {
|
||||
|
|
@ -134,6 +136,7 @@ public:
|
|||
SqlId operator[](const SqlId& id) const; // deprecated
|
||||
|
||||
SqlId operator()(SqlId p) const;
|
||||
SqlId operator()(const S_info& table) const;
|
||||
|
||||
//$ SqlId operator()(SqlId p, SqlId p1, ...);
|
||||
#define E__PutSqlId(I) PutOf(x, p##I)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ public: \
|
|||
void Set(int i, const Value& v) { return info->Set(this, i, v); } \
|
||||
void Set(const SqlId& id, const Value& v) { return info->Set(this, id, v); } \
|
||||
void Set(const ValueMap& m) { return info->Set(this, m); } \
|
||||
\
|
||||
operator const S_info&() const { return *info; } \
|
||||
\
|
||||
S_##Table(); \
|
||||
S_##Table(const ValueMap& m);
|
||||
|
||||
|
|
|
|||
|
|
@ -385,10 +385,18 @@ topic "SqlExp in examples";
|
|||
[s0;%- [C1 where COL >`= 0]&]
|
||||
[s0;%- [*C1 group by][C1 COLUMN1]&]
|
||||
[s0;%- [*C1 having ][C1 COLUMN2 > 10]]
|
||||
:: [s0;%- [C1 Select(ID, Avg(COL)).From(TABLE1).GroupBy(ID)]&]
|
||||
[s0;%- [C1 .Having(][*C1 SqlBoolFunc(`"bool`_and`", COLUMN1 > 0)][C1 )]]
|
||||
:: [s0;%- [C1 select ID, avg(COL) from TABLE1 group by ID]&]
|
||||
[s0;%- [C1 having ][*C1 bool`_and(COLUMN1 > 0)]]
|
||||
:: [s0;%- [*C1 ValueMap m;]&]
|
||||
[s0;%- [*C1 m(COLUMN1, 1)(COLUMN2, `"hello`");]&]
|
||||
[s0;%- [C1 Insert(TABLE1)(][*C1 m][C1 )]&]
|
||||
[s0;C1%- &]
|
||||
[s0;%- [C1 Update(TABLE2)(][*C1 m][C1 ).Where(ID `=`= 123)]]
|
||||
:: [s0;C1%- &]
|
||||
[s0;C1%- &]
|
||||
[s0;%- [C1 insert into TABLE1(][*C1 COLUMN1, COLUMN2][C1 )]&]
|
||||
[s0;%- [C1 values (][*C1 1, E`'hello`'][C1 )]&]
|
||||
[s0;%- [C1 update TABLE2]&]
|
||||
[s0;%- [C1 set ][*C1 COLUMN1 `= 1, COLUMN2 `= E`'hello`']&]
|
||||
[s0;%- [C1 where ID `= 123]]
|
||||
:: [s0;%- [*C1 Update(TABLE)]&]
|
||||
[s0;%- [*C1 (COLUMN1, 13)]&]
|
||||
[s0;%- [*C1 (COLUMN2, `"world`")]&]
|
||||
|
|
@ -454,6 +462,11 @@ topic "SqlExp in examples";
|
|||
::= [s0;%- [C1 Select(][*C1 SqlAll][C1 ().Of(TABLE1))]&]
|
||||
[s0;%- [C1 .From(TABLE1)]]
|
||||
::^ [s0;%- [C1 select TABLE1.][*C1 `*][C1 from TABLE1]]
|
||||
:: [s0;%- [C1 Select(][*C1 TABLE1][C1 (][*C1 S`_TABLE2][C1 ()))]&]
|
||||
[s0;%- [C1 .From(TABLE1)]]
|
||||
:: [s0;%- [C1 select ][*C1 TABLE1.ID, TABLE1.TABLE1`_ID, TABLE1.NAME, TABLE1.LASTNAME,
|
||||
TABLE1.BDATE, TABLE1.COLUMN2, TABLE1.SEQ]&]
|
||||
[s0;%- [C1 from TABLE1]]
|
||||
::= [s0;%- [C1 Vector<int> m;]&]
|
||||
[s0;%- [C1 m << 1 << 2 << 3;]&]
|
||||
[s0;%- [C1 Select(ID)]&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue