title: Postgres function returning a row as JSON value
body: <p>I am pretty new to PG, and trying to convert from MSSQL.</p>
  
  <p>I am working on a function that will return JSON results.
  This one works:</p>
  
  <pre><code>Create Or Replace Function ExampleTable_SelectList()
  Returns JSON As
  $$
    Select array_to_json(array_agg(row_to_json(t))) From
      (Select id, value1, value2, From ExampleTable) t
  $$ Language SQL;
  </code></pre>
  
  <p>Now, I want to call can update that returns a value and turn that value into JSON to return. So, this one gives an error on the <code>set</code> command.</p>
  
  <pre><code>Create Or Replace Function ExampleTable_Update (id bigint, value1 text)
    Returns JSON As
  $$
    Select row_to_json(t) From
    (
      Update ExampleTable
      Set Value1 = value1
      Where id= id
      Returning Value1, Value2;
    ) t
  $$ Language SQL;
  </code></pre>
  
  <p>I suspect that Postgres does not allow the <code>UPDATE</code> statement as a subquery. Is there anyway around that?</p>