Re: Function PostgreSQL 9.2 - Mailing list pgsql-general
From | Adrian Klaver |
---|---|
Subject | Re: Function PostgreSQL 9.2 |
Date | |
Msg-id | 5717F859.5050804@aklaver.com Whole thread Raw |
In response to | Re: Function PostgreSQL 9.2 ("drum.lucas@gmail.com" <drum.lucas@gmail.com>) |
Responses |
Re: Function PostgreSQL 9.2
|
List | pgsql-general |
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. > > > > table users: > > CREATE TABLE > users > ( > id INTEGER DEFAULT nextval('users_id_seq'::regclass) NOT NULL, > email CHARACTER VARYING DEFAULT ''::CHARACTER VARYING NOT NULL, > encrypted_password CHARACTER VARYING DEFAULT ''::CHARACTER > VARYING NOT NULL, > reset_password_token CHARACTER VARYING, > reset_password_sent_at TIMESTAMP(6) WITHOUT TIME ZONE, > remember_created_at TIMESTAMP(6) WITHOUT TIME ZONE, > sign_in_count INTEGER DEFAULT 0 NOT NULL, > current_sign_in_at TIMESTAMP(6) WITHOUT TIME ZONE, > last_sign_in_at TIMESTAMP(6) WITHOUT TIME ZONE, > current_sign_in_ip INET, > last_sign_in_ip INET, > created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, > updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, > name CHARACTER VARYING, > confirmation_token CHARACTER VARYING, > confirmed_at TIMESTAMP(6) WITHOUT TIME ZONE, > confirmation_sent_at TIMESTAMP(6) WITHOUT TIME ZONE, > company_name CHARACTER VARYING, > country CHARACTER VARYING, > mobile_number CHARACTER VARYING, > landline_number CHARACTER VARYING, > staff_colour CHARACTER VARYING, > company_id INTEGER, > role_id INTEGER, > active BOOLEAN DEFAULT false, > deleted BOOLEAN DEFAULT false, > avatar_file_name CHARACTER VARYING, > avatar_content_type CHARACTER VARYING, > avatar_file_size INTEGER, > avatar_updated_at TIMESTAMP(6) WITHOUT TIME ZONE, > fax CHARACTER VARYING, > website CHARACTER VARYING, > business_type CHARACTER VARYING, > lead_source CHARACTER VARYING, > code CHARACTER VARYING, > notes TEXT, > status CHARACTER VARYING, > tsv TSVECTOR, > origin CHARACTER VARYING, > origin_id CHARACTER VARYING, > first_name CHARACTER VARYING, > last_name CHARACTER VARYING, > billed_client_id INTEGER, > username CHARACTER VARYING, > is_client BOOLEAN DEFAULT false, > job_share BOOLEAN DEFAULT true > ); > > > Table companies: > > CREATE TABLE > companies > ( > id INTEGER DEFAULT nextval('companies_id_seq'::regclass) > NOT NULL, > name CHARACTER VARYING, > country CHARACTER VARYING, > timezone CHARACTER VARYING, > mobile_number CHARACTER VARYING, > email CHARACTER VARYING, > website CHARACTER VARYING, > phone CHARACTER VARYING, > created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, > updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, > reference_increment INTEGER DEFAULT 1000, > activated BOOLEAN DEFAULT true, > enable_quotes BOOLEAN DEFAULT false, > allow_billing_client BOOLEAN DEFAULT true, > allow_templates_recurrence BOOLEAN DEFAULT true, > recurrence_limit INTEGER DEFAULT 30, > job_title_dropdown BOOLEAN DEFAULT false, > default_reference_prefix CHARACTER VARYING, > default_reference_increment INTEGER, > default_visit_start_day INTEGER, > default_visit_start_hour INTEGER, > default_visit_start_min INTEGER, > job_date_entry_duration BOOLEAN DEFAULT true, > default_visit_duration_hour INTEGER DEFAULT 0, > default_visit_duration_min INTEGER DEFAULT 30, > date_entry_short BOOLEAN DEFAULT true, > time_entry_24 BOOLEAN DEFAULT true, > time_field_increment INTEGER DEFAULT 10, > enable_job_share BOOLEAN DEFAULT true, > token CHARACTER VARYING > ); > > > -- Adrian Klaver adrian.klaver@aklaver.com
pgsql-general by date: