"Ernany" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
>> 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);
>
> *
> ERROR: near "set": syntax error*

Keep the first instance of "set", remove the other two. As in

update Bens set STATUS=...,
 Responsavel=...,
 Country=...;

> *another question: can I update tables of two different files?*

See ATTACH statement: http://sqlite.org/lang_attach.html

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to