Re: transactions and unique variables:

2007-03-15 Thread Bram - Smartelectronix
Tim Chase wrote: > Which follows the pattern > >UPDATE tbl >SET field = ( > SELECT SUM(field) > FROM tbl > WHERE [EMAIL PROTECTED] or [EMAIL PROTECTED] > ) - field >WHERE [EMAIL PROTECTED] or [EMAIL PROTECTED] > > Any help? > > -tkc (aka "the atomic swapper"? :)

Re: transactions and unique variables:

2007-03-15 Thread Tim Chase
> Uhm, please ignore this email, it looks like this can't be done using > transactions > > begin transaction; > update book set "order"=2 where id=1; > update book set "order"=1 where id=2; > commit; for atomic swapping, however, it can be done in a single obscure SQL statement: update

Re: transactions and unique variables:

2007-03-15 Thread Bram - Smartelectronix
Bram - Smartelectronix wrote: > Rubic wrote: >> Bram, >> >> Try removing (commenting out) the transaction decorator >> and transaction.commit(), then re-run your code. The >> ProgrammingError exception may be hiding the real >> exception. At least that's been my experience. > > Nope..., I'm

Re: transactions and unique variables:

2007-03-15 Thread Bram - Smartelectronix
Rubic wrote: > Bram, > > Try removing (commenting out) the transaction decorator > and transaction.commit(), then re-run your code. The > ProgrammingError exception may be hiding the real > exception. At least that's been my experience. Nope..., I'm really getting the "unique key violation"

Re: transactions and unique variables:

2007-03-15 Thread Rubic
Bram, Try removing (commenting out) the transaction decorator and transaction.commit(), then re-run your code. The ProgrammingError exception may be hiding the real exception. At least that's been my experience. -- Jeff Bauer Rubicon, Inc.

transactions and unique variables:

2007-03-15 Thread Bram - Smartelectronix
Hi everyone, I have items that have an order. This function is supposed to move items up (swapping the order with the previous item) or down (...). I tried doing it via a transaction (as 'order' is logically unique), but on the first save() it fails with a ProgrammingError: