Hi all,

I'm using sqlite3 for storage in my ruby program. I want to be able to
edit information in a single cell for a row that already exists. Here is
my current code:

def loan_book
  puts "Which book is being loaned out?"
  title_of_book = gets.chomp
  book_to_loan = $db.execute("SELECT * FROM books WHERE title = ?",
title_of_book).first

  if "#{book_to_loan['loanedTo']}" == ''
    puts "This book is not loaned out to anyone."
    sleep(1)
    puts "Who are you loaning this book to?"
    person_borrowing_book = gets.chomp
    $db.execute("UPDATE books SET loanedTo=? WHERE title = ?",
person_borrowing_book, book_to_loan)
    sleep(1)
    puts "Alright! The book is now loaned out to
#{person_borrowing_book}"
    sleep(1)
  else
    puts "This books is currently loaned out to
#{book_to_loan['loanedTo']}"
  end
end

When I run this program, and try the 'Loan a book to someone' choice, I
get an error when:

$db.execute("UPDATE books SET loanedTo=? WHERE title = ?",
person_borrowing_book, book_to_loan)

tries to run. Any thoughts as to why this is? I've included my code in
this post.

Attachments:
http://www.ruby-forum.com/attachment/9074/library_client.rb
http://www.ruby-forum.com/attachment/9075/books.db


-- 
Posted via http://www.ruby-forum.com/.