| From: | Jacob Bunk Nielsen <jacob(at)bunk(dot)cc> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: SQL questiom |
| Date: | 2022-01-21 12:25:32 |
| Message-ID: | 87v8ydwa0z.fsf@localhost |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
hamann(dot)w(at)t-online(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matthias Apitz | 2022-01-21 12:38:59 | recording of INDEX creation in tables |
| Previous Message | Duarte Carreira | 2022-01-21 12:02:05 | Re: Query on postgres_fdw extension |