Re: Function PostgreSQL 9.2

From: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function PostgreSQL 9.2
Date: 2016-04-20 21:51:45
Message-ID: CAE_gQfXJ_pxy_yU-KVaAp-DFGGMncfuPJmXmGwfJDWQzF7Dz6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21 April 2016 at 09:44, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:

> On 04/19/2016 07:34 PM, drum(dot)lucas(at)gmail(dot)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 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

Lucas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next 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
Previous Message Adrian Klaver 2016-04-20 21:44:57 Re: Function PostgreSQL 9.2