You should mention the exact error message instead of "doesn't work".
When you want a SP to return answer sets you have to define it with "dynamic result sets":
replace procedure GetQuery(OUT xToken varchar(2000)) dynamic resuklt sets 1
and use a cursor for the select instead of "execute immediate":
begin
declare c cursor with return only for s;
prepare s1 from sqlQuery;
open c1;
end;
But, you defined sqlQuery as a VarChar(2000) and try to insert 400 times "select * from (select ... as x) dt union", which estimates to roughly 16KB.
And you forgot to add a final semicolon to the query text.
Dieter
↧