Skip to main content
Solved

Dynamically using Output as Parameter input

  • January 14, 2025
  • 4 replies
  • 34 views

pkno
Contributor
Forum|alt.badge.img+5
  • Contributor

Hello everyone

I am trying to do the following: 

My workspace writes into a database. I have set a user parameter to give the user an option “delete Database and start a fresh database OR continue adding data onto existing data”. In case of deleting the Database the creation of IDs (which are created in the Process) should start at 1. In case of adding data to the existing database the creation of IDs should continue from whatever the max value already existing in the database is.

I believe this should work as follows using a YES/NO User Parameter.

Test Filter on that User Parameter:

YES → Sampler (create single initiator) → SQL Executor (delete all data with “delete from tables”)

NO → Sampler (create single initiator) → Feature Reader on Database → Statistics Calculator (extract max ID)

 

Now in a different path within the workspace I have a Counter which I use to create the IDs. I thought I could simply use a conditional Value set on my YES/NO User Parameter with

YES → Start at 1
NO → Start at max ID as extracted from the Statistics Calculator above +1

The last step (NO) is where I am having trouble. How can I use that value in my counter transformer without adding attributes? I fiddled around with User Parameters and global variables but I’m not sure thats the way to go. Ideally I would like to cache that value and call it in the Count Start Parameter as $(max_ID) on the Condition the the User Parameter is set to NO. 

I guess I could join the values before getting to the counter but that A) seems a bit excessive and B) could make problems since in case of YES there will be no output and that Feature Joiner might halt the whole Process without an Input?
What am I missing?

Best answer by max_h

pkno wrote:

Hey thanks for the reply,

I dont want to let FME create the database tables, as the DDLs contain some constraints and I am relying on some PostGIS functionality that wont be carried over when I let FME create the tables. 
Also I don’t believe that would solve the problem with IDs. Say I would “use existing” I still need to figure out a way to create max.ID+1 as my count start parameter.

Truncating instead of dropping should keep ddls though as only the data is removed. 
As for the IDs you can add a sequenced coloumnin the advanced tab of the writer.

 

The last step (NO) is where I am having trouble. How can I use that value in my counter transformer without adding attributes? I fiddled around with User Parameters and global variables but I’m not sure thats the way to go. 

Those would have been my ideas. But why dont you want to add attributes/normal parameter?

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

4 replies

max_h
Contributor
Forum|alt.badge.img+10
  • Contributor
  • January 14, 2025

How about using a a user parameter in your database writer:
 

And then simply let them choose between ‘drop and create’ or ‘use existing’.


pkno
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 14, 2025

Hey thanks for the reply,

I dont want to let FME create the database tables, as the DDLs contain some constraints and I am relying on some PostGIS functionality that wont be carried over when I let FME create the tables. 
Also I don’t believe that would solve the problem with IDs. Say I would “use existing” I still need to figure out a way to create max.ID+1 as my count start parameter.


max_h
Contributor
Forum|alt.badge.img+10
  • Contributor
  • Best Answer
  • January 14, 2025
pkno wrote:

Hey thanks for the reply,

I dont want to let FME create the database tables, as the DDLs contain some constraints and I am relying on some PostGIS functionality that wont be carried over when I let FME create the tables. 
Also I don’t believe that would solve the problem with IDs. Say I would “use existing” I still need to figure out a way to create max.ID+1 as my count start parameter.

Truncating instead of dropping should keep ddls though as only the data is removed. 
As for the IDs you can add a sequenced coloumnin the advanced tab of the writer.

 

The last step (NO) is where I am having trouble. How can I use that value in my counter transformer without adding attributes? I fiddled around with User Parameters and global variables but I’m not sure thats the way to go. 

Those would have been my ideas. But why dont you want to add attributes/normal parameter?


pkno
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 15, 2025

Truncating instead of dropping should keep ddls though as only the data is removed. 
As for the IDs you can add a sequenced coloumnin the advanced tab of the writer.

 

Will try it out, this may be what I needed after all :) Thanks

 

Those would have been my ideas. But why dont you want to add attributes/normal parameter?

 

I didn’t want to categorically rule it out, I just thought that there would have to be a better/more elegant way.


Reply


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