Ann Nguyen
Ann Nguyen

Reputation: 23

CASE WHEN not working for some values with incorrect syntax

I am trying to do a case when update statement but I keep getting a Incorrect syntax near '‭'. error. I don't get it because the second query below runs just fine but the first one doesn't. Only difference is I am setting memrvam to 1.24 instead 8.48.

UPDATE a
SET memslam = CASE detseqno
                 WHEN 1923 THEN 338.63
                 WHEN 43 THEN 355.56
              END,
    memrvam = CASE detseqno
                 WHEN 1923 THEN ‭8.48‬
                 WHEN 43 THEN 8.89
              END
FROM slst1consl a
LEFT JOIN wprsbatchxref b ON b.batchnum = a.batchid
                          AND b.recdate = a.recdt
                          AND b.supplier_date = a.supdt
WHERE b.batch_id IN(2058708, 2058709)
  AND memid = 922269
  AND detseqno IN (1043, 43);

UPDATE a
SET memslam = CASE detseqno
                 WHEN 1923 THEN 338.63
                 WHEN 43 THEN 355.56
              END,
    memrvam = CASE detseqno
                 WHEN 1923 THEN 1.24
                 WHEN 43 THEN 8.89
              END
FROM slst1consl a
LEFT JOIN wprsbatchxref b ON b.batchnum = a.batchid
                          AND b.recdate = a.recdt
                          AND b.supplier_date = a.supdt
WHERE b.batch_id IN (2058708, 2058709)
  AND memid = 922269
  AND detseqno IN (1043, 43);

Upvotes: 0

Views: 36

Answers (1)

Thorsten Kettner
Thorsten Kettner

Reputation: 94904

There are hidden special characters there:

                THEN 8.48

When copying this line to my editor I see

                THEN ?8.48?

So, just remove the line and write it anew.

Upvotes: 1

Related Questions