-2
UPDATE s SET sb = sb ||
                  ('{"filded": [{"@value": ' ||
                  sb@>>'{filded,0, @value}'::integer + 1 ||
                  '}],"lastFailure ": '[{"@t": "DateTime", "@value": "$1"}],ln": '[{"@type": "DateTime", "@value": "$1"}])::jsonb
WHERE sbi=$2

this is my postgres sql query which i am trying to run in thi pgAdmin but it giving error

ERROR:  syntax error at or near "["
LINE 1: ...d,0, @value}'::integer + 1 ||'}],"lastFailure ": '[{"@t": "D...
                                                             ^
SQL state: 42601
Character: 116
2
  • Try not to build JSON values by string concatenation Commented Apr 23, 2023 at 3:53
  • You have single quotes in the middle of the string, and I have no idea what you are trying to do? Commented Apr 23, 2023 at 5:40

1 Answer 1

0

Merely a guess on your mess:

UPDATE s
SET    sb = sb
         || ('{"filded":[{"@value":'
         || (sb #>> '{filded,0,@value}')::integer + 1
         || '}], "lastFailure":[{"@t":"DateTime", "@value":"$1"}], "ln":[{"@type":"DateTime", "@value":"$1"}]}')::jsonb
WHERE  sbi = $2;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.