Re: Function PostgreSQL 9.2

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: Function PostgreSQL 9.2
Дата
Msg-id 5717FD1D.6000303@hogranch.com
обсуждение исходный текст
Ответ на Re: Function PostgreSQL 9.2  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
Список pgsql-general
On 4/20/2016 2:51 PM, drum.lucas@gmail.com wrote:
1 - The customer can add any value into users.code column
2 - The customer can chose between add or not 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Add relcreated (timestamp) column to pg_class catalog to record the time an object was created
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Function PostgreSQL 9.2