Skip to content

Instantly share code, notes, and snippets.

@jasonlyles
Created January 12, 2011 21:08
Show Gist options
  • Save jasonlyles/776882 to your computer and use it in GitHub Desktop.
Save jasonlyles/776882 to your computer and use it in GitHub Desktop.
require 'mysql'
begin
cnnxn = Mysql.new(hostname_or_ip,user,password,database,3306,nil,Mysql::CLIENT_MULTI_RESULTS)
cnnxn.query_with_result = false
sql = "call name_of_stored_procedure"
cnnxn.query sql
no_more_results = false
until no_more_results
begin
results=cnnxn.use_result
results.each do |x|
x.each_with_index do |value,i|
puts "#{i}: #{value}"
end
end
rescue Mysql::Error => e
no_more_results=true
end
end
ensure
cnnxn.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment