1

Is there a way to accomplish something like:

select array(update table set value = '' where condition returning another_value)

This one seems to give a syntaxerror. I imagine I could wrap the inner part inside a function...

root
  • 76,608
  • 25
  • 108
  • 120

1 Answers1

2

I think this should work:

WITH Result AS (
  update table set value = '' where condition returning another_value
)
SELECT array(SELECT * FROM Result)

Seems a little clunky to me, but I couldn't simplify it any further without running into syntax errors...

Nick Barnes
  • 19,816
  • 3
  • 51
  • 63
  • Data-modifying statements are not allowed in simple subqueries. [That's only possible with CTEs](http://stackoverflow.com/questions/22749253/are-select-type-queries-the-only-type-that-can-be-nested/22750328#22750328). – Erwin Brandstetter Jun 20 '14 at 11:05