pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: postgresql <pgsql@symcom.com>
To: PgSQL-SQL <pgsql-sql@postgresql.org>
Subject: creating "job numbers"
Date: Thu, 22 Mar 2001 08:19:03 -0500
Message-ID: <200103221311.f2MDB0t56270@mail.postgresql.org> (raw)

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.





view thread (9+ messages)  latest in thread

Message-ID: <200103221311.f2MDB0t56270@mail.postgresql.org>
Permalink:  ../200103221311.f2MDB0t56270@mail.postgresql.org/
Also on:    postgresql.org/message-id/200103221311.f2MDB0t56270@mail.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pgsql@symcom.com
  Subject: Re: creating "job numbers"
  In-Reply-To: <200103221311.f2MDB0t56270@mail.postgresql.org>
  References: <200103221311.f2MDB0t56270@mail.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox