Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from unnest(ARRAY[[1,2],[3,4]]);
- unnest
- --------
- 1
- 2
- 3
- 4
- (4 строки)
- create or replace function unnest_dim(in_array anyarray)
- returns setof anyarray as $$
- declare el in_array%type;
- begin
- foreach el slice 1 in array in_array
- loop
- return next el;
- end loop;
- end;
- $$ language plpgsql;
- select * from unnest_dim(ARRAY[[1,2],[3,4],[5,6]]);
- unnest_dim
- ------------
- {1,2}
- {3,4}
- {5,6}
- (3 строки)
- insert into users (user_id, role1_id, role2_id)
- select 15, r[1], r[2]
- from unnest_dim(ARRAY[[1,2],[3,4],[5,6]]) as r;
Add Comment
Please, Sign In to add comment