Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT4Iu-0000qj-DG for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 12:23:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gT4Hv-0006u6-4s for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 12:22:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT4Hu-0006tz-TA for pgsql-general@lists.postgresql.org; Sat, 01 Dec 2018 12:22:22 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gT4Hs-0004Pz-U6 for pgsql-general@postgresql.org; Sat, 01 Dec 2018 12:22:22 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 14A99108DE61C for ; Sat, 1 Dec 2018 05:22:18 -0700 (MST) Date: Sat, 1 Dec 2018 05:22:18 -0700 (MST) From: PegoraroF10 To: pgsql-general@postgresql.org Message-ID: <1543666938082-0.post@n3.nabble.com> Subject: =?UTF-8?Q?Transition_Tables_doesn=C2=B4t_have_OID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I=C2=B4m trying to use transition tables for auditing purposes. create trigger MyTableAudit_UPD after update on MyTable referencing old table as Transition_old new table as Transition_new for each statement execute procedure AuditTable(); create or replace function AuditTable() returns trigger language plpgsql as $$ if (TG_OP =3D 'UPDATE') then insert into audittable(table_name, oid, audit_action, user_id, table_schema, values_old, values_new) select TG_TABLE_NAME, Transition_new.oid, TG_OP, CURRENT_USER, TG_TABLE_SCHEMA, row_to_json(Transition_old.*)::jsonb, row_to_json(Transition_new.*)::jsonb from Transition_new inner join Transition_old on Transition_new.OID =3D Transition_old.OID; elsif (TG_OP =3D 'DELETE') then insert into audittable(table_name, oid, audit_action, user_id, table_schema, values_old) select TG_TABLE_NAME, Transition_old.oid, TG_OP, CURRENT_USER, TG_TABLE_SCHEMA, row_to_json(Transition_old.*)::jsonb from Transition_old; end if; [42703] ERROR: column transition_new.oid does not exist Where: fun=C3=A7=C3= =A3o PL/pgSQL audittable() linha 14 em comando SQL I would like to user OID value because we change our primary keys, sometimes, OID doesn=C2=B4t. So, there is a way to get OID on transition tables ? -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.ht= ml