It works fine in SQL directly.

Taking the DELIMITER out breaks.

I think it's because DELIMITER is a command and not SQL.

I got around it by looping through my file differently in ruby.

On Wednesday, 27 May 2015 16:19:54 UTC+1, Jeremy Evans wrote:
>
> On Wednesday, May 27, 2015 at 8:03:52 AM UTC-7, Ian Winter wrote:
>>
>> I'd like to run an arbitray bit of SQL as part of a rake task to setup a 
>> test DB, but, Sequel doesn't seem to like the MySQL keyword DELIMITER.
>>
>> If I have this in a SQL file:
>>
>> DELIMITER $$
>> CREATE TRIGGER `test_ins` AFTER INSERT ON `table` 
>> FOR EACH ROW
>> BEGIN
>> IF(NEW.`rating` = 1) THEN
>> INSERT INTO `new_table` (`a`, `b`, `c`) VALUES (NEW.`a`, NEW.`b`, 
>> NEW.`c`);
>> END IF;
>> END $$
>>
>> When I use Sequel::Model.db.run(ddl) ; where ddl is the above, it errors 
>> with:
>>
>> Sequel::DatabaseError: Mysql2::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 $$
>>
>> Is there anyway to make this work at all?
>>
>
> I don't think that error is related to Sequel.  Sequel is just sending 
> that SQL to the database, which is raising an error.  Does that syntax work 
> on the MySQL command line, or when using mysql2 directly?
>
> Can you just drop the DELIMTER $$ from the beginning and $$ from the end 
> and try again?
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to