Hi,
Thanks for the reply.
Yes, I've tried several different variations on that approach, with mostly
the same results.
For example:
Sequel.migration do
up do
if $db_type == :mysql
run <<EOF
DELIMITER $$
CREATE FUNCTION GetTermType(f_subject_id INT)
RETURNS VARCHAR(255)
READS SQL DATA
BEGIN
DECLARE f_term_type VARCHAR(255) DEFAULT "";
SELECT enumeration_value.`value` INTO f_term_type
FROM term
INNER JOIN enumeration_value
ON term.`term_type_id` = enumeration_value.`id`
WHERE term.`id`
IN (SELECT subject_term.`term_id`
FROM subject_term
WHERE subject_term.`subject_id` = f_subject_id)
LIMIT 1;
RETURN f_term_type;
END
$$
EOF
end
end
end
Which results in this:
[java] Sequel::DatabaseError:
Java::ComMysqlJdbcExceptionsJdbc4::MySQLSyntaxErrorException: 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 $$
[java] CREATE FUNCTION GetTermType(f_subject_id INT)
[java] RETURNS VARCHAR(2' at line 1
At first I thought there was an encoding issue, but it always seems to cut
off at about 80 character length.
This might be at the connector level?
b,chris.
On Wednesday, June 24, 2015 at 3:01:31 AM UTC+2, Jeremy Evans wrote:
>
> On Tuesday, June 23, 2015 at 3:24:48 PM UTC-7, Chris Fitzpatrick wrote:
>>
>>
>> Hi,
>>
>> I have an application that uses sequel and sequel migrations. I've been
>> asked to add a bunch of stored procedures that I have in a sql file, but am
>> not sure about the best way to do this.
>> I've tried passing the sql to the db using the run method, but this has
>> some odd results as the sql statements seem to get truncated.
>> I am using the mysql jdbc adapter.
>>
>> thanks for any suggestions.
>>
>
> In a migration, for each SQL statement:
>
> run "SQL"
>
> If you must keep it in a separate SQL file, you can try:
>
> File.read('file.sql').split(';').each{|sql run sql}
>
> But that will not work if you have a semicolon that isn't used a statement
> deliminator in the file.
>
> 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.