Skip to main content
Solved

Sampler and looping - chunking up inputs to SQL Executor

  • May 10, 2024
  • 2 replies
  • 59 views

p_c_20
Supporter
Forum|alt.badge.img+9

I am running a call to an Oracle DB based upon an input ID as a feature attribute value coming in from a CSV. There are upwards of 2000 ID’s to process. Initially, that call was running on a per-feature basis; I am now trying to make this more performant by using the IN statement e.g. WHERE ID IN (‘1’, ‘2’, ‘3’). I am doing this by aggregating incoming ID’s into one attribute value. 

Where this falls flat is that there appears to be a limit on items that Oracle can cope with in an ‘IN’ statement, so I figured I would chunk it up into more manageable numbers. 

My first thought was to create a looping transformer. My conception of this would be that a Counter would increment a Sampler to take the first 500 records (X), then the X+1 group of 500 (e.g. values 501 to 1001), X=2 and so on, until the _matched_records result coming out of SQL Executor was 0, at which point a tester in line would fail. 

However, Sampler doesn’t support that kind of expression building (as far as I can see). Any ideas? I’m wondering about lists. 

(Googling suggests reading ID’s from a prepared table in Oracle, but that isn’t an option.)

Best answer by david_r

Indeed, Oracle has a max length for SQL statements,

You can e.g. use the Grouper from @redgeographics set to a suitable group size and aggregate / concatenate the values based on the resulting value.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • Best Answer
  • May 10, 2024

Indeed, Oracle has a max length for SQL statements,

You can e.g. use the Grouper from @redgeographics set to a suitable group size and aggregate / concatenate the values based on the resulting value.


p_c_20
Supporter
Forum|alt.badge.img+9
  • Author
  • Supporter
  • May 10, 2024

Indeed, Oracle has a max length for SQL statements,

You can e.g. use the Grouper from @redgeographics set to a suitable group size and aggregate / concatenate the values based on the resulting value.

Ah! A simple and elegant solution. Many thanks. 🙏