Hi Vera,
The WorkspaceRunner creates different fme process for each run, so I think the method described in the linked article cannot be applied in your case. One possible approach is to save the next start count value into an external file in the shutdown process, and to read it when the next process starts. Be aware that this approach works only when you specify "Yes" to "Wait for Job to Complete" parameter of the WorkspaceRunner. Main workspace 1) Define a published parameter to fetch whether the current process is the first one or not. Name: IS_FIRST_RUN Type: Choice Configuration: Yes%No 2) Define a private scripted (Python) parameter named "COUNT_START" to return the start count read from an external file. ----- import os global g_path g_path = './counter.txt' if FME_MacroValuesl'IS_FIRST_RUN'] == 'No' and os.path.exists(g_path): f = open(g_path, 'rb') n = f.readline().strip() f.close() return n if n else 0 else: return 0 ----- * You can also define the file path as another published parameter or a global variable in Startup Python Script etc.. 3) Link the "Count Start" parameter of the Counter to the "COUNT_START" parameter above. 4) Insert a PythonCaller with this script after the Counter. When the translation is completed, g_count indicates the last count. ----- import fmeobjects def updateCount(feature): global g_count g_count = int(feature.getAttribute('_count')) ----- 5) Define the Shutdown Python Script like this to save the next start count (last count + 1). ----- f = open(g_path, 'wb') f.write(str(g_count + 1)) f.close() ----- Workspace that calls the main workspace 6) When running for the first user, pass "Yes" to "IS_FIRST_RUN" parameter of the main workspace through the WorkspaceRunner. Otherwise pass "No". It's a little complicated. Hope a more elegant solution will be provided.
Takashi
Correction:
* You can also define the file path as another published parameter or a global variable in Startup Python Script etc..
Startup Python Script will be interpreted after scripted parameter, so the file path cannot be define in the startup process.
Another approach.
If you can get the number of features to be written for each user before the WorkspaceRunner, you can calculate the start count beforehand and pass it to the main workspace as a parameter. userr0]: number = nn0], startt0] = 0 userr1]: number = nn1], startt1] = startt0] + nn0] userr2]: number = nn2], startt2] = startt1] + nn1] ... userri]: number = nni], startti] = startti - 1] + nni - 1] "Multiple Feature Attribute Support" option of the AttributeCreator can be used effectively to do this calculation.
Since you are writting to oracle why not use a SQL executor to read the last value from each users table and assign it to the counter?
A demo for something like this can br found if you create a new workspace Create Workspace wizard > FME Store > Database > read oracle sequence nextval
Thanks Takashi for your answers, I will try it out, especially the last one.
But first I'd like to try another possible solution, but I can't get it to work:
In my oracle DB I have an "admin"-user which has a public sequence that I could use to create all of my IDs.
I put an SQLExecuter-Transformer between origin- and the result-table and connected it to the "admin"-schema, then I wrote the SQL-Statement (...NEXTVAL...) and exposed the "ID"-Attribute. As I understood it, a value should be calculated for each feature that enters the transformer. But I get an Oracle-error: ORA-01400: cannot insert NULL (ID)??
Thanks, Vera
Hi Vera,
Since a sequence is automatically created by oracle for each feature in a table is that not what you are looking for?
The ora message means you are trying to insert a null value to a non nullable column
Itay,
I didn't see your answer because was writing my last question. But that's exactly what I was looking for!
Many thanks
Vera
Glad to hear it
python is not always the answer....
I overlooked that the destination dataset is oracle database. I think Itay's suggestion is the best solution :-)
On more tip, for posterity: If you get error messages starting with "ORA" when reading or writing to Oracle, you can just google the error number directly, without the error text.
Example:
ORA-01400 ->
http://www.google.com/search?q=ORA-01400
The beauty of this is that this works regardless of your current language or locale setting.
David