creating "job numbers"

From: "postgresql" <pgsql(at)symcom(dot)com>
To: "PgSQL-SQL" <pgsql-sql(at)postgresql(dot)org>
Subject: creating "job numbers"
Date: 2001-03-22 13:19:03
Message-ID: 200103221311.f2MDB0t56270@mail.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Perrin 2001-03-22 13:36:56 Re: creating "job numbers"
Previous Message Karel Zak 2001-03-22 13:07:55 Re: CHAR or VARCHAR