如何将值设置为postgres存储函数的OUT args

时间:2017-06-20 14:05:52

标签: postgresql

此函数未编译(语法错误处于或接近“f1”位置:92),它说明了我想要实现的伪代码:

CREATE OR REPLACE FUNCTION tmp_my_func(x INTEGER, OUT f1 INTEGER, OUT f2 INTEGER)
AS $$
      f1 := x*2;
      f2 := x*3;    
$$ LANGUAGE SQL;

2 个答案:

答案 0 :(得分:0)

HttpCookie _forceEntry = Request.Cookies["_forceEntry"];

if (_forceEntry == null)
{
    _forceEntry = new HttpCookie("_forceEntry");
    _forceEntry.Values.Add("_forceEntry", "false");
    Response.Cookies.Add(_forceEntry);
}

if (Request.QueryString["ForceOldIE"] != null)
{
    _forceEntry["_forceEntry"] = "true";
}

if (_unsupportedBrowser.Values["_unsupportedBrowser"].ToString() == "true" && _forceEntry["_forceEntry"] == "false")
    Response.Redirect("~/SupportedBrowsers/Index?applicationId=1");

将返回2,3

答案 1 :(得分:0)

如果要使用LANGUAGE sql,则必须是SQL语句

CREATE OR REPLACE FUNCTION tmp_my_func(x integer, OUT f1 integer, OUT f2 integer)
   LANGUAGE sql AS
'SELECT x*2, x*3';

在PL / pgSQL中,它看起来像这样:

CREATE OR REPLACE FUNCTION tmp_my_func(x integer, OUT f1 integer, OUT f2 integer)
   LANGUAGE plpgsql AS
'BEGIN
   f1 := 2*x;
   f2 := 3*x;
END;';