Search Postgresql Archives

Re: Function PostgreSQL 9.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 6 May 2016 at 02:29, David G. Johnston <david.g.johnston@xxxxxxxxx> wrote:
On Thu, May 5, 2016 at 3:54 AM, Alban Hertroys <haramrae@xxxxxxxxx> wrote:

> On 05 May 2016, at 8:42, drum.lucas@xxxxxxxxx wrote:

> The final function code is:
>
> CREATE OR REPLACE FUNCTION users_code_seq()
>    RETURNS "trigger" AS $$
> DECLARE code character varying;
> BEGIN
>         IF NEW.code IS NULL THEN
>         SELECT client_code_increment INTO STRICT NEW.code FROM public.companies WHERE id = NEW.id ORDER BY client_code_increment DESC;

                                                                        ^^^^^^^
There's your problem. I'm pretty sure the keyword STRICT isn't valid there. It probably gets interpreted as a column name.


​No, its a sanity check/assertion.  If that trips its because there is no company having a value of NEW.id on the public.companies table.  If that is OK then remove the STRICT but if you are indeed expecting a record to be present and it is not it is correctly telling you that there is a problem in the data.  Namely that said company needs to be added to the table.

David J.​
 


Taking off the "STRICT", the errors were gone. But still, it's not working. Please have a look below. 


If I use the other table:

CREATE TABLE public.company_seqs
(company_id BIGINT NOT NULL,
last_seq BIGINT NOT NULL DEFAULT 1000,
CONSTRAINT company_seqs_pk PRIMARY KEY (company_id)
);

It works fine.. the problem is when I try to use the companies table.. which is already there and I just add another column named: client_code_increment

haven't found the problem yet...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux