Skip to main content
Solved

Sampler and looping - chunking up inputs to SQL Executor


p_c_20
Contributor
Forum|alt.badge.img+8

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.

View original
Did this help you find an answer to your question?

2 replies

david_r
Evangelist
  • 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
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • May 10, 2024
david_r wrote:

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. 🙏


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings