public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: H <[email protected]>
Cc: PostgreSQL Users Mailing List <[email protected]>
Subject: Re: Combining metavariables and table names
Date: Mon, 29 Dec 2025 18:17:37 -0700
Message-ID: <CAKFQuwY5UK0YFi2yE1TBigQDK+Mh=jjzDfh9CLhPvNxN3e2nLA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAKFQuwb9jdGH6-og4HFQv=AU7UH+V2AjoQy2y+xZ_Cjz1bx5FA@mail.gmail.com>
<[email protected]>
On Mon, Dec 29, 2025 at 5:58 PM H <[email protected]> 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.
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Combining metavariables and table names
In-Reply-To: <CAKFQuwY5UK0YFi2yE1TBigQDK+Mh=jjzDfh9CLhPvNxN3e2nLA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox