Skip to main content

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

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;

Reply