# PostgreSQL function in an insert statement

**URL:** <https://www.ruby-forum.com/t/postgresql-function-in-an-insert-statement/75651>\
**Category:** Rails\
**Created:** [March 2, 2006, 10:25am UTC](https://www.ruby-forum.com/t/postgresql-function-in-an-insert-statement/75651 "2006-03-02T10:25:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten\_Senf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de0a6/32.png) [@Torsten\_Senf](https://www.ruby-forum.com/u/Torsten_Senf)\
**Post date:** [March 2, 2006, 10:25am UTC](https://www.ruby-forum.com/t/postgresql-function-in-an-insert-statement/75651/1 "2006-03-02T10:25:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Torsten\_Senf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de0a6/32.png) [@Torsten\_Senf](https://www.ruby-forum.com/u/Torsten_Senf)\
**Post date:** [March 2, 2006, 10:31am UTC](https://www.ruby-forum.com/t/postgresql-function-in-an-insert-statement/75651/2 "2006-03-02T10:31:56Z")

</div>

I use extension for PostgreSQLAdapter to deal with PG large objects:  
[http://dev.rubyonrails.org/ticket/2090](http://dev.rubyonrails.org/ticket/2090)

And this to deal with functions and stored proc:

> **[BigBold - Informasi Tentang Bisnis dan Marketing](http://www.bigbold.com)**
>
> BigBold ialah situs yang memberikan segala macam Informasi Tentang Bisnis dan Marketing

HTH
