在opengauss6.0.2创建存储过程报[42601]错误

–在dbeaver客户端中执行下面创建存储过程的语句,报错[42601]

CREATE PROCEDURE insert_data (param1 INT = 0, param2 CHAR(20),param3 CHAR(20),param4 INT = 0 )
IS
BEGIN
INSERT INTO graderecord VALUES(param1,param2,param3,param4);
END;

–错误内容

SQL Error [42601]: ERROR: subprogram body is not ended correctly at end of input

Position: 172

版本是这个:

(openGauss 6.0.2 build 6285c0ef) compiled at 2025-07-15 15:13:08 commit 0 last mr 8059 on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 10.3.0, 64-bit

是语法存在问题吗?还是其他?谢谢

–晕,在Data Studio这样的书写格式才能被执行。。。。

CREATE OR REPLACE PROCEDURE public.procedure_name()
AS DECLARE

/*declaration_section*/

BEGIN

/*executable_section*/

END;
/
/

dbeaver如果使用postgresql的数据库类型,会无法解析ORACLE风格的创建存储过程语法。

可以使用dbeaver里的gaussdb数据库类型,或者使用mogeaver里的mogdb数据库类型,就没这个问题了。

1 Like

药到病除