Home » U++ Library support » U++ SQL » SqlArray::SetDistinct()
SqlArray::SetDistinct() [message #7410] |
Wed, 27 December 2006 23:45 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
I'd like to propose to add method SetDistinct() to SqlArray.
It can be easily implemented.
private:
bool distinct;
public:
SqlArray& SetDistinct(bool flag = true) { distinct = flag; return *this; }
Fixes for SqlArray::AppendQuery().
SqlSet select_cols;
select_cols = (distinct ? Distinct(cols) : cols);
if(IsNull(count))
sql * ::Select(select_cols).From(table).Where(wh).OrderBy(orderby) ;
else
sql * ::Select(select_cols).From(table).Where(wh).OrderBy(orderby) .Limit(count).Offset(offset);
Actually, it is a little bit inconvenient to have an SQL statement incorporated into SqlArray. It limits you by letting to use only one table and forces to reimplement all SQL-building API.
I hope I'm not very boring.
Regards,
Novo
|
|
|
|
Re: SqlArray::SetDistinct() [message #7480 is a reply to message #7411] |
Sun, 31 December 2006 05:19 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
Thank you!
I got the idea. Just two remarks:
1) DISTINCT doesn’t break editing of data. You just need to add a list of columns from DISTINCT to a WHERE part. DISTINCT breaks master-detail relationship.
2) Instead of building an SQL statement in place you can analyze an already build statement and retrieve a list of columns to select and a FROM part. You already have a tree, which represents an SQL statement. You do not have to parse anything. You are a lucky man!
Happy New Year !!!
Regards,
Novo
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 06:58:00 CEST 2024
Total time taken to generate the page: 0.04768 seconds
|