From: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | Patrick FICHE <Patrick(dot)Fiche(at)aqsacom(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Syntax error for UPDATE ... RETURNING INTO STRICT |
Date: | 2019-12-03 11:37:55 |
Message-ID: | CAADeyWhikeMyuowX9X2BjRddruD+q0SkviMC-H7KFdbyX3AZGw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you Patrick -
On Tue, Dec 3, 2019 at 11:49 AM Patrick FICHE <Patrick(dot)Fiche(at)aqsacom(dot)com>
wrote:
>
> It seems that STRICT is the issue.
>
> But why does your function return a table of boolean in this case ?
>
> As it only updates one record, it would probably be easier to return a
> boolean only.
>
> CREATE OR REPLACE FUNCTION words_toggle_puzzle(
> in_mid bigint
> ) RETURNS boolean
> AS
> $func$
> UPDATE words_moves
> SET puzzle = NOT puzzle
> WHERE mid = in_mid
> RETURNING puzzle;
> $func$ LANGUAGE sql;
>
your suggestion works well, thank you.
I wanted to use strict, because the mid is a PK - so there should always be
an exactly one record that has been updated
(or otherwise, in very strange cases - the SQL would fail and my
java-servlet would throw SQLException)
Regards
Alex
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Janes | 2019-12-03 15:20:00 | Re: slow insert speeds with bytea |
Previous Message | Patrick FICHE | 2019-12-03 10:49:58 | RE: Syntax error for UPDATE ... RETURNING INTO STRICT |