Skip to main content
Question

SQLCreator insert delayed

  • March 16, 2018
  • 1 reply
  • 9 views

annette2
Contributor
Forum|alt.badge.img+11

Hi,

I am trying to insert a record into a table when the workspace starts and before any features are read to indicate the job has started. I couldn't get it to work without using a workspace runner workaround and I'm wondering if anyone could spot why.

SQL statement to insert:

INSERT INTO DM_GEO.NG148B_PROCES_LOG (WORKBECH_ID, RUN_STATUS, WORKBENCH_NAME) VALUES ($(WORKBENCH_ID), 1, 'Clipper_Perf_POC')

Attempt 1: SQLCreator added to workspace. Record is still inserted after all the records are read and processed.

Attempt 2: Use SQL Statement to Execute Before Translation - this doesn't work as the SQL statement is executed before the first feature hits the writer and it seems after the records are read.

Attempt 3: Sample one of the features from the first reader and use a SQLExecutor. Record is also inserted after all records are read and processed.

I've read about how multiple SQLExecutors and Creators can be ordered but this doesn't help here.

Any thoughts would be welcome as the workaround is ok for a POC but not for wider production use.

Thanks,

Annette

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.

1 reply

takashi
Celebrity
  • 7843 replies
  • March 16, 2018

Hi @annette2, in my quick test on the "Attempt 2" with the PostgreSQL reader, an INSERT statement which is set to the "SQL To Run Before Read" parameter was executed definitely before the reader starts to read the table. If the "Attempt 2" doesn't work anyway, I'd recommend you to contact Safe to investigate the reason.

A workaround. You can add a SELECT statement that generates just a single feature to the SQLCreator, and connect a FeatureReader to read the table using the feature as initiator. Something like this.

FME_SQL_DELIMITER ;
INSERT <your insert statement> ;
SELECT 1;