pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL questiom
3+ messages / 3 participants
[nested] [flat]
* SQL questiom
@ 2022-01-21 10:13 hamann.w@t-online.de
0 siblings, 2 replies; 3+ messages in thread
From: hamann.w@t-online.de @ 2022-01-21 10:13 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi,
I am using a query pretty often that looks like
SELECT <<fixed columns from tables>> WHERE <<fixed join statements>> AND
<<actual select criterion>>
Is there a way (with sql or plpgsql) to convert that into
SELECT myquery('<<actual select criterion>>')
Kind regards
Wolfgang Hamann
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: SQL questiom
@ 2022-01-21 10:36 Thomas Boussekey <thomas.boussekey@gmail.com>
parent: hamann.w@t-online.de
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Boussekey @ 2022-01-21 10:36 UTC (permalink / raw)
To: hamann.w@t-online.de; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Le ven. 21 janv. 2022 à 11:14, <hamann.w@t-online.de> a écrit :
>
>
> Hi,
>
> I am using a query pretty often that looks like
> SELECT <<fixed columns from tables>> WHERE <<fixed join statements>> AND
> <<actual select criterion>>
>
> Is there a way (with sql or plpgsql) to convert that into
> SELECT myquery('<<actual select criterion>>')
>
> Kind regards
> Wolfgang Hamann
>
>
>
> Hello Wolfgang,
You can use a FUNCTION
<https://www.postgresql.org/docs/current/sql-createfunction.html; to
perform this operation
HTH,
Thomas
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: SQL questiom
@ 2022-01-21 12:25 Jacob Bunk Nielsen <jacob@bunk.cc>
parent: hamann.w@t-online.de
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Bunk Nielsen @ 2022-01-21 12:25 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
hamann.w@t-online.de writes:
> I am using a query pretty often that looks like
> SELECT <<fixed columns from tables>> WHERE <<fixed join statements>> AND
> <<actual select criterion>>
>
> Is there a way (with sql or plpgsql) to convert that into
> SELECT myquery('<<actual select criterion>>')
I would solve that by creating a view like:
CREATE VIEW some_view_name AS
SELECT <<fixed columns from tables>> WHERE <<fixed join statements>>;
See also https://www.postgresql.org/docs/14/sql-createview.html
Then you can query that view with your actual select criterion like:
SELECT * FROM some_view_name WHERE <<actual select criterion>>;
Best regards,
Jacob
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-01-21 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 10:13 SQL questiom hamann.w@t-online.de
2022-01-21 10:36 ` Thomas Boussekey <thomas.boussekey@gmail.com>
2022-01-21 12:25 ` Jacob Bunk Nielsen <jacob@bunk.cc>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox