【问题标题】:How to use postgres stored procedures with Node pg package? or without pg package in Node Expressjs applications如何在 Node pg 包中使用 postgres 存储过程?或在 Node Expressjs 应用程序中没有 pg 包
【发布时间】:2015-07-03 14:13:48
【问题描述】:

如何在 Node pg 包中使用 postgres 存储过程?或者在 Node Expressjs 应用程序中没有 pg 包。我能够运行内联查询,但不知道如何使用存储过程。

【问题讨论】:

标签: node.js postgresql express


【解决方案1】:

postgres 使用函数而不是过程。如果你想执行一个忽略返回的函数,你可以创建它而不返回,或者通过PERFORM运行它,而不是SELECT... 在所有其他方面,运行函数与运行查询相同:

environments=# select * from now();
              now
-------------------------------
 2015-07-03 08:19:30.096488+02
(1 row)

environments=# select now();
              now
-------------------------------
 2015-07-03 08:19:40.260368+02
(1 row)

environments=# do
environments-# $$
environments$# begin
environments$# perform now();
environments$# end;
environments$# $$
environments-# ;
DO

【讨论】:

    猜你喜欢
    • 2017-03-05
    • 2014-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-19
    • 2016-05-01
    相关资源
    最近更新 更多