在Postgres中的plperl函数中访问current_settings函数

时间:2018-11-06 19:40:44

标签: postgresql perl plperl

我正在Postgres中编写我的第一个plperl函数,我需要访问current_settings()区域中的某些值(通过使用该调用)-我想知道这样做的最佳解决方案是什么? / p>

在plpgsql中,我可以执行以下操作:

DECLARE
  cid int;
BEGIN
  select nullif(current_setting('jwt.claims.customerId', true), '') :: int into cid;
END ...

只是想知道在Perl plperl脚本中是否可以访问诸如current_setting之类的系统功能。

谢谢!

1 个答案:

答案 0 :(得分:1)

使用database access functions之一,例如:

$rv = spi_exec_query("select nullif(current_setting('jwt.claims.customerId', true), '')::int as cid");
$cid = $rv->{rows}[0]->{cid};
相关问题