Re: Combining metavariables and table names - Mailing list pgsql-general

From H
Subject Re: Combining metavariables and table names
Date
Msg-id 403D51E9-3428-452B-A01C-2B090C1F637F@meddatainc.com
Whole thread Raw
In response to Re: Combining metavariables and table names  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Combining metavariables and table names
List pgsql-general
On December 29, 2025 8:17:37 PM GMT-05:00, "David G. Johnston" <david.g.johnston@gmail.com> wrote:
>On Mon, Dec 29, 2025 at 5:58 PM H <agents@meddatainc.com> wrote:
>
>> Just tried your suggestion to use format() but it resulted in a
>'syntax
>> error at or near "("'
>>
>
>Helps to show exactly what you tried.  I provided pseudo-code.
>
>postgres=# \set sch 'schemaname'
>postgres=# select format('%I.%I', :'sch', 'tblname');
>       format
>--------------------
> schemaname.tblname
>(1 row)
>
>Admittedly, if the names do require quoting, and depending on how the
>function uses the value, some additional tweaking may be required.
>
>There shouldn't be anything you cannot do with format that you can do
>with
>pre-processing and setting the variable up-front.  Admittedly that is
>probably cleaner overall anyway though.
>
>David J.

I used the exact syntax you provided, however, I suspect that format() cannot be used in an argument in CREATE TRIGGER.



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Combining metavariables and table names
Next
From: "David G. Johnston"
Date:
Subject: Combining metavariables and table names