RQL Statement with null value

1,109 views
Skip to first unread message

benoit.r...@gmail.com

unread,
Mar 17, 2008, 6:11:49 AM3/17/08
to ATG_Tech
Hello,

I'm facing a weird issue with ATG 7.2.
My item descriptor is a user. Each user has an unique email and
employee_id.
If I'm querying the repository with something like email = "xxx" and
employee_id = "xxx" it works, I can find user with same email/
employee_id. But if I'm querying with something like email = "xxx" and
employee_id = null ATG never finds user with same email and empty
employee_id.
It seems that ATG can't manage null value. Here is my code :

RepositoryItemDescriptor rid = null;
RepositoryView rv = null;
RqlStatement statement = null;
RepositoryItem[] items = null;
try {
rid = this.getRepository().getItemDescriptor(UTILISATEUR);
rv = rid.getRepositoryView();
String empId =
this.getValue().get(StringUtils.toUpperCase(ITEMPROPERTY_EMPLOYEE_ID)).toString().trim();
if("".equals(empId)) empId = null;
Object param[] =
{ this.getValue().get(StringUtils.toUpperCase(ITEMPROPERTY_EMAIL)).toString().trim(),
empId};
statement = RqlStatement.parseRqlStatement(ITEMPROPERTY_EMAIL + "= ?0
and "+ ITEMPROPERTY_EMPLOYEE_ID+" = ?1");
items = statement.executeQuery(rv, param);
if (items != null) {
//Do my things...
}
}
catch (Exception e) {
if (this.isLoggingError()) {
this.logError("Exception "+e);
}
}

Do you know how to solve this problem ?
Thanks to all !

quicksilver03

unread,
Mar 17, 2008, 6:44:47 AM3/17/08
to ATG_Tech
You query is wrong: if employee_id is empty the RQL should be

email = ?0 AND employee_id IS NULL

If employee_id is not empty the query should be:

email = ?0 AND employee_id = ?1

You would do a similar thing in SQL, that is you do not compare
something to NULL with the equality operator.

On Mar 17, 11:11 am, "benoit.rossig...@gmail.com"

benoit.r...@gmail.com

unread,
Mar 17, 2008, 9:11:20 AM3/17/08
to ATG_Tech
You're right it works ! I didn't think of that, thank you !
> > this.getValue().get(StringUtils.toUpperCase(ITEMPROPERTY_EMPLOYEE_ID)).toSt­ring().trim();
> >         if("".equals(empId)) empId = null;
> >         Object param[] =
> > { this.getValue().get(StringUtils.toUpperCase(ITEMPROPERTY_EMAIL)).toString()­.trim(),
> >                            empId};
> >         statement = RqlStatement.parseRqlStatement(ITEMPROPERTY_EMAIL + "= ?0
> > and "+ ITEMPROPERTY_EMPLOYEE_ID+" = ?1");
> >         items = statement.executeQuery(rv, param);
> >         if (items != null) {
> >                 //Do my things...
> >         }}
>
> > catch (Exception e) {
> >         if (this.isLoggingError()) {
> >                 this.logError("Exception "+e);
> >         }
>
> > }
>
> > Do you know how to solve this problem ?
> > Thanks to all !- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
Reply all
Reply to author
Forward
0 new messages