Re: Function PostgreSQL 9.2

Поиск
Список
Период
Сортировка
От drum.lucas@gmail.com
Тема Re: Function PostgreSQL 9.2
Дата
Msg-id CAE_gQfXJ_pxy_yU-KVaAp-DFGGMncfuPJmXmGwfJDWQzF7Dz6g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Function PostgreSQL 9.2  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Function PostgreSQL 9.2  (John R Pierce <pierce@hogranch.com>)
Re: Function PostgreSQL 9.2  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Function PostgreSQL 9.2  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general


On 21 April 2016 at 09:44, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 04/19/2016 07:34 PM, drum.lucas@gmail.com wrote:
    Information. eg.:


    The schema for the tables.

    Why is not just adding a DEFAULT value to the users.code not an option?



The customer can add their own value to the users.code column.
That's why I can't have a default value.

That is contradicted by your next statement below.


    What the default code should be or how it is to be calculated?


the default value is 1000.

See above.


So the customer can set their own code value. But if they don't do that,
I've to provide the next available value. 1001, 1002, 1003, etc....

Then why is users.code a varchar field?



    What is increment_client_code?


It's a column:
ALTER TABLE public.companies ADD COLUMN client_code_increment integer;
ALTER TABLE public.companies ALTER COLUMN client_code_increment SET
DEFAULT 1000;


    Does increment_client_code relate to users or some other table, say
    clients?


nope.. there is no link between them

Then what is its purpose?

I am with the other responses in this thread, this is a set up that is not going to end well. More to the point, I still have no idea what you are trying to achieve with your triggers and functions.



Well.. will try ONE more time then.


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

Lucas

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

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