| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> | 
|---|---|
| To: | Tim Smith <randomdev4+postgres(at)gmail(dot)com>, Marc Mamin <M(dot)Mamin(at)intershop(dot)de> | 
| Cc: | David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: Using row_to_json with %ROWTYPE ? | 
| Date: | 2015-02-06 16:11:54 | 
| Message-ID: | 54D4E7CA.9080407@aklaver.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On 02/06/2015 05:33 AM, Tim Smith wrote:
> Nice work-around Marc.  Thank you !
>
Nice that it works, but in the end it proves that the issue is not with 
row_to_json and a row type, but with how %ROW_TYPE is being used in a 
specific function. To prove it, using your earlier function modified for 
your latest test case:
CREATE OR REPLACE FUNCTION public.dostuff()
  RETURNS json
  LANGUAGE plpgsql
AS $function$
DECLARE
v_row app_val_session_vw %ROWTYPE;
j_return json;
BEGIN
select * into strict v_row from app_val_session_vw where user_id=1;
select into j_return row_to_json(v_row);
RETURN j_return;
END;
$function$
test=# select dostuff();
                                       dostuff 
-----------------------------------------------------------------------------------
 
{"session_id":441122,"session_ip":"10.11.12.13","user_name":"Foobar","user_id":1}
(1 row)
-- 
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2015-02-06 16:28:50 | Re: Cluster seems broken after pg_basebackup | 
| Previous Message | Adrian Klaver | 2015-02-06 15:56:49 | Re: Using row_to_json with %ROWTYPE ? |