Re: 'locking' the SELECTs based on indices...

From: PFC <lists(at)peufeu(dot)com>
To: mario(dot)splivalo(at)mobart(dot)hr, "Achilleus Mantzios" <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: 'locking' the SELECTs based on indices...
Date: 2006-02-23 16:35:21
Message-ID: op.s5fpo7sncigqcu@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Now, If some other user want's his prize, when checking his code, if he
> sends code for some other service then service 1, that's ok. If he's
> sends code for the service 1 the PERFORM will wait untill I'm finished
> with previous user.

Sorry for the double post.

If the rows in your table represent associations between codes and
services that are one-use only, you could simply use UPDATE or DELETE, to
mark the row in question as having been "consumed".
Then, you check how many rows were deleted or updated. If it's 1, good.
If it's 0, the code has been used already.

If the code itself is one-use only, you should have a codes table and a
codes_to_services table, with an ON DELETE CASCADE so that, when you use a
code, you delete it from the codes table and it's "consumed" for all
services.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel Hernandez 2006-02-23 17:46:44 Sum If
Previous Message PFC 2006-02-23 16:30:55 Re: 'locking' the SELECTs based on indices...