Re: Determine server version from psql script - Mailing list pgsql-general

From Igor Korot
Subject Re: Determine server version from psql script
Date
Msg-id CA+FnnTyXFh+sXTOC7HMU0eLDmW0YLhWjX+Z89V9uzg5gtFcHLQ@mail.gmail.com
Whole thread Raw
In response to Re: Determine server version from psql script  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Determine server version from psql script
Re: Determine server version from psql script
List 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.g.johnston@gmail.com> wrote:
>
> On Sunday, March 23, 2025, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>>
>> Hi
>>
>> ne 23. 3. 2025 v 19:31 odesílatel Igor Korot <ikorot01@gmail.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.
>

pgsql-general by date:

Previous
From: Igor Korot
Date:
Subject: Re: Determine server version from psql script
Next
From: "David G. Johnston"
Date:
Subject: Re: Determine server version from psql script