Hi! The CREATE statement declares c3 as the primary key, not c1. Why do you > now treat c1 as the field that decides whether insert or update should > be performed?
That was actually a typo :) Anyway, see if you can use these statements instead: > > insert or replace into X(c1, c2, c3) > select key, x1.c2, 'a' from (select 1 key) left join X x1 on (x1.c1 = > key); > > insert or replace into X(c1, c2, c3) > select key, 'b', x1.c3 from (select 1 key) left join X x1 on (x1.c1 = > key); I can see your point. Join with existing row to get the values that already are in the DB, and replace that row. But the same problem remains. I want to make this user-agnostic, so only a trigger or something in the DDL would be useful, since I can't control the actual statements sent to the DB. Because there is no way to know if a column is either not being sent, or being sent as null, I can't actually know if the user wants to write a null, or leave that column alone. The "translation" I'm looking for would be something like this: User sends SQL: INSERT INTO X(c1, c2) VALUES(1, 'a') Should be translated to: Replace column c2 and leave c3 alone. User sends SQL: INSERT INTO X(c1, c3) VALUES(1, null) Should be translated to: Replace column c3 to null and leave c2 alone. In other words, it should function like the PRIMARY KEY c1 ON CONFLICT REPLACE, but it should replace ONLY the columns that are actually expressed in the statement, not the full row... Cheers! Hugo Ferreira Igor Tandetnik > > > > ----------------------------------------------------------------------------- > To unsubscribe, send email to [EMAIL PROTECTED] > > ----------------------------------------------------------------------------- > > -- スプーンが ない