Re: getting duplicate number is there a

From: Richard Huxton <dev(at)archonet(dot)com>
To: Joel Fradkin <jfradkin(at)wazagua(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: getting duplicate number is there a
Date: 2005-05-17 07:11:35
Message-ID: 42899927.9070801@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Joel Fradkin wrote:
> I was using SET TRANSACTION ISOLATION LEVEL SERIALIZABLE in MSSQL.
>
> Is there something similar in postgres to ensure its not in the middle of
> being updated?

Yep - see the SQL COMMANDS reference section under SET TRANSACTION ...
You could use LOCK TABLE too.
See Chapter 12 - Concurrency Control for discussion.

> sql = "SELECT COUNT(*) FROM tblcase WHERE LocationID = " &
> intLocationID & _
> " and substr(casenum,length(casenum)-1,2) = '" &
> right(year(date),2) & "' AND clientnum = '" & _
>
> chrClientNum & "'"
>
> I will add a select just before doing the insert to see if this helps, its
> not happening a bunch, but 5 6 times a day is still an issue for me.
>
> I use the count as a segment of my case number so each time a new case is
> entered the count goes up for that location for that year.

I'd be tempted to have a case_numbers table with (year,location,max_num)
and lock/read/insert to that. Makes everything explicit, and means you
don't have to mess around with counts/substrings.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sim Zacks 2005-05-17 12:16:34 plpython setof
Previous Message Ezequiel Tolnay 2005-05-17 05:02:17 Re: getting duplicate number is there a