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 » Is this correct?
Is this correct? [message #8577] Mon, 19 March 2007 21:00 Go to next message
MikeyV is currently offline  MikeyV
Messages: 20
Registered: February 2007
Promising Member
Is this the correct way to use SqlSum?

SQL * Select(SqlSum(PS)).From(AreaMission);


I get garbage in SQL[0]
Re: Is this correct? [message #8579 is a reply to message #8577] Tue, 20 March 2007 00:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Did you SQL.Fetch()?

There is also shorter form using operator%:

x = SQL % Select(SqlSum(PS)).From(AreaMission);


Mirek
Re: Is this correct? [message #8581 is a reply to message #8577] Tue, 20 March 2007 01:44 Go to previous messageGo to next message
MikeyV is currently offline  MikeyV
Messages: 20
Registered: February 2007
Promising Member
Quote:

Did you SQL.Fetch()?



No, I wasn't sure how. Is it like:
SQL * Select(SqlSum(PS)).From(AreaMission);
while(SQL.Fetch())
    x += SQL[0];


I also didn't realize that those were operators (ie. *, %, &) and I don't really know what they do. I will study the SQL header file and try to figure out what they do.

I will use that short form.

Thanks (again) Mirek!
Re: Is this correct? [message #8585 is a reply to message #8579] Tue, 20 March 2007 08:26 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

luzr wrote on Mon, 19 March 2007 19:22

Did you SQL.Fetch()?

There is also shorter form using operator%:

x = SQL % Select(SqlSum(PS)).From(AreaMission);


Mirek

WOW! That's something new.
Re: Is this correct? [message #8586 is a reply to message #8581] Tue, 20 March 2007 10:12 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
MikeyV wrote on Mon, 19 March 2007 20:44

Quote:

Did you SQL.Fetch()?



No, I wasn't sure how. Is it like:
SQL * Select(SqlSum(PS)).From(AreaMission);
while(SQL.Fetch())
    x += SQL[0];




Yes Smile

Sure, we still owe everybody the nice SQL tutorial...

BTW, while above code is OK, I do not recommend using SQL with Fetch - it is global variable and way too often you can make a mistake here (by issuing another query on the same SQL).

So if you are going to Fetch, rather use:

Sql sql;
sql * Select(...
while(sql.Fetch())


Mirek
Previous Topic: An improvement to SqlArray::PerformInsert
Next Topic: Sqlite3 Forcing creating a database
Goto Forum:
  


Current Time: Sun Apr 28 22:10:19 CEST 2024

Total time taken to generate the page: 0.04428 seconds