# PostgreSQL-Ruby extention: calling Postgres functions

**URL:** <https://www.ruby-forum.com/t/postgresql-ruby-extention-calling-postgres-functions/118764>\
**Category:** Ruby\
**Created:** [October 30, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/postgresql-ruby-extention-calling-postgres-functions/118764 "2007-10-30T18:52:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![htrex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@htrex](https://www.ruby-forum.com/u/htrex)\
**Post date:** [October 30, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/postgresql-ruby-extention-calling-postgres-functions/118764/1 "2007-10-30T18:52:01Z")

</div>

Hi all,  
I’m quite new to Ruby, and I have a question:  
I’m using the Postgres-ruby extention to connect to my Postgres db  
(require ‘postgres’ etc)  
Now I need to call existing db functions but I don’t know how…  
the function I want to call is

CREATE OR REPLACE FUNCTION sdr\_new.pprocess\_insert(pid\_process integer,  
pid\_client integer, pid\_entity integer, pppid integer, ppid\_process  
integer, pnotes character varying, pstatus integer, plast\_update  
timestamp without time zone, plogin\_usuario character varying, pip  
character varying)

as you can see it has a lot of parameter as well

Anyone could help me?

Cheers  
Alessandro

---

<div class="post-metadata">

**Author:** ![htrex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@htrex](https://www.ruby-forum.com/u/htrex)\
**Post date:** [October 30, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/postgresql-ruby-extention-calling-postgres-functions/118764/2 "2007-10-30T20:46:29Z")

</div>

> as you can see it has a lot of parameter as well
> 
> Anyone could help me?

not sure how it is done with raw postgres driver (is it the exec()  
method?) but if you use DBI ([http://ruby-dbi.rubyforge.org/](http://ruby-dbi.rubyforge.org/) ,  
[http://www.kitebird.com/articles/ruby-dbi.html](http://www.kitebird.com/articles/ruby-dbi.html)) the .do() method should  
do the trick.

The DBI in ruby is a standard method of interfacing to SQL databases (it  
has drivers for several of them). Advantage is that the DBI interface is  
pretty much same for all supported databases so in theory you could  
switch the database (and use different database driver) but your code  
would not change much…

Hope this helps,

Vlad
