Question

Default date format for writing to PostGIS

  • 16 February 2015
  • 3 replies
  • 11 views

Hi,

 

 

I write many Data from an ESRI enterprise Geodatabase to a PostGIS Database. All this data are copied by only one fme workbench. This means FME reads and writes the schema dinamically. So far so god.

 

 

The Input Data has datefields wich are written to PostGIS as fileds in the format timestamp (2015-02-16 00:00:00).

 

 

How can I tell FME that a datefield in PostGIS has to be created as date (2015-02-16) and not as timestamp (2015-02-16 00:00:00)?

 

 

Thank's a lot

 

Roman

 

 

 

3 replies

Userlevel 2
Badge +17
Hi Roman,

 

 

If you are using the POSTGIS writer to create the table, try setting "date" to the field data type in the Feature Type Properties dialog.

 

 

 

Takashi
Badge +3
Hi you can use the DateFormatter with the appropriate formatstring for that, or tcl format function in a attributecreator (wich boils down to the same of course.)
Userlevel 2
Badge +17
Ah, you are trying to do that through Dynamic Schema.

 

 

The solution may be a typical use case of "Destination Schema is Derived from List Attributes". (http://fmepedia.safe.com/articles/Samples_and_Demos/Dynamic-Workflow-Tutorial-Destination-Schema-is-Derived-from-List-Attributes)

 

 

Summary

 

- read schema of the source feature type,

 

- modify the schema (change "fme_datetime" type to "fme_date" type),

 

- apply the schema to the writer feature type as its schema source.

 

 

1. Read Schema of the Source Feature Type 

 

Add Schema (Any Format) Reader to the workspace.

 

Set the "Input Format" explicitly, and link its "Dataset" to the source dataset of the Geodatabase Reader.

 

 

The Schema reader reads schemas from the specified source dataset, and creates features having schema information as a list attribute called "attribute{}" for every source feature type.

 

In this case, the following attributes will be used to configure the dynamic schema.

 

fme_feature_type_name

 

attribute{}.name

 

attribute{}.fme_data_type

 

 

2. Modify the Schema

 

1) Connect a ListExploder to the schema reader to explode the schame features on "attribute{}".

 

2) Add an AttributeCreator to change the value of "fme_data_type" from "fme_datetime" to "fme_date". To do that, the Conditional Value setting can be used.

 

If fme_data_type = fme_datetime Then fme_date, Else No Action

 

3) Use an Aggregator to restore the "attriute{}" list.

 

Group By: fme_feature_type_name

 

Mode: Attributes Only

 

List Name: attribute

 

 

3. Apply the Schema to the Writer Feature Type

 

After exposing "fme_feature_type" of the data features (the Geodatabase reader), use a FeatureMerger to merge the "attribute{}" to the data features.

 

Join On:

 

Requestor (data features): fme_feature_type

 

Supplier (schema features): fme_feature_type_name

 

Send Merged features to the POSTGIS writer feture type.

 

 

Add a NULL Reader as a Workspace Resource.

 

Menu: Readers > Add Reader as Resource

 

Finally, set the "NULL" to Schema Source of the POSTGIS writer feature type.

 

Reply