| Home » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » Some Sql addidtions Goto Forum:
	| 
		
			| Some Sql addidtions [message #16562] | Thu, 26 June 2008 14:56  |  
			|  |  
	| Recently I made possible to write select in select fields list: 
 
SQL * ::Select(
   ID, 
   NAME, 
   ::Select(NAME, AGE).From(PARENTS).Where(KID_ID == ID),
   PHONE
).From(KIDS)
..and conditions
 
 
SQL * ::Select(
  X == Y,
  NUMBER < 100,
).From(TABLE)
SqlNvl has now As() method so it's possible to write:
 
 
SQL * ::Select(
   (QUANTITY * PRICE).As(FINAL_PRICE)
   (NAME | SURNAME).As(FULL_NAME)
).From(PRICES)
It's also possible to write cases:
 
 
SQL * ::Select(
  ID,
  Case(AGE < 5, "Baby")
      (Between(AGE, 5, 10), "Kid")
      ("Young man"),
  NAME
.From(PERSONS)
 |  
	|  |  |  
	|  |  
	| 
		
			| Re: Some Sql addidtions [message #16573 is a reply to message #16567] | Fri, 27 June 2008 23:16   |  
			|  |  
	| How about to write SQL queries as a simple text? for example:
 
 ?| Quote: |  | Query *q;
 q->SetText ( "SELECT SomeColumns FROM SomeTable WHERE SomeCondition = &SomeParameter GROUP BY SomeGoups HAVING SomeHavingCondition..." )
 
 | 
 and after then we can set parameter value;
 
 | Quote: |  | q->SetParameter ( "SomeParameter", parameter_value );
 
 | 
 
 after then we can do:
 
 
 | Quote: |  | QResult *q_result = q->Execute ();
 
 QChoose q_chouse = q_result->Choose ();
 
 while ( q_chouse->Next () ) {...}
 
 
 | 
 or
 
 
 | Quote: |  | Array q_res = q->Execute ()->Unload ();
 
 | 
 
 How about thi idea? I thing that this is more simple... and will be possible for sent to an server application only query text!
 [Updated on: Fri, 27 June 2008 23:19] Report message to a moderator |  
	|  |  |  
	|  |  
	|  |  
	|  |  
	| 
		
			| Re: Some Sql addidtions [message #16581 is a reply to message #16578] | Sat, 28 June 2008 23:30   |  
			|  |  
	| Thank you Mirek! I like this "low level" query! 
 I tried to compile example package and get folow error:
 
 
 | Quote: |  | C:\uppdev\examples\SQLApp\query.cpp(17) : error C2593: 'operator ==' is ambiguous
 c:\uppdev\uppsrc\sql\Sqlexp.h(346): could be 'Upp::SqlBool Upp::operator ==(const Upp::SqlVal &,const Upp::SqlSet &)'
 c:\uppdev\uppsrc\sql\Sqlexp.h(308): or 'Upp::SqlBool Upp::operator ==(const Upp::SqlVal &,const Upp::SqlVal &)'
 while trying to match the argument list '(Upp::SqlId, Upp::SqlSelect)'
 
 | 
 [Updated on: Sat, 28 June 2008 23:37] Report message to a moderator |  
	|  |  |  
	|  |  
	|  |  
	| 
		
			| Re: Some Sql addidtions [message #16585 is a reply to message #16584] | Sun, 29 June 2008 21:03   |  
			|  |  
	| | luzr wrote on Sun, 29 June 2008 19:15 |  | 
 | tojocky wrote on Sat, 28 June 2008 17:30 |  | Thank you Mirek! I like this "low level" query!
 
 I tried to compile example package and get folow error:
 
 
 | Quote: |  | C:\uppdev\examples\SQLApp\query.cpp(17) : error C2593: 'operator ==' is ambiguous
 c:\uppdev\uppsrc\sql\Sqlexp.h(346): could be 'Upp::SqlBool Upp::operator ==(const Upp::SqlVal &,const Upp::SqlSet &)'
 c:\uppdev\uppsrc\sql\Sqlexp.h(308): or 'Upp::SqlBool Upp::operator ==(const Upp::SqlVal &,const Upp::SqlVal &)'
 while trying to match the argument list '(Upp::SqlId, Upp::SqlSelect)'
 
 | 
 
 | 
 
 Please, when posting a problem like this, mention the compiler (and platform, but it is obvious here
  
 Mirek
 
 | 
 Sorry!
 
 platform is Win32 xp, Compiler is MSC8 optimal!
 |  
	|  |  |  
	| 
		
			| Re: Some Sql addidtions [message #16586 is a reply to message #16562] | Mon, 30 June 2008 09:15   |  
			| 
				
				|  |  mirek Messages: 14271
 Registered: November 2005
 | Ultimate Member |  |  |  
	| | unodgs wrote on Thu, 26 June 2008 08:56 |  | Recently I made possible to write select in select fields list:
 
 
SQL * ::Select(
   ID, 
   NAME, 
   ::Select(NAME, AGE).From(PARENTS).Where(KID_ID == ID),
   PHONE
).From(KIDS)
..and conditions
 
 
SQL * ::Select(
  X == Y,
  NUMBER < 100,
).From(TABLE)
SqlNvl has now As() method so it's possible to write:
 
 
SQL * ::Select(
   (QUANTITY * PRICE).As(FINAL_PRICE)
   (NAME | SURNAME).As(FULL_NAME)
).From(PRICES)
It's also possible to write cases:
 
 
SQL * ::Select(
  ID,
  Case(AGE < 5, "Baby")
      (Between(AGE, 5, 10), "Kid")
      ("Young man"),
  NAME
.From(PERSONS)
 
 | 
 
 Well, you have broken SqlExp in the process
  
 
 
/*
SqlVal::SqlVal(const SqlSelect& x) {
	SetHigh('(' + ((SqlStatement) x).GetText() + ')');
}
SqlVal::SqlVal(const SqlBool& x) {
	SetHigh(~x);
}
*/
 I had to comment these, otherwise I am getting a lot of errors like the one tojocky mentions.
 
 Mirek
 |  
	|  |  |  
	|  |  
	| 
		
			| Re: Some Sql addidtions [message #16589 is a reply to message #16587] | Mon, 30 June 2008 12:05   |  
			|  |  
	| | luzr wrote on Mon, 30 June 2008 03:36 |  | Well, to avoid this situation in the future, I have moved my "SqlExp documentation examples" package to reference/SqlExp.
 
 This should have two nice purposes:
 
 When you add something new to SqlExp, add example of it to this package. And, by compiling it, there should be a bit of safeguarding against these kinds of bugs...
 
 Mirek
 
 | 
 Good idea. I'll try to fix that (In my app there are so many sqls so I thought I hadn't broken anything..)
 |  
	|  |  |  
	| 
		
			| Re: Some Sql addidtions [message #16593 is a reply to message #16589] | Mon, 30 June 2008 21:04   |  
			|  |  
	| Another solution (at least for SqlApp) is to comment 
 
inline SqlBool operator==(const SqlVal& a, const SqlSet& b) { return In(a, b); }
inline SqlBool operator!=(const SqlVal& a, const SqlSet& b) { return NotIn(a, b); }
and using directly In or NotIn instead of SqlVal !=/== SqlSet. IMO it's more readable, but for now I'll leave it as it is. I'll try to find solution without compromise.
 |  
	|  |  |  
	|  | 
 
 
 Current Time: Thu Oct 30 19:17:19 CET 2025 
 Total time taken to generate the page: 0.04709 seconds |