Re: Function PostgreSQL 9.2
| От | Berend Tober |
|---|---|
| Тема | Re: Function PostgreSQL 9.2 |
| Дата | |
| Msg-id | 572C8398.8080708@computer.org обсуждение исходный текст |
| Ответ на | Re: Function PostgreSQL 9.2 ("drum.lucas@gmail.com" <drum.lucas@gmail.com>) |
| Ответы |
Re: Function PostgreSQL 9.2
|
| Список | pgsql-general |
drum.lucas@gmail.com wrote: > It's working now... > > Final code: > > ALTER TABLE public.companies ADD COLUMN client_code_increment integer; > ALTER TABLE public.companies ALTER COLUMN client_code_increment SET NOT NULL; > ALTER TABLE public.companies ALTER COLUMN client_code_increment SET DEFAULT 1000; > COMMIT TRANSACTION; > > BEGIN; > -- Creating the function > CREATE OR REPLACE FUNCTION users_code_seq() > RETURNS "trigger" AS $$ > DECLARE code character varying; > BEGIN > -- if it's an insert, then we update the client_code_increment column value to +1 > IF (TG_OP = 'INSERT') THEN ... Think about it, will (TG_OP = 'INSERT') ever be untrue.
В списке pgsql-general по дате отправления: