Skip to main content
Question

PostgreSQL Scirpt (.SQL)

  • 14 November 2012
  • 2 replies
  • 12 views

Instead of directly writing in it, is there any way to write an SQL script to run at an appropriate time while using PostgreSQL reader/writer?
You could use a SQLExecutor on a PostGIS database (with the script embeded as a transformer parameter), but that would not be tied to your writer, and I'm not sure if that would work for a non-PostGIS PostgreSQL database.
I do this all the time using a text writer (e.g. CSV) with a single column.  You have to build the SQL by hand by concatenating strings/variables in an attribute creator.  For example:

 

INSERT INTO $(DestFeature2) VALUES (DEFAULT,'@Value(LOCALITY_ID)','@Value(INPUT_STRING)','@Value(CONFIDENCE)');

 

 

The output is just a block of SQL statements in a text file which you can then pipe to psql at your leisure.

Reply