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 #18978 is a reply to message #18976] Sun, 02 November 2008 22:09 Go to previous messageGo to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

By the way, I have decided to how to display related fields from other tables by using SqlArray.

struct ConvCompany : Convert
{
        Value Format(const Value &q) const
        {
			SQL * Select(COM_NAME).From(COMPANY).Where(COM_ID == q);
			String company;
			if(SQL.Fetch())
				company = SQL[COM_NAME];
			else
				company = "";
			return q.IsNull() ? Null : company;
        }
};

.....
.....

projects.AddColumn(VPR_COMPANYID, t_("Customer")).SetConvert(Single<ConvCompany>());


This method is bad because they occur too frequent recourse to the server, but the program looks beautiful.


It would be good to do the same method could display LEFT JOINED FIELD.

Maybe this way:
projects.SetTable(PROJECTV),Leftjoined(COMPANY,VPR_COMPANYID),AS_PREFIX(VCOM_);
projects.AddColumn(VCOM_COMPANYNAME, t_("Customer"));


This is the ideal, or something similar.



SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}

[Updated on: Sun, 02 November 2008 22:19]

Report message to a moderator

 
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:28 GMT+2 2026

Total time taken to generate the page: 0.00994 seconds