Re: How to use Array in Array of Json
Steve Midgley <[email protected]> Mon, 25 Nov 2019 08:13:44 -0800
| Newsgroups | gmane.comp.db.postgresql.sql |
|---|---|
| Message-ID | <CAJexoS+5-VdD9YrWi=E800f_NoVRXsUMSutA_tdhzhksJZMPQg@mail.gmail.com> |
--000000000000d2eecf05982e0c5a Content-Type: text/plain; charset="UTF-8" On Mon, Nov 25, 2019 at 4:09 AM Monalee Bhandge < [email protected]> wrote: > Dear Friends, > My function definition is as: > > CREATE OR REPLACE FUNCTION schema1.samplefun1( > vin_comp_cd smallint, > vin_div_cd smallint, > vin_loc_cd smallint[], > vin_bt_cd integer[], > ) > > Here instead of passing parameter I want to just send a single i/p in > Json[]. > > My problem is how to pass array in Json[] variable. And how to use in code. > > > I believe you want a json conversion function. The entire list is here: https://www.postgresql.org/docs/current/functions-json.html I'm guessing that the following function would be very useful to take a single input json structure and convert it for insertion as single record in a table: json_populate_record I hope that is helpful? Steve --000000000000d2eecf05982e0c5a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Mon, Nov 25, 2019 at 4:09 AM Monal= ee Bhandge <<a href=3D"mailto:[email protected]">monalee.bhan= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" = style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa= dding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr">Dear Friends,<div>My func= tion definition=C2=A0is as:</div><div><br></div><div><div>CREATE OR REPLACE= FUNCTION schema1.samplefun1(</div><div>=C2=A0 =C2=A0 vin_comp_cd smallint,= </div><div>=C2=A0 =C2=A0 vin_div_cd smallint,</div><div>=C2=A0 =C2=A0 vin_l= oc_cd smallint[],</div><div>=C2=A0 =C2=A0 vin_bt_cd integer[],</div><div>= =C2=A0 )</div><div><br></div><div>Here instead of passing parameter=C2=A0I = want to just send a single i/p in Json[].</div></div><div><br></div><div>My= problem is how to pass array in Json[] variable. And how to use in code.</= div><div><br></div><br></div></div></blockquote><div>I believe you want a j= son conversion function. The entire list is here: <a href=3D"https://www.po= stgresql.org/docs/current/functions-json.html">https://www.postgresql.org/d= ocs/current/functions-json.html</a></div><div><br></div><div>I'm guessi= ng that the following function would be very useful to take a single input = json structure and convert it for insertion as single record in a table: <c= ode class=3D"gmail-literal">json_populate_record</code>=C2=A0</div><div><br= ></div><div>I hope that is helpful?</div><div>Steve<br></div></div></div> --000000000000d2eecf05982e0c5a--