1

I have the following 2 files:

20161009180554_add_process_functionst_to_db.rb

class AddProcessFunctionstToDb < ActiveRecord::Migration
  def up
    funcs = File.read(Rails.root.join('db', 'migrate', 'processfunctions.sql').to_s)
    execute funcs
  end
end

processfunctions.sql

drop function if exists retention_data(ref refcursor, shopId integer);
create or replace function retention_data(ref refcursor, shopId integer) returns refcursor as $$
    begin
...
    return ref;
    end;
$$ language plpgsql;

I am trying to add the function in processfunctions.sql to the database. But when I run

rake db:migrate

I get the following error:

/app/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near ""
LINE 1: 
        ^
: 
drop function if exists retention_data(ref refcursor, shopId integer);

after 'Line 1: ' in the error (what the arrow is pointing at) is a rectangle. Like what you would see if you didn't have the right font installed.

I have removed the blank line on line 1 and changed from CRLF to LF, but neither of those changed anything

2
  • 1
    Does processfunctions.sql contain what you think it does? Maybe have a look at it with cat -vet or look at a hex dump. Commented Oct 9, 2016 at 19:46
  • Cool, that worked! Thanks Commented Oct 9, 2016 at 20:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.