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"? :)
> 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
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
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"
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.
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:
6 matches
Mail list logo