diff --git a/uppsrc/Sql/SqlSchema.h b/uppsrc/Sql/SqlSchema.h index d9e5f81b0..8e6156184 100644 --- a/uppsrc/Sql/SqlSchema.h +++ b/uppsrc/Sql/SqlSchema.h @@ -144,6 +144,8 @@ struct S_info { int GetCount() const { return column.GetCount(); } SqlId GetId(int i) const { return column.GetKey(i); } + int GetIndex(const String& id) const { return column.Find(id); } + int GetIndex(const SqlId& id) const { return column.Find(~id); } int GetWidth(int i) const { return column[i].width; } int GetWidth(const SqlId& id) const; @@ -194,6 +196,8 @@ struct S_type { static int GetCount(); static SqlId GetId(int i); + static int GetIndex(const String& id); + static int GetIndex(const SqlId& id); static int GetWidth(int i); static int GetWidth(const SqlId& id); diff --git a/uppsrc/Sql/Sqlexp.h b/uppsrc/Sql/Sqlexp.h index eb3cde3fd..beef7bfe4 100644 --- a/uppsrc/Sql/Sqlexp.h +++ b/uppsrc/Sql/Sqlexp.h @@ -479,6 +479,17 @@ SqlSet SqlSetFrom(const T& cont) return set; } +template +SqlSet SqlSetFrom(const T& cont, int pos, int count) +{ + SqlSet set; + typename T::ConstIterator it = cont.Begin() + pos; + typename T::ConstIterator e = it + count; + for(; it != e; it++) + set.Cat(*it); + return set; +} + class SqlSetC : public SqlSet { public: SqlSetC(const String& s) { text = s; priority = SET; } diff --git a/uppsrc/Sql/sch_header.h b/uppsrc/Sql/sch_header.h index cbe987e3e..c96592d72 100644 --- a/uppsrc/Sql/sch_header.h +++ b/uppsrc/Sql/sch_header.h @@ -24,6 +24,8 @@ public: \ \ static int GetCount() { return GetInfo().GetCount(); } \ static SqlId GetId(int i) { return GetInfo().GetId(i); } \ + static int GetIndex(const String& id) { return GetInfo().GetIndex(id); } \ + static int GetIndex(const SqlId& id) { return GetInfo().GetIndex(id); } \ static int GetWidth(int i) { return GetInfo().GetWidth(i); } \ static int GetWidth(const SqlId& id) { return GetInfo().GetWidth(id); } \ \ diff --git a/uppsrc/Sql/src.tpp/S_type$en-us.tpp b/uppsrc/Sql/src.tpp/S_type$en-us.tpp index 0ee362f5b..c430bb80b 100644 --- a/uppsrc/Sql/src.tpp/S_type$en-us.tpp +++ b/uppsrc/Sql/src.tpp/S_type$en-us.tpp @@ -95,6 +95,14 @@ t]_[*@3 i])&] [s2; Returns a column ID for column at [%-*@3 i].&] [s3; &] [s4;%- &] +[s5;:S`_type`:`:GetIndex`(const String`&`):%- [@(0.0.255) static] [@(0.0.255) int]_[* GetIn +dex]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 id])&] +[s5;:S`_type`:`:GetIndex`(const SqlId`&`):%- [@(0.0.255) static] [@(0.0.255) int]_[* GetInd +ex]([@(0.0.255) const]_[_^SqlId^ SqlId][@(0.0.255) `&]_[*@3 id])&] +[s2;~~~1792; Returns the index of column [%-*@3 id] or negative number +if not found.&] +[s3; &] +[s4;%- &] [s5;:S`_type`:`:GetWidth`(int`):%- [@(0.0.255) static] [@(0.0.255) int]_[* GetWidth]([@(0.0.255) i nt]_[*@3 i])&] [s2; Returns the width of column (usually text) as defined in the