Ruby tutorial for writing stored procedures for PostgreSQL?

I heard that in PostgreSQL you can write stored procedures in Ruby.

But I could not find more information about this, teaching how to actually do it.

Can anyone recommend good sources for this.

thanks

+6
ruby postgresql
source share
2 answers

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

+2
source share

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 out his GitHub repository for installation instructions.

+7
source share

All Articles