Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. drop function ProcessReward();
  2. CREATE OR REPLACE FUNCTION ProcessReward()
  3. RETURNS text AS $$
  4. DECLARE
  5. sessionid NO SCROLL CURSOR FOR SELECT pg."Setting",pg."UserId",pg."Id" FROM "Development"."PersonGame" pg inner join "Development"."Game" g on g."Id" = pg."GameId" pg."GameId"=1 for read only;
  6. titles TEXT DEFAULT '';
  7. rec record;
  8. jsonrec record;
  9. jsonrecord record;
  10. BEGIN
  11. OPEN sessionid;
  12. loop
  13.  
  14. FETCH sessionid INTO rec;
  15. if not found then
  16. exit ;
  17. end if;
  18. EXECUTE 'select * from "Development"."GameRecipient" where "PersonGameId"=$1' into jsonrecord using rec."Id";
  19. --I want to loop here every row returned by above query
  20. --loop start
  21. -- do your task
  22.  
  23. --loop end
  24.  
  25. end loop;
  26. return titles;
  27. END;
  28. $$ LANGUAGE plpgsql;
  29.  
  30. col1 col2 col3
  31. 123 324 444
  32. 345 222 765
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement