79439550

Date: 2025-02-14 13:40:46
Score: 3.5
Natty:
Report link

I found a solution while facing same problem. For avoid inserting if you violate not null constraint you can do a Insert Select operation avoiding null values.

In your example:

INSERT INTO public.users (user, user_yob, sex) SELECT mom, mom_yob, 'F' FROM staging.users where user is not null ON CONFLICT DO NOTHING;

This should avoid inserting values from staging users to public users if user (guess is name or something similar is not null) you can check any value

Here you have an example of the select into with where clause

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Me too answer (2.5): facing same problem
  • Low reputation (1):
Posted by: Daniel Jiménez