select Ebo_PerfExecuting this query in the XEOQL Console (available in every XEO Application's Administration Viewer) provides the following results:
select LIB_Book.publisherThe previous query will return a list of all LIB_Publisher instances that are related to a LIB_Book instance (if one wanted only the publisher of a given book, you would need a where clause, which will be discussed in the next section). To select all LIB_BookCategory instances associated to any given book, the following query could be used
select LIB_Book.categoriesYou can go further down the hierarchy, like selecting all publisher nucleus from publishers that are related to book instance with the following query:
select LIB_Book.publisher.nucleusDot syntax can be used continually as long as the attributes being selected are of type object or collection.
WHERE whereStatement (AND | OR whereStament)*The whereStatament expression encapsulates all the possible combinations for valid expressions which can be created using the following elements:
, >, <, >
, <=, like, is null, etc...)
select LIB_Book where title = 'Da Vinci Code'One could also explicitly refer the Object Model being selected in the expression, like the following:
select LIB_Book where LIB_Book.title = 'Da Vinci Code'One can use attributes from instances with which the first is related, for example to select all books which were published by "Wrox".
select LIB_Book WHERE LIB_Book.publisher.name = 'Wrox'or
select LIB_Book WHERE publisher.name = 'Wrox'Beware that when selecting object instances through an attribute (i.e. selecting LIB_Publisher instances by using LIB_Book.publisher) the context for the where clause is that of the of the first Object Model. So if you make the following (wrong) query to select all publishers with a name similar to "Wrox" that have a book published it will fail with an error:
select LIB_Book.publisher where name Like '%Wrox%'The error generated from the query is the following:
QLParser:XEO.QL:null Base Error:Not a valid attribute select LIB_book.publisher where<strong>[name]</strong> Like '%Wrox%'The error occurs because, although the publisher (of the LIB_Publisher Object Model) has an attribute name, in BOQL the context for the where clause is always that of the first Object Model selected, in this case, LIB_Book. In order to make this query correct you would have to refer to the publisher name by prefixing it with "publisher." so that the XEOQL Parser knows that the "name" attribute is from the publisher and not from the book. The correct query would be the following:
select LIB_Book.publisher where publisher.name like '%Wrox%'Another important issue is when comparing to an attribute that is relation. The following two queries are equivalent:
select LIB_Book.publisher where publisher.boui = 111111 select LIB_Book.publisher where publisher = 111111When comparing to a relation attribute you're comparing with its BOUI attribute. _
Literal Type | Usage![]() |
Notes |
---|---|---|
Date | to_date('5/5/2010','DD-MM-YYYY') | When comparing dates, it's required to use the to_date function, which will converted the date to the internal representation of the database |
Number | 12345 | |
Duration | 12345 | |
String | 'String' |
select LIB_Movement where (fine * 10) / 100 > 200The four arithmetic operators are available (sum, subtraction, mutiplication and division)
Operator | Description | Example |
---|---|---|
= | Equality operator | 1 = 1 |
> | Bigger than operator | salary > 1000 |
< | Less than operator | value < 100 |
<= | Bigger or equal than operator | salary >= 200 |
>= | Less or equal than operator | value <= 100 |
<> | Different operator (not equal) | salary <> 1000 (salary not equal to 1000) |
! | Different operator (alias to <>) | salary ! 1000 |
Like | Allows to compare strings with wildcards | name like "XEO%" name not like "XEO %" |
Startswith | Restricts attributes that start with a given character | name startswith "A" name startswith "#" |
In | Retricts arguments to the ones in the following subqueries | boui in (select Object where value > 3) boui not (select Object where value > 3) |
Is Null | Evaluates if the argument does have a value | Name is null Name is not null |
Not | Negates a condition | Name not null |
select Foo where Contains('bar')You could also use wildcard matching*, such as:
select Foo where Contains('bar%')which would match Foo instances which have words started with "bar"*. *Note: Wildcard matching is database dependent. The "contains" clause will be converted to the underlying database's function to make full text searches. In Oracle databases the '%' wildcard can be used in XEOQL expressions (with the contains clause), while Mysql uses the '*' wildcard in its "MATCH" function. When using the contains clause, be sure to read the documentation of your database about wildcard text searching.
To select all books instances ordered by the publisher's name and then by title, the following query would do.select LIB_Book order by title ASC
select LIB_Book order by publisher.name,title ASC__
And later, bind the parameter to a value. To use parameters, the are methods in the ObjectListManager which allow you to pass a XEOQL expression and an array of Objects (the values for the parameters) and will execute your expression with the defined bindings. For example.select LIB_Book where title = ?
EboContext ctx = //get an EboContext boObjectList results = ObjectListManager.list(ctx, "select LIB_Book where title = ? and ISBN = ?", new Object[] {"Da Vinci Code", 11344444});__
SELECT USING SYSUSER/ABC Ebo_PerfThe results will be all Ebo_Perf instances that the SYSUSER user would see when executing the select Ebo_Perf query.
Constant | Description |
---|---|
CTX_PERFORMER_BOUI | The boui of the user which is executing the query, when you use this in a XEOQL expression it will be automatically replaced by the user's BOUI. |
![TODO TODO](/pub/TWiki/TWikiDocGraphics/todo.gif)
I | Attachment | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|
![]() |
XEOQL-Console.png | manage | 13.4 K | 2011-01-04 - 17:52 | PedroRio | XEOQL Console - Simple Query |