Using row_to_json with %ROWTYPE ?

From: Tim Smith <randomdev4+postgres(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Using row_to_json with %ROWTYPE ?
Date: 2015-02-05 21:38:21
Message-ID: CA+HuS5EbRgf49KBhBjF5hgT7-GEn7S-GeAkLks7xkzMqCCOfzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 ?

Thanks

Tim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-02-05 21:57:29 Re: Using row_to_json with %ROWTYPE ?
Previous Message Rémi Cura 2015-02-05 16:07:27 Re: How do I bump a row to the front of sort efficiently