Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. require 'mysql'
  2.  
  3. begin
  4. cnnxn = Mysql.new(hostname_or_ip,user,password,database,3306,nil,Mysql::CLIENT_MULTI_RESULTS)
  5. cnnxn.query_with_result = false
  6. sql = "call name_of_stored_procedure"
  7. cnnxn.query sql
  8.  
  9. no_more_results = false
  10. until no_more_results
  11. begin
  12. results=cnnxn.use_result
  13. results.each do |x|
  14. x.each_with_index do |value,i|
  15. puts "#{i}: #{value}"
  16. end
  17. end
  18. rescue Mysql::Error => e
  19. no_more_results=true
  20. end
  21. end
  22. ensure
  23. cnnxn.close
  24. end
Add Comment
Please, Sign In to add comment