Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Update as a function result
drop function if exists f(); drop table if exists t; create table t(i serial primary key, x int); insert into t(x) select random()*10 from generate_series(1,10); create function f() returns setof t language plpgsql as $$ declare r t[]; begin -- How to get result into the variable and return it with a as (update t set x = x*2 where i > 5 returning *) select array_agg(a.*) into r from a; return query select * from unnest(r); -- How to return result of update (just remove parenthesises around it) return query update t set x = x*2 where i > 5 returning *; end $$; select * from f();
run
|
edit
|
history
|
help
0
Replace key of json
1075-1077 Project Analysis
Engenheiro
sql
Assignment 1(SET A)
Tememons Dashboard
Cross Tab With Totals
Correlated subquery in SELECT clause, and rewritten for Netezza
Recursive inefficiency
PostgreSQL aggregate JSON recordset keys by row