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 1o8cZR-00029d-QI for pgsql-general@arkaria.postgresql.org; Tue, 05 Jul 2022 07:02:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o8cZP-00089G-7P for pgsql-general@arkaria.postgresql.org; Tue, 05 Jul 2022 07:02:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8cZO-000897-Q7 for pgsql-general@lists.postgresql.org; Tue, 05 Jul 2022 07:02:02 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o8cZM-0003bj-JY for pgsql-general@postgresql.org; Tue, 05 Jul 2022 07:02:01 +0000 Received: by mail-ed1-x532.google.com with SMTP id e40so14077070eda.2 for ; Tue, 05 Jul 2022 00:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hsBxmkXRcbnmaJjLqa2X0gWCQ2+yvNW2BCoQO4Kj3cs=; b=fAkp86kOwy6dSf4Ev7JF0rqImWi2amx8fKyL0BaiOXxRxjtITVxPxp8JQwocUBTQ3u zUMpLlmZiDDvev//U1kWFsXp35rVyox0KNmvorXSyXHNGTZ7lfVPQ6MJ5vw85ldKF09u HMQEXhlygaFF3SzYgyQzfA0J00RkZT7TvH56ZFl01fjQq4fKsttBMVt7ja73HzdWkqFm FKEhJ932AB/Q77jBckINtyFrLH//noAwG5zYDlS/1p0s7Vk13kpFlMVlf3pbaBrPjhUt emOOiVhBc7+khlNJfy9BvJ0JzaHXaoslFCrQyBEefFuKKVt/pTPJ2vPjUwtDrFOkLUiL 849g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hsBxmkXRcbnmaJjLqa2X0gWCQ2+yvNW2BCoQO4Kj3cs=; b=gGL3S3iDXu8dumgShuFA9pOz/oQ9bAexzfNxGrVwglo3n5wppEhBzfYC3F6dsbvPFw IZqpPvUtrOuEqbqZOdprPDMx/aYSzvW2E8JSg6BZYbVDA/jJ29PETGWEvaRAVLtJREFI 9oq5tPNJ4RK3brr/0vDNKnXfmuWAuZAdifiBNQN1v5HKb/kmDaBkjyztxMXZzklNvZ1s akzNHTw4Yu+avuXVe8ZLT2odW5pMVHZgKsffFsBWt2+iD19AB4PYgFEKJZQJesDJN03W yYtrYI77ddDM/TFwz8ojPdpmFXKS0JLvJLhcSXvkey70EeVuchcEyItTpdXip3VG93Ee L5jQ== X-Gm-Message-State: AJIora8g6sLQUv2Ir+nLi/kpu+gSYSKGLS60h6/tuuYdomId6kWBaMav 2AlRA4meD721Pnu8ca2kppg= X-Google-Smtp-Source: AGRyM1uHhFCP0mzn+fth7r8JsIFPb9NcEPX4l7X78TnPFxSARrbQgMIp2XU709lUcSSE65pTnpoRww== X-Received: by 2002:a05:6402:15a:b0:431:71b9:86f3 with SMTP id s26-20020a056402015a00b0043171b986f3mr43203543edu.249.1657004519240; Tue, 05 Jul 2022 00:01:59 -0700 (PDT) Received: from hollewijn.internal (217-19-30-105.dsl.cambrium.nl. [217.19.30.105]) by smtp.gmail.com with ESMTPSA id fg8-20020a056402548800b0043a3f52418asm4419022edb.18.2022.07.05.00.01.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2022 00:01:58 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Getting data from a record variable dynamically From: Alban Hertroys In-Reply-To: Date: Tue, 5 Jul 2022 09:01:57 +0200 Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <3ABEE3C9-E57F-4D52-BB4C-0CD9D9838235@gmail.com> References: To: "Rhys A.D. Stewart" X-Mailer: Apple Mail (2.3608.120.23.2.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 5 Jul 2022, at 1:02, Rhys A.D. Stewart = wrote: >=20 > Greetings All, >=20 > I have a trigger that is attached to several different tables. In the > trigger function I retrieve a single row and I want the info from a > specific column. This column is dependent on the table in question. > and I have the column name stored in a variable as well. Without > writing a conditional for each table, what is the best way to > dynamically get the data from the record variable? I would create a simple trigger function for each of those tables that = just extracts the value(s) from the field(s) you mentioned, and then = pass those values on to a generic function that does the actual = table-independent work. The usual trigger pseudo-columns and variables wouldn=E2=80=99t be = available in that generic function, but considering that your triggers = fire from different tables, you could either pass them on or they = (probably) don=E2=80=99t make sense in the context of the generic = function. Alban Hertroys -- There is always an exception to always.