开发者

Ruby tutorial for how to write stored procedures for PostgreSQL?

开发者 https://www.devze.com 2023-01-09 22:51 出处:网络
I have heard that one in Postgr开发者_StackOverflow社区eSQL can write stored procedures in Ruby.

I have heard that one in Postgr开发者_StackOverflow社区eSQL 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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消