public inbox for [email protected]help / color / mirror / Atom feed
Re: Combining metavariables and table names 3+ messages / 2 participants [nested] [flat]
* Re: Combining metavariables and table names @ 2025-12-30 01:17 David G. Johnston <[email protected]> 2025-12-30 03:02 ` Re: Combining metavariables and table names H <[email protected]> 0 siblings, 1 reply; 3+ messages in thread From: David G. Johnston @ 2025-12-30 01:17 UTC (permalink / raw) To: H <[email protected]>; +Cc: PostgreSQL Users Mailing List <[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. ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Combining metavariables and table names 2025-12-30 01:17 Re: Combining metavariables and table names David G. Johnston <[email protected]> @ 2025-12-30 03:02 ` H <[email protected]> 2025-12-30 03:28 ` Combining metavariables and table names David G. Johnston <[email protected]> 0 siblings, 1 reply; 3+ messages in thread From: H @ 2025-12-30 03:02 UTC (permalink / raw) To: [email protected] On December 29, 2025 8:17:37 PM GMT-05:00, "David G. Johnston" <[email protected]> wrote: >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. I used the exact syntax you provided, however, I suspect that format() cannot be used in an argument in CREATE TRIGGER. ^ permalink raw reply [nested|flat] 3+ messages in thread
* Combining metavariables and table names 2025-12-30 01:17 Re: Combining metavariables and table names David G. Johnston <[email protected]> 2025-12-30 03:02 ` Re: Combining metavariables and table names H <[email protected]> @ 2025-12-30 03:28 ` David G. Johnston <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: David G. Johnston @ 2025-12-30 03:28 UTC (permalink / raw) To: H <[email protected]>; +Cc: [email protected] <[email protected]> On Monday, December 29, 2025, H <[email protected]> wrote: > > I used the exact syntax you provided, however, I suspect that format() > cannot be used in an argument in CREATE TRIGGER. > Oh, right. I was apparently overlooking the context and got tunnel vision around the “versioning” function call that isn’t really a call but rather a stored expression; and so the arguments must be simple literals (as documented). In that case you do indeed need to do the work in the client since the server needs the final result handed to it. You could also just create a wrapper function that calls versioning and has the two name part arguments as separate inputs. David J. ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-12-30 03:28 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-12-30 01:17 Re: Combining metavariables and table names David G. Johnston <[email protected]> 2025-12-30 03:02 ` H <[email protected]> 2025-12-30 03:28 ` David G. Johnston <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox