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