user88
user88

Reputation: 1164

ERROR: null value in column "user_id" violates not-null constraint in postgresql

I want to delete a row in my table re_users and I am getting error below:

ERROR:  null value in column "user_id" violates not-null constraint
DETAIL:  Failing row contains (5, null, 2014-09-05 06:53:47.804037, 2014-09-05 06:53:47.804037, null, _fetch_mails, minutes, null, Fetchmail Service, (), -1, 2014-09-05 06:53:47, 5, f, f, 5, fetchmail.server).
CONTEXT:  SQL statement "UPDATE ONLY "public"."ir_cron" SET "user_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "user_id""

kindly suggest me, how do I resolve it.

Waiting for reply.

Thanks

Upvotes: 2

Views: 3746

Answers (2)

Kellen Stuart
Kellen Stuart

Reputation: 8903

This is postgres' way of telling you there's a foreign key relationship that needs to be deleted first. Once you delete the row in your linked table, then you'll be able to get past this error.

Related: How to query a table for foreign keys?

Upvotes: 1

Wided Kéfi
Wided Kéfi

Reputation: 41

The table ir_cron contains a row with the user_id that you're trying to delete, you should first edit that row or delete it before deleting the row in re_users.

Upvotes: 1

Related Questions