postgre中类似oracle的sql%rowcount用法

get diagnostics cnt := row_count;

现在有两个表tab1和tab2,两个表的格式相同,tab1中有1000条数据,tab2中0条数据

创建测试功能函数

create or replace function test_fun()

    return integer as

$body$

declare

    rowcnt integer;

begin

    insert into tab2 select * from tab1;

    get diagnostics rowcnt := row_count;

    return rowcnt;

end;

$body$

    LANGUAGE plpgsql VOLATILE;

ALTER FUNCTION test_fun()

  OWNER TO gpadmin;

 

执行

select test_fun()

返回结果1000

posted @ 2018-09-13 16:42  咻_python  阅读(1978)  评论(0编辑  收藏  举报