【发布时间】:2012-04-08 07:22:42
【问题描述】:
我曾经在邮件列表http://archives.postgresql.org/pgsql-hackers/2005-06/msg01481.php读过这篇文章
SELECT *
FROM foo_func(
c => current_timestamp::timestamp with time zone,
a => 2,
b => 5
);
现在我需要这种可以将关联数组参数传递给函数的解决方案。 我是否需要制作一个虚拟表,然后将该表用作参数类型?或者有什么直接的解决方法吗?或者这个黑客已经实施了吗?
或者我可以使用 pl/python 来模拟吗?
【问题讨论】:
-
您的意思是要将 hstore 值传递给函数吗? postgresql.org/docs/9.0/static/hstore.html
-
嗯不错的选择但是我得到
ERROR: type "hstore" does not exist我正在使用8.4 -
啊,我想那时候它只是一个contrib模块。如果你安装它应该可以工作。 postgresql.org/docs/8.4/static/hstore.html
-
好吧,我签入了
SELECT * FROM pg_available_extensions,但上面写着no such relation pg_available_extensions,你能告诉我如何安装它或检查它是否安装了吗? -
扩展是 9.1+ 的功能。我已将 8.4 的详细说明与代码示例放在单独的答案中。
标签: postgresql stored-procedures plpgsql