存储过程与函数不能同名

最近更新时间: 2024-10-17 17:10:00

如创建一个与函数同名的存储过程会提示function xxx already exists with same argument types。

postgres=# CREATE OR REPLACE FUNCTION proc_1() RETURNS void AS
$$
begin
   raise notice 'Hello TBase';
end;
$$
LANGUAGE PLPGSQL;
CREATE FUNCTION
postgres=# CREATE  PROCEDURE proc_1() AS                      
$$
begin
   raise notice 'Hello TBase';
end;
$$
LANGUAGE PLPGSQL;
ERROR:  function "proc_1" already exists with same argument types
postgres=#
#如果你要替换,则提示
postgres=# CREATE OR REPLACE PROCEDURE proc_1() AS                      
$$
begin
   raise notice 'Hello TBase';
end;
$$
LANGUAGE PLPGSQL;
ERROR:  cannot change routine kind
DETAIL:  "proc_1" is a function.
postgres=#