Re: [SQL] Order of execution
On 2013-05-06, JORGE MALDONADO wrote: > --089e013d1eb83325e504dc01710d > Content-Type: text/plain; charset=ISO-8859-1 > > I have an UPDATE query which performs several opertions in one table. > > UPDATE table01 SET > field1 = (query1 may contain any field), > field2 = (query1 may contain any field), > field3 = (query1 may contain any field) > WHERE (condition) > > query1, query2 and query3 perform a logic to determine which records will > be updated. Does field1 updates first, then field2 and, lastly, field3? Updates are one row at a time in an unpredictble order. this will be wrapped in a transaction so either all will updated or none. testing suggests that in simple cases the expressions are evaluated in the order the columns appear in the table definition, but I wouldn't rely on that. > or What is the order in which updates are executed? If I need fields to be > updated in a certain order, should I use 3 UPDATE commands instead? yeah, if "simultaneously" isn't acceptable you'll need to do separate updates. -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Correct implementation of 1:n relationship with n>0?
On Ôñé 30 Áðñ 2013 20:25:42 Wolfgang Keller wrote: > > (there is nothing wrong in getting your hands dirty with pl/pgsql btw) > > The point is that I would have expected that problem to be solved > within the past four decades since relational databases have been > invented. Or at least in the past two decades since PostgreSQL has been > developed. > Then what about n>1, n>2, n>k where k an arbitrarily large positive integer? isn't it the same problem class actually? Is there any serious database vendor who provides out of the box support for 1:n, n>0 ? Or is it an "unusual" user requirement in the first place. Ever thought why not so many people have asked for this? Anyway, IMHO, the need for more programming/programmers increases with the years, engineering becomes more complex, you can't expect serious contgrol in anything without getting under the hood. > >;-> > > After all, this should be really an ultra-classic-standard FAQ item. > > I'm definitely not the first database user in the world who needs to > have a 1:n relationship with n>0 and integrity enforced by the > database. > > Sincerely, > > Wolfgang > > > - Achilleas Mantzios IT DEV IT DEPT -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
