I am trying to write a simple plsql script to insert data in a table, which has jsonb as one of the columns
Example:
do $do$ declare
tel varchar:= '8000012000';
begin for i in 1..10 loop insert
into
t_tbl_sample(
lob,
prop_name,
prop_value,
prop_details
)
values(
'TN_ADD' || i,'ABC','XYZ',
'[{"specCode": {"name": "Telephone Number", "text": "TEL_NUM"}, "specValue": {"code": null, "text": tel}}]'
);
end loop;
end $do$;
But executing this gives an error:
ERROR: invalid input syntax for type json
LINE 11: '[{"specCode": {"name": "Telephone Number", "text": "TEL_NUM...
^
DETAIL: Token "tel" is invalid.
How can i write the pgSql to use a variable inside the JSONB element? Sounds like a simple requirement , but I could not find the syntax or reference anywhere