| From: | John R Pierce <pierce(at)hogranch(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Function PostgreSQL 9.2 |
| Date: | 2016-04-20 22:05:17 |
| Message-ID: | 5717FD1D.6000303@hogranch.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 4/20/2016 2:51 PM, drum(dot)lucas(at)gmail(dot)com wrote:
> 1 - The customer can add any value into users.code column
> 2 - The customer can chose between *add or no**t* add the value on
> users.code column
> 3 - If users.code is null (because the customer's chosen not to add
> any value in there), a trigger/function has to do the job.
> 4 - the function/trigger add the next available value, which the
> default is 1000 and it's stored on companies.client_code_increment
why don't you use a SEQUENCE for this?
... DEFAULT nextval('sequencename') ...
initialize the sequence to 1000.
done.
still sounds pretty sketchy.
--
john r pierce, recycling bits in santa cruz
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2016-04-20 22:07:05 | Re: Function PostgreSQL 9.2 |
| Previous Message | Adrian Klaver | 2016-04-20 22:02:52 | Re: Add relcreated (timestamp) column to pg_class catalog to record the time an object was created |