Re: How to call JSONB_INSERT with integer as the new to-be-inserted value?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to call JSONB_INSERT with integer as the new to-be-inserted value?
Date: 2020-09-12 21:26:24
Message-ID: 663494.1599945984@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Farber <alexander(dot)farber(at)gmail(dot)com> writes:
> ERROR: function jsonb_insert(jsonb, unknown, integer) does not exist
> LINE 1: SELECT JSONB_INSERT(_user, '{uid}', _uid)
> ^
> HINT: No function matches the given name and argument types. You might
> need to add explicit type casts.
> QUERY: SELECT JSONB_INSERT(_user, '{uid}', _uid)
> CONTEXT: PL/pgSQL function words_get_user(jsonb) line 44 at assignment

I think it'd work to do

JSONB_INSERT(_user, '{uid}', to_jsonb(_uid));

The third argument has to be jsonb, not something else.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2020-09-13 07:53:33 Re: How to call JSONB_INSERT with integer as the new to-be-inserted value?
Previous Message Steve Baldwin 2020-09-12 21:20:34 Re: How to call JSONB_INSERT with integer as the new to-be-inserted value?