Thank you Simon!
Why do you say: > This would normally be done inside your programming language. strengthen the rule directly in the database seems common sense. olivier Le 13 févr. 2014 à 10:37, Simon Slavin <slav...@bigfraud.org> a écrit : > > On 13 Feb 2014, at 8:50am, O.D. vidal <pa...@mac.com> wrote: > >> I would like a field is not editable. What is the best sol >> ution? >> >> For example, I have a table Country: >> >> id - Name >> >> 1 - Brazil >> 2 - Canada >> ... >> >> I want the name of the country can not be changed. > > This would normally be done inside your programming language. However it > might be possible to enforce the rule inside SQLite using a TRIGGER: > > <http://www.sqlite.org/lang_createtrigger.html> > > It might looks something like > > CREATE a TRIGGER > UPDATE ON Country > WHEN new.name != old.name > BEGIN > RAISE (FAIL, 'Not allowed to change the name of a country.') > END > > Note: I just made that up off the top of my head and have no idea whether it > will work. > > You will have to guard against > > (A) people DROPping the TRIGGER, and > (B) people deleting the row from the Country table and making a new one with > a different name. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users