Greetings, I should read and write features one by one, namely in the feature reader I have a condition by which I retrieve data from the database, more precisely the ID. But every time I should first write a feature in the database that gets a new ID, and when reading the conditions for the second time, it should select that new ID, and not immediately select that first ID for me. how to create this?
Sounds like a pretty slow process, would not recommend… but there are always cases where it needs to be done the way it is done.
You could create a workbench that does exactly this. Read one feature from the database with a WHERE cause to select the last inserted feature and write it to the same database.
And then make a workbench with a workspaceRunner that runs the first workbench for X amount of times.
Or you could do something with a CustomTransformer and Looping, and give up after 4 hours and switch to the workspaceRunner.
If I understand, you want to insert a number of rows (without ID) in a table with an automatic ID column, and recover the resulting IDs?
That can be done if you have a unique constraint besides the ID field (which I’ll call “Name”), where you insert all your features with a FeatureWriter, read back from the same table with a FeatureReader, and join the new ID using your “Name” as the joining key.
If you don’t have that, but you can assume rows that are identical would have the same ID, the same technique works.
The “proper” way of doing this in SQL would be to use whatever equivalent of INSERT INTO RETURNING your database supports, to recover the column values of inserted rows, but that’s tricky in FME because you can only insert directly in the target table, and you can’t customize the SQL statement to return data from insertion.
See the following threads for more information