| From: | Igor Korot <ikorot01(at)gmail(dot)com> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
| Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Determine server version from psql script |
| Date: | 2025-03-24 01:08:11 |
| Message-ID: | CA+FnnTyXFh+sXTOC7HMU0eLDmW0YLhWjX+Z89V9uzg5gtFcHLQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi,
This is what :
[code[
\else
DROP TRIGGER IF EXISTS playersinleague_insert ON playersinleague;
CREATE TRIGGER playersinleague_insert AFTER INSERT ON playersinleague
WHEN new.current_rank IS NULL
BEGIN
UPDATE playersinleague SET current_rank = 1 + (SELECT coalesce(
max( current_rank ), 0 ) FROM playersinleague WHERE id = new.id) WHERE
rowid = NEW.rowid;
UPDATE playersinleague SET original_rank = current_rank WHERE rowid
= new.rowid;
END;
\endif
[/code]
And I'm getting this:
[code]
\else
DROP TRIGGER IF EXISTS playersinleague_insert ON playersinleague;
psql:draft_pg.sql:44269: NOTICE: trigger "playersinleague_insert" for
relation "playersinleague" does not exist, skipping
DROP TRIGGER
CREATE TRIGGER playersinleague_insert AFTER INSERT ON playersinleague
WHEN new.current_rank IS NULL
BEGIN
UPDATE playersinleague SET current_rank = 1 + (SELECT coalesce(
max( current_rank ), 0 ) FROM playersinleague WHERE id = new.id) WHERE
rowid = new.rowid;
psql:draft_pg.sql:44272: ERROR: syntax error at or near "new"
LINE 1: ...eague_insert AFTER INSERT ON playersinleague WHEN new.curren...
^
[/code]
What is the problem niw?
Thank you.
On Sun, Mar 23, 2025 at 2:27 PM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Sunday, March 23, 2025, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>>
>> Hi
>>
>> ne 23. 3. 2025 v 19:31 odesílatel Igor Korot <ikorot01(at)gmail(dot)com> napsal:
>>>
>>> Hi,
>>>
>>> [code]
>>> SELECT current_setting('server_version_num')::int > 130000 as v13
>
>
>>
>> SELECT current_setting('server_version_num')::int > =140000 as v14
>
>
> IOW, you can’t use >130000 because that will match v13.1 which is 130001
in integer format.
>
> David J.
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2025-03-24 01:15:54 | Re: Determine server version from psql script |
| Previous Message | David G. Johnston | 2025-03-23 19:27:19 | Re: Determine server version from psql script |