[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

PostgreSQL-Ruby extention: calling Postgres functions

Alessandro Cipriani

10/30/2007 5:52:00 PM

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
--
Posted via http://www.ruby-....

1 Answer

Vladimir Konrad

10/30/2007 7:42:00 PM

0

> 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?

not sure how it is done with raw postgres driver (is it the exec()
method?) but if you use DBI (http://ruby-dbi.ruby... ,
http://www.kitebird.com/articles/rub...) 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