Skip to main content

Hi!

I’m using FME Workbench 2022.

I’m trying to insert some data in a table in PostgreSQL. The table has a composite key, like this: (id, feed_id, env_id). The table, obviously, has the constraint: CONSTRAINT agency_pkey PRIMARY KEY (id, feed_id, env_id).

In FME, I’m reading from a GTFS file, doing some transformations, and then, trying to write into the DB with a FeatureWriter using PostgreSQL as Format. I have all the configurations right. I checked it so many times, and before posting this question, I talked to some experienced mates.

The problem I have is, in runtime, the FeatureWriter is not adding the attribute called “id” to the insert, so the database is sending the error “null value in column id violates not null constraint”. It happens with and without bulk mode.

Now I’ll provide some images for visual context and information.

Flux:

Data in logger:

FeatureWriter Parameters:

FeatureWriter User Attributes:

I added the Debug to the log to see what is happening in the FeatureWriter. This is the SQL query that is creating, which does not include the id:

 

Could someone please help me with this? I really don’t know what is happening. Thanks!

Hi ​@dvazquez,

Sorry we didn't get to your post in time! Based on the error message, it appears that id may have some missing values that aren't being included by the FeatureWriter to perform the insert, which is why PostgreSQL is reporting a “null value violates not null constraint” error. If you're still having trouble inserting to your PostgreSQL table, I believe it would be helpful to first distinguish if the id attribute is generated from in your workspace or brought in by a reader.

If id is created or modified within FME (for example, with an AttributeManager or Counter), please double-check that the attribute exists and all features have a value for it immediately before the FeatureWriter. You can do this by placing an Inspector or using feature caching at the writer input port.

If id originates from a reader, ensure that the reader exposes this attribute and that it hasn’t been filtered out or renamed during transformations.

As well, you could try importing the schema from the agency table in the FeatureWriter. Click the + at the bottom left > Import From Dataset > Parameters > Tables > agency.

If this doesn’t fix the issue, we’ll be able to better assist you with more information, such as:

  • Your specific FME version and build (Help > About FME Workbench)
  • A sample workspace
  • Some sample data