Home » U++ Library support » U++ SQL » [sql] Select embeded in join
Re: [sql] Select embeded in join [message #22844 is a reply to message #22840] |
Fri, 21 August 2009 15:59 |
Zbych
Messages: 326 Registered: July 2009
|
Senior Member |
|
|
luzr wrote on Fri, 21 August 2009 14:30 |
Would it be possible to use other type as return value?
|
All joins expect SqlId type, so it can be any type that can be converted to SqlId. I tried it with String and it works fine:
String AsTable(SqlId table) const { return String("(") << text << ") as " << table.ToString(); }
But maybe all joins should be overloaded and accept SqlSelect?
Sqlexp.h:
class SqlSelect {
[...]
private:
SqlSelect& LeftJoin0(const char * item);
[...]
public:
SqlSelect& LeftJoin(SqlId table) {return LeftJoin0(~table);}
SqlSelect& LeftJoin(SqlSelect select) {return LeftJoin0(~select);}
[...]
String ToString() const { return text; }
String operator~() const { return ToString(); }
[...]
SqlSelect & AsTable(SqlId table);
[...]
SqlStatement.cpp:
SqlSelect& SqlSelect::LeftJoin0(const char * item) {
text << " left outer join " << item;
return *this;
}
SqlSelect & SqlSelect::AsTable(SqlId table)
{
text = String("(") << text << ") as " << ~table;
return *this;
}
[Updated on: Fri, 21 August 2009 21:57] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri May 03 22:58:34 CEST 2024
Total time taken to generate the page: 0.02657 seconds
|