U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ SQL » How to display fields from different tables in one SQLArray
Re: How to display fields from different tables in one SQLArray [message #18785 is a reply to message #18769] Mon, 20 October 2008 22:51 Go to previous messageGo to previous message
zsolt is currently offline  zsolt
Messages: 702
Registered: December 2005
Location: Budapest, Hungary
Contributor
First you have to add the fields to your arrayctrl:
m_array.AddKey(PR_ID); //primary key
m_array.AddColumn(PR_CREATIONDATE, t_("Creation Date"), 10)
    .SetConvert(Single<ConvertYourIntBasedDate>());
...
m_array.AddColumn(COM_NAME, t_("Company Name"), 10);
...


You have to have a function returning the fields of your Select statement:
SqlSet GetSqlColumns(const ArrayCtrl &a_array)
{
	SqlSet cols;
	for(int i = 0; i < a_array.GetIndexCount(); i++)
		if(!a_array.GetId(i).IsNull())
			cols.Cat(SqlId(a_array.GetId(i)));
	return cols;
}


And a code to fill the arrayctrl from db:
SqlSet cols = GetSqlColumns(m_array);
Sql sql;
sql * ::Select(Distinct(cols))
	.From(PROJECT)
	.LeftJoin(COMPANY)
	.On(COM_ID == PR_COMPANYID)
	.Where(1)
	.OrderBy(PR_ID)
;

for(;;) {
	Vector<Value> row;
	if(!sql.Fetch(row)) break;
	m_array.Add(row);
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DBF crash error while writing record
Next Topic: PATCH/BUGFIX Oracle asTable Failure - Solution
Goto Forum:
  


Current Time: Sat Apr 25 15:13:26 GMT+2 2026

Total time taken to generate the page: 0.00864 seconds