Strange result from IN Statement

0 views
Skip to first unread message

Clarkee21

unread,
Dec 16, 2009, 6:28:17 PM12/16/09
to transfer-dev
Hi again,

I'm trying to query Transfer based on a list of user IDs that I have.
Oddly though Transfer isn't giving me the result back I expect.

Here's my code...

listOfUsers = '14750309,9179162,14750303';
tql = 'select user.id, user.milestone, user.emailFlag, user.name
from user where user.id NOT IN (:list)';
query = application.transfer.createQuery(tql);
query.setParam('list',listOfUsers,'list');
qryUsers = application.transfer.listByQuery(query);

This should actually give me an empty recordset because I've only got
these 3 users, however the dump shows me the 2nd and 3rd result.

The SQL being generated when I try it in mySQL works fine but from my
reading up on TQL this querying against the objects (?) not the
Database but these users. These are all in the cache but still why am
I getting results when I shouldn't be?

Can I just say though I think Transfer is very cool so far :-). It's
great to see all the extra code I had before just disappear. Great
job :-)

Thanks a lot,
James

Clarkee21

unread,
Dec 16, 2009, 6:35:35 PM12/16/09
to transfer-dev
Ummm, actually mySQL is truncating it if I wrap the numbers in quotes.
I'm then getting the same result as Transfer. Guess it's my syntax
then.

Cheers,
James

Elliott Sprehn

unread,
Dec 17, 2009, 3:42:00 AM12/17/09
to transfer-dev

Use the type argument to setParam() to tell it that they're numbers.

Clarkee21

unread,
Dec 20, 2009, 4:31:34 PM12/20/09
to transfer-dev
Thanks Elliot,

That didn't seem to work for me but your comment about the arguments
made me a have a closer look at the setParam() in the docs and noticed
a "list" argument. Set that to true and it's now working :-)

Code is now...

tql = 'select user.id, user.milestone, user.emailFlag, user.name
from user where user.id NOT IN (:list)';
query = application.transfer.createQuery(tql);

query.setParam('list',listOfUsers,'list',true);
qryUsers = application.transfer.listByQuery(query);


Thanks again,
James

Reply all
Reply to author
Forward
0 new messages