Direct sql statement in rails

Hi
I would like how can I execute a query like (Postgres sql)
INSERT INTO oids (“filename”, “picture”)
VALUES(‘logo.png’,lo_import(file));

in rails…Why I am asking this is I have a table oids having fields

id | integer | not null default
nextval(‘oids_id_seq’::regclass)
filename | character varying(255) | default NULL::character varying
picture | oid

I am trying to save an image file directly to picture field…My view
file is

<%= form_tag ({:action => “createoid”}, {:enctype =>
‘multipart/form-data’}) %>
Picture for OID
<%= file_field_tag “logo” %>
<%= submit_tag “Save” %>
<%= end_form_tag %> and controller is

def createoid
@pi = Oid.new
@pi.filename=params[:logo].original_filename.gsub(/[^a-zA-Z0-9.]/,
‘_’)
@pi.picture=params[:logo].read
@pi.save
end

  I am getting error

ArgumentError: Invalid Ruby/cstring: INSERT INTO oids (“filename”,
“picture”) VALUES(‘logo.png’, '�PNG���
Then some nonreadable chlues like above
And if the datatype above where bytea instead of oid no problem

Please help
Thanks in advance
Sijo

Sijo Kg wrote:

Hi
I would like how can I execute a query like (Postgres sql)

Take a look at the execute method on the connection object:

http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M001488&name=execute

Peace,
Phillip