Hello Igor, > Is it possible to simplify the code? I have ten fields to UPDATE. > (STATUS, Responsavel, Country,......) > > UPDATE Bens SET *STATUS *= > CASE (SELECT COUNT(BENSBK.STATUS) FROM BENSBK WHERE BENSBK.BEM = > Bens.BEM) > WHEN 0 THEN Bens.STATUS > ELSE (SELECT BENSBK.STATUS FROM BENSBK WHERE BENSBK.BEM = Bens.BEM) > END [similar statements snipped]
Try this: update Bens set STATUS=coalesce( (SELECT BENSBK.STATUS FROM BENSBK WHERE BENSBK.BEM = Bens.BEM), STATUS), set Responsavel=coalesce( (SELECT BENSBK.Responsavel FROM BENSBK WHERE BENSBK.BEM = Bens.BEM), Responsavel), set Country=coalesce( (SELECT BENSBK.Country FROM BENSBK WHERE BENSBK.BEM = Bens.BEM), Country); Igor Tandetnik *************************************************************************************************************************** * ERROR: near "set": syntax error* Someone help me? *************************************************************************************************************************** *another question: can I update tables of two different files?* UPDATE Bens SET *STATUS * ....????? *Patrim.db3* TABLE [Bens] ( [Situacao] NVARCHAR(1), [Uso] NVARCHAR(1), [Country] NVARCHAR(1), [Bem] NUMERIC(9) NOT NULL ON CONFLICT ROLLBACK PRIMARY KEY ON CONFLICT ROLLBACK, [Status] NVARCHAR(1), [Responsavel] NVARCHAR(10)); *PatrimBK.db3* TABLE [Bens] ( [Situacao] NVARCHAR(1), [Uso] NVARCHAR(1), [Country] NVARCHAR(1), [Bem] NUMERIC(9) NOT NULL ON CONFLICT ROLLBACK PRIMARY KEY ON CONFLICT ROLLBACK, [Status] NVARCHAR(1), [Responsavel] NVARCHAR(10)); **************************************************************************************************************************** Thanks a lot Ernany _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users