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 » Count error
Count error [message #17592] Thu, 21 August 2008 19:37 Go to next message
TeCNoYoTTa is currently offline  TeCNoYoTTa
Messages: 138
Registered: July 2008
Location: Egypt
Experienced Member

hello

what is the proplem with this statment
	SQL*Select(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR
			   ,Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID && IS_DOWNLOADED == true))
			   ,Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID)));
Re: Count error [message #17593 is a reply to message #17592] Thu, 21 August 2008 19:49 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
If you use an Aggregate Function like Count(), you have to specify an Aggregate grouping using something like GroupBy()
SQL*Select(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR,Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID && IS_DOWNLOADED == true)),
Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID))).GroupBy(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR);

This is an SQL requirement, not U++...
Re: Count error [message #17613 is a reply to message #17593] Fri, 22 August 2008 14:14 Go to previous messageGo to next message
TeCNoYoTTa is currently offline  TeCNoYoTTa
Messages: 138
Registered: July 2008
Location: Egypt
Experienced Member

thanks but i wrote this

	SQL*Select(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR
			   ,Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID && IS_DOWNLOADED == true))
			   ,Count(Select(SqlAll()).From(FILES).Where(FILE_ITEM_ID == ITEM_ID))).GroupBy(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR);


and these errors happened

D:\Program Files\MyApps\CISL\main.cpp:240: error: invalid initialization of reference of type 'const Upp::SqlVal&' from expression of type
	 'Upp::SqlSelect'
D:\Program Files\upp\uppsrc/Sql/Sqlexp.h:216: error: in passing argument 1 of 'Upp::SqlVal Upp::Count(const Upp::SqlVal&)'
D:\Program Files\MyApps\CISL\main.cpp:241: error: invalid initialization of reference of type 'const Upp::SqlVal&' from expression of type
	 'Upp::SqlSelect'
D:\Program Files\upp\uppsrc/Sql/Sqlexp.h:216: error: in passing argument 1 of 'Upp::SqlVal Upp::Count(const Upp::SqlVal&)'
Re: Count error [message #17616 is a reply to message #17613] Fri, 22 August 2008 15:29 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Your going to have to break that statement up and figure out where the error is happening. I can't simply tell from that information, but I have a feeling it is because you are using the SQL object and haven't assigned a database or something like that.

[Updated on: Fri, 22 August 2008 15:30]

Report message to a moderator

Re: Count error [message #17652 is a reply to message #17613] Sun, 24 August 2008 20:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ops, seems that this variant is not supported.

Have you tried

SQL*Select(ITEM_ID,ITEM_TITLE,ITEM_AUTHOR, Select(Count(SqlAll()))

?

(it should be the same thing...)

Anyway, this seems to be a bug. Parameter of Count should rather be SqlSet...

Mirek
Re: Count error [message #17653 is a reply to message #17652] Sun, 24 August 2008 20:35 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ok, hopefully fixed. Will be on svn within hour.

(Fix: add this function:

SqlVal Count(const SqlSet& exp)
{
return SqlFunc("count", exp);
}

)

Mirek
Previous Topic: PostgreSQL Attribute Foreign Key --> Bug?
Next Topic: SQLCommander make program crash
Goto Forum:
  


Current Time: Fri Apr 19 09:40:55 CEST 2024

Total time taken to generate the page: 0.05568 seconds