Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 #20493 is a reply to message #19154] Fri, 20 March 2009 17:06 Go to previous messageGo to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

I went on the road, proposed in a previous message, and came across an odd job VectorMap. Here is a piece of code.


Value ConvNomencl::Format(const Value& q) const
{
	static VectorMap<int, String> nom;
	static Time lastcleartime;
	if(GetSysTime()-lastcleartime > 60){
		nom.Clear();
		lastcleartime=GetSysTime();
	}
	if(nom.GetCount()==0) nom.Add(0, " "); // <==adding empty entry there. 
	int q1=q;
	int f = nom.Find(q1);
	if(f > 0){
		String s;
		s = nom.Get(q1);
		return s;
	} else {
		Sql sql;
		sql * SqlSelect(NOM_ID,NOM_NAME).From(NOMENCL).Where(NOM_ID == q);
		String nomencl;
		if(sql.Fetch()) {
			int sid = sql[NOM_ID];
			nom.Add(sid, sql[NOM_NAME]);
			nomencl = sql[NOM_NAME];
		} else {
			nomencl = "";
		}
		return nomencl;
	}
}


After creating or cleaning object VectorMap, the first added item can not be found by .Find() method, and therefore the number of elements corresponding to the first element is continuously growing.

However, if you add the first empty element - then all the rest are working properly. This is well intended, or is it wrong?


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
 
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 May 11 18:37:08 CEST 2024

Total time taken to generate the page: 0.02858 seconds