You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Felipe Ramos <fr...@tissat.es> on 2003/11/12 09:45:27 UTC

Select count(*)

Hi all,
   
    How can I make a "Select count(*) from Customer where customerId='1' 
"  query using Torque 3.1 ?

    ( I know that one possibility is use the Criteria.CUSTOM but..... )

Toru Suzuki wrote:

>Hi all,
>
>I used Torque3.0 and oracle
>
>I'm trying to do
>
>String note = "\*comment";
>Criteria cri = new Criteria();
>cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
>
>SQL log is
>SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
>WHERE PERSON.NOTE LIKE '\comment%'
>
>I expected 
>WHERE PERSON.NOTE LIKE '*comment%'
>
>SqlExpression.buildLike(String columnName,String criteria,SqlEnum 
>comparison,boolean ignoreCase,DB db,StringBuffer whereClause)
>javadoc wrote
>criteria = "50\%" -> columnName = '50%'
>
>Why???
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>  
>

-- 
------------------------
Felipe Ramos
Tissat SA
C/ Orense 34-9ª
28020 Madrid
Tel: (+34) 91 4175913 
Fax: (+34) 91 4172914
Mail: framos@tissat.es
------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Select count(*)

Posted by Felipe Ramos <fr...@tissat.es>.
I agree with you in the fact that  doSelect, and list.size() is  a waste 
of server resources, and that is the reason to look for a Criteria to 
make the query: select count(*) from customer where customerName='James' 
  , but, what Criteria?



Yes, the bottton of my last  message was a mistake. :-)

Josh Holtzman wrote:

> One way is to select the objects you want using Criteria and 
> CustomerPeer.doSelect, which returns a list of Customers matching your 
> criteria (customerId=1).  Once you have the list, list.size() returns 
> the number of Customers returned, which is what you want.  But if you 
> didn't want the list of Customer objects at all, than instantiating 
> all of these objects is a waste of server resources.
>
> Also -- is your message a reply to the message regarding the \*comment 
> query (bottom of this message)?  I don't see the connection.
>
> Josh
>
> Felipe Ramos wrote:
>
>> Hi all,
>>      How can I make a "Select count(*) from Customer where 
>> customerId='1' "  query using Torque 3.1 ?
>>
>>    ( I know that one possibility is use the Criteria.CUSTOM but..... )
>>
>> Toru Suzuki wrote:
>>
>>> Hi all,
>>>
>>> I used Torque3.0 and oracle
>>>
>>> I'm trying to do
>>>
>>> String note = "\*comment";
>>> Criteria cri = new Criteria();
>>> cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
>>>
>>> SQL log is
>>> SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
>>> WHERE PERSON.NOTE LIKE '\comment%'
>>>
>>> I expected WHERE PERSON.NOTE LIKE '*comment%'
>>>
>>> SqlExpression.buildLike(String columnName,String criteria,SqlEnum 
>>> comparison,boolean ignoreCase,DB db,StringBuffer whereClause)
>>> javadoc wrote
>>> criteria = "50\%" -> columnName = '50%'
>>>
>>> Why???
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>
>>>
>>>  
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>

-- 
------------------------
Felipe Ramos
Tissat SA
C/ Orense 34-9ª
28020 Madrid
Tel: (+34) 91 4175913 
Fax: (+34) 91 4172914
Mail: framos@tissat.es
------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Select count(*)

Posted by Josh Holtzman <jo...@joshholtzman.com>.
One way is to select the objects you want using Criteria and 
CustomerPeer.doSelect, which returns a list of Customers matching your 
criteria (customerId=1).  Once you have the list, list.size() returns 
the number of Customers returned, which is what you want.  But if you 
didn't want the list of Customer objects at all, than instantiating all 
of these objects is a waste of server resources.

Also -- is your message a reply to the message regarding the \*comment 
query (bottom of this message)?  I don't see the connection.

Josh

Felipe Ramos wrote:

> Hi all,
>      How can I make a "Select count(*) from Customer where 
> customerId='1' "  query using Torque 3.1 ?
>
>    ( I know that one possibility is use the Criteria.CUSTOM but..... )
>
> Toru Suzuki wrote:
>
>> Hi all,
>>
>> I used Torque3.0 and oracle
>>
>> I'm trying to do
>>
>> String note = "\*comment";
>> Criteria cri = new Criteria();
>> cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
>>
>> SQL log is
>> SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
>> WHERE PERSON.NOTE LIKE '\comment%'
>>
>> I expected WHERE PERSON.NOTE LIKE '*comment%'
>>
>> SqlExpression.buildLike(String columnName,String criteria,SqlEnum 
>> comparison,boolean ignoreCase,DB db,StringBuffer whereClause)
>> javadoc wrote
>> criteria = "50\%" -> columnName = '50%'
>>
>> Why???
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
>>  
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Select count(*)

Posted by Tulsi Das <qu...@yahoo.com>.
I use something like this:

Criteria crit = new Criteria();
crit.addSelectColumn("count(*)");
crit.add(CustomerPeer.NAME, "james");

Record result = 
  (Record) CustomerPeer.doSelectVillageRecords(crit).get(0);

if (!result.getValue(1).isNull()) {
  int count = result.getValue(1).asInt();
}

try it and tell me if it worked!

 --- Felipe Ramos <fr...@tissat.es> escribió: 
> Excuse is a bad example, let's think in: Select count(*) from
> customer 
> where customerName='James'
> 
> Felipe Ramos wrote:
> 
> > Hi all,
> >      How can I make a "Select count(*) from Customer where 
> > customerId='1' "  query using Torque 3.1 ?
> >
> >    ( I know that one possibility is use the Criteria.CUSTOM
> but..... )
> >
> > Toru Suzuki wrote:
> >
> >> Hi all,
> >>
> >> I used Torque3.0 and oracle
> >>
> >> I'm trying to do
> >>
> >> String note = "\*comment";
> >> Criteria cri = new Criteria();
> >> cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
> >>
> >> SQL log is
> >> SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
> >> WHERE PERSON.NOTE LIKE '\comment%'
> >>
> >> I expected WHERE PERSON.NOTE LIKE '*comment%'
> >>
> >> SqlExpression.buildLike(String columnName,String criteria,SqlEnum 
> >> comparison,boolean ignoreCase,DB db,StringBuffer whereClause)
> >> javadoc wrote
> >> criteria = "50\%" -> columnName = '50%'
> >>
> >> Why???
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: torque-user-help@db.apache.org
> >>
> >>
> >>  
> >>
> >
> 
> -- 
> ------------------------
> Felipe Ramos
> Tissat SA
> C/ Orense 34-9ª
> 28020 Madrid
> Tel: (+34) 91 4175913 
> Fax: (+34) 91 4172914
> Mail: framos@tissat.es
> ------------------------
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>  

------------
¡Ayudá a los chicos navegando!
En noviembre, Yahoo! dona un plato de comida por cada nuevo usuario que nevegue gratis con Yahoo! Conexión.
Conectate ya en http://conexion.yahoo.com.ar

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Select count(*)

Posted by Felipe Ramos <fr...@tissat.es>.
Excuse is a bad example, let's think in: Select count(*) from customer 
where customerName='James'

Felipe Ramos wrote:

> Hi all,
>      How can I make a "Select count(*) from Customer where 
> customerId='1' "  query using Torque 3.1 ?
>
>    ( I know that one possibility is use the Criteria.CUSTOM but..... )
>
> Toru Suzuki wrote:
>
>> Hi all,
>>
>> I used Torque3.0 and oracle
>>
>> I'm trying to do
>>
>> String note = "\*comment";
>> Criteria cri = new Criteria();
>> cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
>>
>> SQL log is
>> SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
>> WHERE PERSON.NOTE LIKE '\comment%'
>>
>> I expected WHERE PERSON.NOTE LIKE '*comment%'
>>
>> SqlExpression.buildLike(String columnName,String criteria,SqlEnum 
>> comparison,boolean ignoreCase,DB db,StringBuffer whereClause)
>> javadoc wrote
>> criteria = "50\%" -> columnName = '50%'
>>
>> Why???
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
>>  
>>
>

-- 
------------------------
Felipe Ramos
Tissat SA
C/ Orense 34-9ª
28020 Madrid
Tel: (+34) 91 4175913 
Fax: (+34) 91 4172914
Mail: framos@tissat.es
------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org