You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Eric Kelm <er...@vsgadmin.com> on 2006/03/24 04:15:47 UTC

Subqueries in ODMG query

Is it possible to use a subquery inside of an ODMG query e.g.

select jobs from " + JobBO.class.getName();
where employees_idemployee = " + employee.getIdEmployee();
idjob like $1 or idtask_code like
	(select task_codes from " + TaskCodeBO.class.getName();
    	 where task_code_name like $2
	)

If this is not correct syntax (seems not to be) can someone point me in the
right direction? Thanks



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


RE: Subqueries in ODMG query

Posted by Eric Kelm <er...@vsgadmin.com>.
Thanks, but I was looking for something using ODMG-API, not PB-API. I did
find this test case and my query looks similar except that I have 2
different object types in my query.

/**
  +     * test Subquery
  +     * get all articles with price > avg(price)
  +     * PROBLEM: avg(price) is NOT extent aware !!
  +     *
  +     * test may fail if db does not support sub queries
  +     */
  +    public void _testSubQuery1() throws Exception
  +    {
  +        Implementation odmg = OJB.getInstance();
  +        Database db = odmg.newDatabase();
  +        db.open(databaseName, Database.OPEN_READ_WRITE);
  +
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +     
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select anArticle from " + 
  +                Article.class.getName() + 
  +                " where " + 
  +                " price >= (select avg(price) from " + 
  +                Article.class.getName() +
  +                " where articleName like \"A%\") ");
  +
  +        List results = (List) query.execute();
  +        tx.commit();
  +        assertTrue(results.size() > 0);
  +        db.close();
  +    } 

->-----Original Message-----
->From: Vasily Ivanov [mailto:basil.iv@gmail.com] 
->Sent: Thursday, March 23, 2006 9:22 PM
->To: OJB Users List
->Subject: Re: Subqueries in ODMG query
->
->http://db.apache.org/ojb/docu/guides/query.html#subqueries
->
->On 3/24/06, Eric Kelm <er...@vsgadmin.com> wrote:
->> Is it possible to use a subquery inside of an ODMG query e.g.
->>
->> select jobs from " + JobBO.class.getName(); where 
->employees_idemployee 
->> = " + employee.getIdEmployee(); idjob like $1 or idtask_code like
->>        (select task_codes from " + TaskCodeBO.class.getName();
->>         where task_code_name like $2
->>        )
->>
->> If this is not correct syntax (seems not to be) can someone 
->point me 
->> in the right direction? Thanks
->>
->>
->>
->> 
->---------------------------------------------------------------------
->> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
->> For additional commands, e-mail: ojb-user-help@db.apache.org
->>
->>
->
->---------------------------------------------------------------------
->To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
->For additional commands, e-mail: ojb-user-help@db.apache.org
->
->
->



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


Re: Subqueries in ODMG query

Posted by Vasily Ivanov <ba...@gmail.com>.
http://db.apache.org/ojb/docu/guides/query.html#subqueries

On 3/24/06, Eric Kelm <er...@vsgadmin.com> wrote:
> Is it possible to use a subquery inside of an ODMG query e.g.
>
> select jobs from " + JobBO.class.getName();
> where employees_idemployee = " + employee.getIdEmployee();
> idjob like $1 or idtask_code like
>        (select task_codes from " + TaskCodeBO.class.getName();
>         where task_code_name like $2
>        )
>
> If this is not correct syntax (seems not to be) can someone point me in the
> right direction? Thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

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


RE: Subqueries in ODMG query

Posted by Eric Kelm <er...@vsgadmin.com>.
Sorry mistyped

Is it possible to use a subquery inside of an ODMG query e.g.

select jobs from " + JobBO.class.getName(); where employees_idemployee = " +
employee.getIdEmployee() + " and (idjob like $1 or idtask_code like
	(select task_codes from " + TaskCodeBO.class.getName();
    	 where task_code_name like $2
	))

If this is not correct syntax (seems not to be) can someone point me in the
right direction? Thanks



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