Author |
Message
|
SN_IIB |
Posted: Mon Jul 21, 2014 3:56 am Post subject: Compute Node - frame DB query dynamically |
|
|
Novice
Joined: 20 Jul 2014 Posts: 10
|
Dear Experts,
I am using esql Compute node to fetch a record from Database. I would like to dynamically frame the where clause depending on whether the fields in request sent to esql Compute node is null or not.
I placed a DB query with static where clause in esql Compute node and it worked successfully, but could not get hold how to frame it dynamically.
Please can you share your inputs?
Thanks.
Last edited by SN_IIB on Wed Feb 04, 2015 2:20 am; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 21, 2014 5:09 am Post subject: Re: Compute Node - frame DB query dynamically |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
SN_IIB wrote: |
Please can you share your inputs? |
That's what you do; share the inputs.
If your query becomes complex, you may find it's more maintainable to build the query string directly in ESQL and use PASSTHRU, accepting the costs to performance. Judgement call on your part there. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
SN_IIB |
Posted: Mon Jul 21, 2014 6:09 am Post subject: |
|
|
Novice
Joined: 20 Jul 2014 Posts: 10
|
Thanks.
I understand the Performance part.
Mine is a simple select query, so I don't foresee any issue. But what I am looking for in this thread is how to technically dynamically frame the where clause in the query.
Last edited by SN_IIB on Wed Feb 04, 2015 2:20 am; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jul 21, 2014 6:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
it depends on what you mean by 'dynamically frame the where clause'.
It's easy to use ? for WHERE A=? and B=?
but if you need to say WHERE ?=?, then you have to use passthrough. |
|
Back to top |
|
 |
SN_IIB |
Posted: Tue Jul 22, 2014 9:14 am Post subject: |
|
|
Novice
Joined: 20 Jul 2014 Posts: 10
|
Thanks for your inputs.
Yes I would like to frame WHERE clause in such a way that
WHERE FIELD1=x1 AND FIELD2=y1 AND FIELD3=z1. If value x1 = null, then my WHERE clause should be WHERE FIELD2=y1 AND FIELD3=z1. If the values x1=null and y1=null, then my WHERE clause should be WHERE FIELD3=z1.
In the WHERE clause mentioned above, values x1, y1 and z1 are received from a SOAP Request and passed on as input to the Compute node ESQL code.
I checked the Passthrough node as suggested, but I could not visualize how I can use it for my scenario.
Please can you help me with more pointers? |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 22, 2014 9:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
SN_IIB wrote: |
I checked the Passthrough node as suggested, but I could not visualize how I can use it for my scenario. |
PASSTHRU ESQL statement. Not the Passthru node. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|