Skip to main content
Solved

SQL Executor

  • June 12, 2019
  • 2 replies
  • 21 views

deanhowell
Influencer
Forum|alt.badge.img+24

Hello all,

Another newby question, sorry :)

I have a table in PostgreSQL which is called ExaminationNumber and has a single column call ExamID.

The ExamID field stores a current count of the examinations processed and is increased by one each time.

I am have a reader that reads from the table and grabs the current ExamID value. I then want to update the value by one using the SQLExecutor but can't get it to work.

 

 

Can anyone let me the correct syntax or if there is a better way to go about this?

 

 

Best answer by nielsgerrits

What is the feedback in the log?

I think the syntax is the problem. It's either "insert into" or "update", not "update into". And you probably need to use "where" to define which record(s) need to be updated. In your current statement all records will be updated. See for example W3Schools. Also, postgres is case sensitive, so if you have table names or column names with uppercase characters you need to use quotation marks.

update public."ExaminationNumber" set "ExamID" = (@Evaluate(@Value(ExamID)+1));

Best practice is first to make the statements work, for example using pgAdmin, then transmit the statement to FME.

As an addition, in this particular example I would use the value which already is in the database to reduce I/O.

For all records this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1;

For a specific record this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1 where "ExampID" = @Value(ExamID);
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2939 replies
  • Best Answer
  • June 12, 2019

What is the feedback in the log?

I think the syntax is the problem. It's either "insert into" or "update", not "update into". And you probably need to use "where" to define which record(s) need to be updated. In your current statement all records will be updated. See for example W3Schools. Also, postgres is case sensitive, so if you have table names or column names with uppercase characters you need to use quotation marks.

update public."ExaminationNumber" set "ExamID" = (@Evaluate(@Value(ExamID)+1));

Best practice is first to make the statements work, for example using pgAdmin, then transmit the statement to FME.

As an addition, in this particular example I would use the value which already is in the database to reduce I/O.

For all records this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1;

For a specific record this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1 where "ExampID" = @Value(ExamID);

deanhowell
Influencer
Forum|alt.badge.img+24
  • Author
  • Influencer
  • 315 replies
  • June 12, 2019

What is the feedback in the log?

I think the syntax is the problem. It's either "insert into" or "update", not "update into". And you probably need to use "where" to define which record(s) need to be updated. In your current statement all records will be updated. See for example W3Schools. Also, postgres is case sensitive, so if you have table names or column names with uppercase characters you need to use quotation marks.

update public."ExaminationNumber" set "ExamID" = (@Evaluate(@Value(ExamID)+1));

Best practice is first to make the statements work, for example using pgAdmin, then transmit the statement to FME.

As an addition, in this particular example I would use the value which already is in the database to reduce I/O.

For all records this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1;

For a specific record this would be

update public."ExaminationNumber" set "ExamID" = "ExamID" + 1 where "ExampID" = @Value(ExamID);

Thanks @nielsgerrits, you are a champion again.