Does ActiveRecord.connection.execute(string) perform any modifications
on the given string?  If so, what quoting do I need to add?

Here's why: I'm trying to use execute(string) to load a stored
procedure.  I can hand-load the procedure without error (i.e. via
dbconsole), but when I call the function below, it throws the error:
====
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'DELIMITER $$
====
FWIW, I've pawed over the sources and see that mysql_adapter's execute()
calls @connection(query), but I lose the thread after that.  Here's the
function (some lines elided for brevity):
====
  sql = <<SQL
-- COVERAGE(astart, aend, bstart, bend)
--
DELIMITER $$
DROP FUNCTION IF EXISTS `coverage`$$
CREATE FUNCTION `coverage`(abeg DATETIME, aend DATETIME, bbeg DATETIME,
bend DATETIME)
  RETURNS FLOAT DETERMINISTIC
BEGIN
  <snip>
END;
$$
DELIMITER ;
SQL
  ActiveRecord::Base.establish_connection
  ActiveRecord::Base.connection.execute(sql)
end
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to