db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter riegersperger <r...@subnet.at>
Subject Re: Count(*) and criteria
Date Sun, 02 Feb 2003 22:31:12 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 02 February 2003 23:15, Scott Eade wrote:
> Try something like:
>
> Criteria c = new Criteria();
> c.addSelectColumn("COUNT(" + colName + ")");
> List result = doSelect();
> Record rec = (Record) result.get(0);
> int count = rec.getValue(1).asInt();

i tried. the problem is that i need the exact criteria as in the original 
query, for example:

(ahemm  - please note that i don't actually name my methods like this)
getListAndRecordCountFromGivenCriteria (Criteria crit)
{
ThisPeer.doSelect(crit);
[...]
crit.addSelectColumn("Count(*)");
[...]

fails because all the column names are written into the SELECT-clause as soon 
as ThisPeer.doSelect(Criteria) is called.
so, i get a SQL-statement like:
SELECT myTable.ID, myTable.Name, Count(*) FROM myTable;

i could get this whole thing working if there was a way to remove 
SelectColumns.

> Where colName is the name of some small column in the table (can't remember
> why, but "*" doesn't work when the query is done this way).

ok, thanks for that hint!

> BTW: Have you looked at LargeSelect?

no. but i will.

thanks,

rick


- -- 
|-
| peter riegersperger  <rick@subnet.at>
|-
| ein windows switcher tagebuch:
| http://forum.subnet.at/viewforum.php?f=22
|-
| subnet
| platform for media art and experimental technologies
|-
| http://www.subnet.at/
|-
| muehlbacherhofweg 5 // 5020 salzburg // austria
|-
| fon/fax +43/662/842 897
|- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+PZwwIMP39JYOy9IRAvGiAJ9pSyLUoqljZI1xgdM3J3VWQ8QX5wCgiw/d
GPgcN5Nl8AhtUp8BRSamVes=
=GjO0
-----END PGP SIGNATURE-----


Mime
View raw message