Declare an array datatype in the function then use the aggregate function array_agg to transform the select statement into an array CREATE OR REPLACE FUNCTION users_function(myints integer) $$ BEGIN -- you need to find the bounds with array_lower and array_upper FOR I in array_lower(myints, 1) .. array_upper(myints, 1) LOOP Raise Notice '%', myintsi::integer; END LOOP; END; $$ select * from users_function(array_agg((select user_id from profiles))).
Declare an array datatype in the function then use the aggregate function array_agg to transform the select statement into an array. CREATE OR REPLACE FUNCTION users_function(myints integer) $$ BEGIN -- you need to find the bounds with array_lower and array_upper FOR I in array_lower(myints, 1) .. array_upper(myints, 1) LOOP Raise Notice '%', myintsi::integer; END LOOP; END; $$ select * from users_function(array_agg((select user_id from profiles))).
I'm running PostgreSQL 8.4.4 and getting this error. Any ideas? Select array_agg(select id from users limit 2); ERROR: syntax error at or near "select" – Chirag Patel Feb 16 at 0:53 Add another set of brackets like: select array_agg((select id from users limit 2)).
Forgot that - any time you have a subquery in a function you need two sets: one for the function an one for the subquery. – nate c Feb 16 at 3:03 Sorry to keep bothering you, but this is what I got: select array_agg((select id from users limit 2)); ERROR: more than one row returned by a subquery used as an expression – Chirag Patel Feb 16 at 5:48.
I could not get the nate c's array_agg approach as I described above. This is an option: select * from test_array('{1,2}'); CREATE OR REPLACE FUNCTION test_array(user_ids integer) RETURNS void AS $$ declare begin FOR I in array_lower(user_ids, 1) .. array_upper(user_ids, 1) LOOP RAISE NOTICE '%', user_idsi::integer; END LOOP; end $$ LANGUAGE plpgsql.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.