Steve Crawford wrote:
>
> begin;
>
> select item-id, item-info
> from the-queue
> where available
> order by priority
> limit 1
> for update;
>
> update the-queue
> set status = 'assigned'
> where item-id = previously-selected-item-id;
>
> commit;
>
I do something similar in one of my apps:
BEGIN;
update the-queue
set status = 'assigned'
where available
order by priority
limit 1
returning item-id, item-info;
COMMIT;
This should be safer and faster.
Regards,
LL