creating "job numbers" - Mailing list pgsql-sql

From postgresql
Subject creating "job numbers"
Date
Msg-id 200103221311.f2MDB0t56270@mail.postgresql.org
Whole thread Raw
Responses Re: creating "job numbers"
Re: creating "job numbers"
List pgsql-sql
I have been working with PG for about 2 months now. I am creating a  
job tracking system for my company. I have written a front end on the 
workstations (all macintoshes) that seems to be working quite well. 
However, I have a problem with a concept.

In my current setup I have only one workstation  that is actually 
inputting new jobs. So, I took the expedient way to create the  job 
number. Ask PG to count the rows, add a magic number and insert 
this data. This all happens in one connection. What are the odds of 
two people hitting the db at the same time? In the current set up nil. 
There is only one entry computer. I want to change the system to use 
a job number generated by PG. I created a test  table and I  am 
playing with inserting and the sequence function works great. 
However, I am at a loss of how to pick up this next (last) job. I have 
read the docs and I still am confused. I can not first ask with the 
number will be, and asking for the previous oid after  the fact can 
also lead to  the same problem. so that leaves me  with, 1 ask for 
that last oid from this  workstation ip, or 2 since a job is inserted with 
data, I could do a select of this data after the insert (not very elegant).

How are you professionals handling this problem? I like the ability to 
insert and have the system give me the number. As I grow into more 
workstations inputting the jobs I won't have to worry about chasing 
the next  highest number.

Thanks,
Ted P.




pgsql-sql by date:

Previous
From: Karel Zak
Date:
Subject: Re: CHAR or VARCHAR
Next
From: jdassen@cistron.nl (J.H.M. Dassen (Ray))
Date:
Subject: Re: creating "job numbers"