views:

58

answers:

2

I have heard that one in PostgreSQL can write stored procedures in Ruby.

But I haven't been able to find more information about it teaching one how to actually do it.

Could someone recommend good sources for that.

Thanks

+4  A: 

Obviously, you need to install PL/Ruby. After that, you can write:

CREATE FUNCTION ruby_max(int4, int4) RETURNS int4 AS '
    if args[0].to_i > args[1].to_i
        return args[0]
    else
        return args[1]
    end
' LANGUAGE 'plruby';

Check its GitHub repository for installation instructions.

floatless
Also. http://rubyforge.org/projects/plruby/
rfusca
Hardest part is getting the pl/ruby install right, usually.
rfusca
Some information regarding installation: http://stackoverflow.com/questions/617600/installing-pl-ruby-for-postgresql
floatless
+1  A: 

Check this website: http://moulon.inra.fr/ruby/plruby.html , it has some nice examples.

Frank Heikens