如何创建不返回任何内容的函数 [英] How to create function that returns nothing

查看:285
本文介绍了如何创建不返回任何内容的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用pl/pgsql编写一个函数. 我正在使用 PostgresEnterprise Manager v3 并使用shell来创建函数,但是我必须在shell中定义返回类型.如果未定义返回类型,则无法创建函数.

I want to write a function with pl/pgsql. I'm using PostgresEnterprise Manager v3 and using shell to make a function, but in the shell I must define return type. If I don't define the return type, I'm not able to create a function.

如何创建没有返回结果的函数,即创建新表的函数?

How can create a function without return result, i.e a Function that creates a new table?

推荐答案

使用RETURNS void如下:

CREATE FUNCTION stamp_user(id int, comment text) RETURNS void AS $$
    #variable_conflict use_variable
    DECLARE
        curtime timestamp := now();
    BEGIN
        UPDATE users SET last_modified = curtime, comment = comment
          WHERE users.id = id;
    END;
$$ LANGUAGE plpgsql;

这篇关于如何创建不返回任何内容的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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