Search Postgresql Archives

Re: Getting data from a record variable dynamically

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

 



On Mon, Jul 4, 2022 at 4:03 PM Rhys A.D. Stewart <rhys.stewart@xxxxxxxxx> wrote:

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.

The only workaround I can think of is to wrap the query that populates
the record variable in a to_jsonb function and then subscript that.


Is there a better way?


Not in the strongly typed language that is SQL; you will be unable to use first-tier types in that way.  You indeed need to create a type that itself is dynamic in terms of the information it stores (jsonb works) which also involves throwing away the static typing of the outer layer and devolving everything to basically text.

David J.


[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 Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux