ART#210 - What is Repository Query Language (RQL) in ATG ?

Before we jump unto querying the ATG repository, we must understand the ATG's RQL (Repository Query Language). It is similar to your standard SQL with some changes and extra stuff.

Now, the first question which pops up into our minds is that : "RQL is fine.. but where and how do we use this?? ". Let us see that

We can write RQLs in the form of strings and fetch the data from our repository using one of the following:-

1. Java Code in ATG's codebase.
2. Dynamo Administration Module (a.k.a the infamous dyn/admin)
3. Some ATG's servlet beans (or simply some OOTB Droplets)

We will have detailed article for all three cases, but for now, we will focus on how we write RQLs.

What is ATG's RQL?

RQL stands for Repository Query Language, which is used for querying ATG's repositories (both versioned and non-versioned). The syntax is pretty much similar to that of SQLs of various databases and is written in the form of strings. These RQL strings are executed using any of the methods listed above, and the relevant results are fetched.
We can also do nesting (to an extend) for RQL queries to fetch our desired results.

How do we write RQLs?
This is pretty easy.
Consider the OOTB item-descriptor "user" in ProfileAdapterRepository.
Here are some examples:-

a. To find all the MALE users. (Text Comparison Query)
gender = "male"

b. To find all users with age > 20 (Comparison Query)
age > 20

c. To find all MALE users with age > 20 (Logical Operator)
gender = "male" AND age > 20

d. To find all users with date of birth more than 28th February 2015
dateOfBirth > date("2015-02-28")

e. To find all users with date of birth more than 28th February 2015 (specific time)
dateOfBirth > date("2015-02-28 12:08:01 IST")

e. To find all users with homeAddress's city as DELHI ( user-item having homeAddress as a property, which itself is an item of type contactInfo) = "DELHI"

e. To find all users with homeAddress's city as DELHI or MUMBAI or CHENNAI INCLUDES ANY {"DELHI","MUMBAI","CHENNAI"}

e. To find all users with hobbies as SWIMMING and DANCING

f. To find all users with middleName as null
middleName is NULL

g. To find all users with more than 3 creditCards
count(creditCards) > 3

h. To find all users. (Yes, ALL Users.. :) )

i. To find all MALE users and order them by age in ascending order
gender = "MALE" order by age DESC

For more details, you can also have a look at ATG documentation for RQL syntax HERE.

The above RQL examples can give you an overview on how you can write RQLs. Once you are familiar with this, we can proceed onto using them.

How do we execute RQLs?
Let us discuss this in further chapters.



No comments:

Post a Comment


Get All The Latest Updates Delivered Straight Into Your Inbox For Free!