File: email1.rb

Project: Invitation to Ruby

#!/usr/bin/env ruby

require 'dbi'

db = DBI.connect ("DBI:Pg:jim", "jim")

sql = <<-SQL
SELECT email
FROM person, email
WHERE person.personid = email.personid
AND person.nick = ? 
ORDER BY nick, type
SQL

db.prepare(sql) { |statement|
  statement.execute(ARGV[0])
  statement.each { |row|
    puts row[0]
  }
}

db.disconnect


[ Index ][ Table of Contents ]
Generated by [ source2html ]