From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Tim Smith <randomdev4+postgres(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Using row_to_json with %ROWTYPE ? |
Date: | 2015-02-05 21:57:29 |
Message-ID: | 54D3E749.8020607@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 02/05/2015 01:38 PM, Tim Smith wrote:
> Hi,
>
> I have a function that broadly looks like this :
>
> create function doStuff() returns json as $$
> DECLARE
> v_row my_view%ROWTYPE;
> BEGIN
> select * into strict v_row from my_view where foo=bar;
> select row_to_json(v_row) from v_row;
> END;
> $$ LANGUAGE plpgsql;
>
>
> However this does not seem to work ? What am I doing wrong ?
Well for starters is:
select * into strict v_row from my_view where foo=bar;
returning more than one row? v_row can only hold one row at a time.
Given that then:
select row_to_json(v_row) from v_row;
should be:
select row_to_json(v_row);
I would suggest taking a look at:
Also error messages would be helpful:)
>
> Thanks
>
> Tim
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | David G Johnston | 2015-02-05 21:59:21 | Re: Using row_to_json with %ROWTYPE ? |
Previous Message | Tim Smith | 2015-02-05 21:38:21 | Using row_to_json with %ROWTYPE ? |