Bird
0
0

A query using jsonb_set() function returns an error. Which of these is the most probable cause?

medium📝 Debug Q7 of 15
PostgreSQL - JSON and JSONB
A query using jsonb_set() function returns an error. Which of these is the most probable cause?
AThe path argument is missing brackets.
BThe first argument is of type <code>json</code> instead of <code>jsonb</code>.
CThe function does not exist in PostgreSQL.
DThe JSON data contains duplicate keys.
Step-by-Step Solution
Solution:
  1. Step 1: Understand jsonb_set() requirements

    This function requires the first argument to be jsonb type.
  2. Step 2: Identify common error causes

    If the first argument is json, the function call fails. Missing brackets or duplicates cause different errors.
  3. Final Answer:

    The first argument is of type json instead of jsonb. -> Option B
  4. Quick Check:

    jsonb_set requires jsonb input = A [OK]
Quick Trick: jsonb_set only accepts jsonb, not json [OK]
Common Mistakes:
  • Passing json instead of jsonb
  • Incorrect path syntax
  • Assuming function is unavailable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes