可以从plv8函数中调用另一个模式中的函数吗? [英] It's possible to call functions in another schema from within plv8 functions?

查看:80
本文介绍了可以从plv8函数中调用另一个模式中的函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用plv8编写postgres函数。现在,我想以这种方式使用pgcrypt库:

I'm trying to use plv8 to write postgres functions. Now I would like to use the pgcrypt library in a way like this:

CREATE OR REPLACE FUNCTION v01.myfunction(arg json) 
RETURNS json AS
$BODY$
  var res;
  res = obj.crypt(arg.password, res);
  plv8.elog(NOTICE, res);
  ...

$BODY$
LANGUAGE plv8;

crypt是pgcrypt库附带的,可以在另一个模式中找到。但是,如果运行,则会出现错误:

Where crypt comes with the pgcrypt library and is find in another schema. But if running I get the error:

ERROR:  ReferenceError: obj is not defined

有什么想法吗?谢谢!

推荐答案

好,我发现了:

var pp = plv8.execute("SELECT obj.crypt($1,$2)",[arg.password, cpw]);

简单:-)

这篇关于可以从plv8函数中调用另一个模式中的函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆