diff --git a/uppsrc/Sql/SqlVal.cpp b/uppsrc/Sql/SqlVal.cpp index b20ec2f3b..9fd02212c 100644 --- a/uppsrc/Sql/SqlVal.cpp +++ b/uppsrc/Sql/SqlVal.cpp @@ -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 << ')'; diff --git a/uppsrc/Sql/Sqlexp.h b/uppsrc/Sql/Sqlexp.h index e1ac9a157..9f79cc863 100644 --- a/uppsrc/Sql/Sqlexp.h +++ b/uppsrc/Sql/Sqlexp.h @@ -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) diff --git a/uppsrc/Sql/sch_header.h b/uppsrc/Sql/sch_header.h index c96592d72..675437ae6 100644 --- a/uppsrc/Sql/sch_header.h +++ b/uppsrc/Sql/sch_header.h @@ -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); diff --git a/uppsrc/Sql/src.tpp/SqlExp$en-us.tpp b/uppsrc/Sql/src.tpp/SqlExp$en-us.tpp index bfa8a2886..b885b2814 100644 --- a/uppsrc/Sql/src.tpp/SqlExp$en-us.tpp +++ b/uppsrc/Sql/src.tpp/SqlExp$en-us.tpp @@ -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 m;]&] [s0;%- [C1 m << 1 << 2 << 3;]&] [s0;%- [C1 Select(ID)]&]