Forum: Ruby on Rails PostgreSQL function in an insert statement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Torsten Senf (Guest)
on 2006-03-02 11:25
(Received via mailing list)
Hi there,

I wont insert a picture in a PostgrSQL-DB via the function lo_import.
Therfore I modify the value of an 'oid' column.

@measurepoint = Measurepoint.new(params[:measurepoint])
@measurepoint.measurepoint_background =
"lo_import('#{@params['measurepoint']['measurepoint_background']')"
@measurepoint.save

The result is an error like this:

PGError: ERROR:  invalid input syntax for type oid:

because the function is quotet in the values of the insert statement.

'lo_import('picture')'
^                    ^

These quotes are responsible for a wrong interpretation from the
database,
because a function in quotes is not a function, its a string.

Is it possible to give the modified insert statement without quotes to
the
insert statement.

Thank you for a solution and please apologize my bad english.



--
Torsten Senf
Lugovoi N. (Guest)
on 2006-03-02 11:31
(Received via mailing list)
I use extension for PostgreSQLAdapter to deal with PG large objects:
http://dev.rubyonrails.org/ticket/2090

And this to deal with functions and stored proc:
http://www.bigbold.com/snippets/posts/show/1008

HTH
This topic is locked and can not be replied to.