From: | Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com> |
---|---|
To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
Cc: | "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Return a table from a function |
Date: | 2021-04-07 11:54:31 |
Message-ID: | ZFN0GPmc3-cvrruskEt1dlawlju5kby21xy_MW1xJTxNv_UtGTWQXpviTt9jn7cM30t6e3YtQwLFSwXpmf9IjYK86jAc5BXT5E6uQVJP6T8=@protonmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, April 7th, 2021 at 09:44, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> On Tue, 2021-04-06 at 16:52 +0000, Simon Connah wrote:
>
> > I've written a function that returns a table. It works fine and I get the expected results.
> >
> > The only problem is that in Node.js which is the client the table data is a string rather
> >
> > than a list of variables. Is there some way to change the return data so it is still like
> >
> > a table but in something like JSON? Or even better is there a way to return it as the
> >
> > individual rows so that each column can be easily accessed? I'm using pg-promise to access
> >
> > PostgreSQL from a Node.js web application.
>
> It's a bit unclear what you are doing, but I guess you should run
>
> SELECT * FROM myfunction('arg');
>
> rather than
>
> SELECT myfunction('arg');
>
> Yours,
>
> Laurenz Albe
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Cybertec | https://www.cybertec-postgresql.com
That fixed it perfectly! Thank you.
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Connah | 2021-04-09 07:47:06 | Can't work out what is wrong with this code |
Previous Message | Laurenz Albe | 2021-04-07 08:44:08 | Re: Return a table from a function |