Problem with parameterised CASE UPDATE

From: Mike Martin <mike(at)redtux(dot)plus(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Problem with parameterised CASE UPDATE
Date: 2020-06-03 16:33:23
Message-ID: CAOwYNKaRNDMSCE1w6CxnyqDXzqoqTqjdmqne8wFCkhX2D=YJEw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi
I have the following query

PREPARE chk AS
UPDATE transcodes_detail td
SET
sortid=CASE WHEN $1 = 6 THEN $2::numeric ELSE td.sortid END
WHERE detailid=$3
execute chk (7,'1c',73)

It fails as ERROR: invalid input syntax for type numeric: "1c"
It seems to check all parameters before it tests whether parameter 1
equates to 6 (in this instance).

Is there a way round this

thanks in advance

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Midgley 2020-06-03 18:02:27 Re: Problem with parameterised CASE UPDATE
Previous Message Mark Bannister 2020-06-03 13:52:40 Recursive CTE with a function