Skip to main content
Question

Process one feature at a time

  • May 22, 2024
  • 2 replies
  • 292 views

sunsilk11
Contributor
Forum|alt.badge.img+6

Hi,

I have multiple features, for each I need use an Oracle sequence to get the ID of the feature.

Then I need to write the feature to the database. The ID must be unique.

I have used a SQLExecutor to obtain the sequence next value. 

I am struggling when there are multiple features to write. FME is executing the SQLExecutor multiple times before getting single value for the ID. 

I need to process each feature at a time i.e. run through SQLExecutor, get the feature ID and write feature to database, then proceed to next feature.

 

Any suggestions ?

 

 

2 replies

daveatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • May 22, 2024

Hi @sunsilk11,

Use a Sampler transformer to extract the first feature, then send it to the SQLExecutor to get the last Oracle sequence number. Use a FeatureMerger to merge that value on all the other features, then use that value as the Count Start in a Counter to create subsequent sequence values for all the features.

I am attaching a workspace snippet to illustrate.


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • May 23, 2024

I suspect the Oracle sequence will get out of sync this way, as you perform sequence_name.NEXTVAL once (in the SQLExecutor), but write many records to the database, each with its own unique ID.

This could be handled directly in Oracle, by firing a trigger that gets sequence_name.NEXTVAL when a record is inserted into the table.