Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ESQL - how to build up a dynamic database query

613 views
Skip to first unread message

tim t

unread,
Jun 3, 2004, 6:55:26 AM6/3/04
to
Hi,

I was wondering if anyone could help me with a problem I have in ESQL
for Message Broker. I need to build up a database query dependant on
some esql variables. This can be done very easily in Java as you can
build up a string and pass it in as the query, however I dont know if
this is possible in ESQL.
An example in Java would be :-

qString = 'Select * from table1 where table1.col1=1';

if (var2!=null) {
qString = qString + ' and table1.col2= ' + var2;
}
if (var3!=null) {
qString = qString + ' and table1.col3= ' + var3;
}

Is there any way to accomplish a similar statement build in ESQL.
Many Thanks
Tim

Brian Meekings

unread,
Jun 6, 2004, 12:14:54 PM6/6/04
to
Take a look at the PASSTHRU and EVAL statements. I haven't used them,
but think you should be able to accomplish what you want.

Brian Meekings
Information Design, Inc - IBM Premier Partner
meek...@us.ibm.com
meek...@idi-middleware.com

Miriam Kaestner

unread,
Jun 17, 2004, 9:13:15 AM6/17/04
to
Better use PASSTHRU than EVAL, which brings enormous perfomance punishments.

Alternatively, you may write something like
SET Environment.myResultSet[] =
SELECT * FROM Database.table1 AS D
WHERE D.col1=1
AND ((Environment.var2 IS NOT NULL) AND D.col2 = Environment.var2)
AND ((Environment.var3 IS NOT NULL) AND D.col3 = Environment.var3);

0 new messages