Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAHw1-0007nL-EF for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 19:47:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lAHw0-0001ts-DB for pgsql-general@arkaria.postgresql.org; Thu, 11 Feb 2021 19:47:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAHvz-0001te-On for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 19:47:28 +0000 Received: from mx32.harte-lyne.ca ([216.185.71.32]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAHvr-0005Ak-Nx for pgsql-general@lists.postgresql.org; Thu, 11 Feb 2021 19:47:22 +0000 Received: from mx32.harte-lyne.ca (localhost [127.0.32.1]) by mx32.harte-lyne.ca (Postfix) with ESMTP id 1E27440E3F for ; Thu, 11 Feb 2021 14:47:13 -0500 (EST) X-Virus-Scanned: amavisd-new at harte-lyne.ca Received: from mx32.harte-lyne.ca ([127.0.32.1]) by mx32.harte-lyne.ca (mx32.harte-lyne.ca [127.0.32.1]) (amavisd-new, port 10024) with ESMTP id MlDsPzYwQq9a for ; Thu, 11 Feb 2021 14:47:07 -0500 (EST) Received: from webmail.harte-lyne.ca (webmail.hamilton.harte-lyne.ca [216.185.71.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx32.harte-lyne.ca (Postfix) with ESMTPSA id CD71A40E34 for ; Thu, 11 Feb 2021 14:47:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harte-lyne.ca; s=dkim_hll; t=1613072826; bh=bc3lO79VQktDOVb5sQqrRdwoHV34KXFG/g+/u3YpIf0=; h=Date:Subject:From:To:Reply-To; b=p5FNOKD9lJUihCo8UviQoigILBuftcAMwbjIBYNADU4n8dhaIZ4zjEfh38HwQWg5+ zPfhjJqd9g/q8RoAR1+bIDVCJJZjeM0cjNZpwAnlSqf08Qp0c6a0uB/2g01McKjggO lvmcLYbLGivZ8NtGj18J6kRjkX58IMNU1dEYx+92oiHHLsUnZvSMcTIr6hmETE/A9j ytO0hpEq3pwt99xjOf+vFY4xN1NdCBgRi/yIXj6/x+Lqek7obEoqKV1F3wOS2j+kXs Ay5VdF0oym+HBzXbEacROR2Q6SXi95nxXmGy0cJxbliMcwHQS8iW08MjvE5W2E4Lem tRWXzb1/q9k0w== Received: from 216.185.71.41 (SquirrelMail authenticated user byrnejb_hll) by webmail.harte-lyne.ca with HTTP; Thu, 11 Feb 2021 14:47:06 -0500 Message-ID: <990f599f4168a310bb22268d9f38f904.squirrel@webmail.harte-lyne.ca> Date: Thu, 11 Feb 2021 14:47:06 -0500 Subject: Problem with trigger function From: "James B. Byrne" To: pgsql-general@lists.postgresql.org Reply-To: byrnejb@harte-lyne.ca User-Agent: SquirrelMail/1.4.23 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am trying to implement a trigger in a PostgreSQL-9.6.17 database: CREATE OR REPLACE FUNCTION customer_num_informix() RETURNS trigger AS $$ BEGIN -- An Aubit/Informix 4GL INSERT statement passes the value 0 to Informix -- DBMS for columns that have the SERIAL data type. Informix will then -- use the incremented serial number in place of 0. PostgreSQL instead -- will simply take the value 0 and replace the incremented serial number. -- This trigger function emulates the Informix DBMS behaviour. -- -- The NEW variable contains the data for the row to be INSERTed or -- UPDATEd. It, and its complement OLD used for UPDATE and DELETE, -- are automatically created and populated by PostgreSQL whenever -- a data-change function is called. -- IF NEW.customer_num = 0 THEN SELECT nextval('customer_customer_num_seq') INTO NEW.customer_customer_num; ELSE IF NEW.customer_customer_num > 0 THEN PERFORM setval('customer_customer_num_seq', NEW.customer_customer_num); END IF; END IF; RETURN NEW; END; $$ LANGUAGE plpgsql; ALTER FUNCTION public.customer_num_informix() OWNER TO hll_4gl_testing; CREATE TRIGGER customer_num_serial BEFORE INSERT ON customer FOR EACH ROW EXECUTE customer_num_informix(); The problem is that I am getting a syntax error on the CREATE TRIGGER statement: ERROR: syntax error at or near "customer_num_informix" LINE 3: FOR EACH ROW EXECUTE customer_num_informix(); I do not see what the error is. What is wrong with the syntax I used? -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail Unencrypted messages have no legal claim to privacy Do NOT open attachments nor follow links sent by e-Mail James B. Byrne mailto:ByrneJB@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3