Answer the question
In order to leave comments, you need to log in
Getting result in Activerecord?
Hello. There is such a command in Activerecord, how can I get the result of the last SELECT
sql = <<-SQL.squish
BEGIN;
CREATE TEMP TABLE timesheets_get ( child_code )
ON COMMIT DROP
AS ( VALUES
( '6061788 '::VARCHAR(9) )
);
CREATE INDEX ON timesheets_get( child_code );
SELECT bb.id, aa.*
FROM timesheets_get aa
LEFT JOIN children bb ON aa.child_code = bb.code;
COMMIT;
SQL
result = ActiveRecord::Base.connection.execute( sql )
puts result
Answer the question
In order to leave comments, you need to log in
Try this.
ActiveRecord::Base.connection.execute( sql ).each |row|
p row
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question