创建存储过程时 Informix 数据库出错 "SQLState: 42000 ErrorCode: -201 Position: 167"

Informix db error while creating stored procedure "SQLState: 42000 ErrorCode: -201 Position: 167"

我试图在 informix 数据库中创建一个存储过程,但是当我尝试 运行 创建过程代码时,第一行出现以下错误:

Error: A syntax error has occurred.
SQLState:  42000
ErrorCode: -201
Position: 167
Error occurred in:
create procedure test(p_from_date date, p_to_date date, p_department_id like department.id, p_username LVARCHAR(100)) returning decimal

DEFINE v_report LVARCHAR(32100)

这是我的代码:

create procedure test(p_from_date date, p_to_date date, p_department_id like department.id, p_username LVARCHAR(100)) returning decimal

DEFINE v_report LVARCHAR(32100);
DEFINE v_report_result_id LIKE report_result.id;
DEFINE v_amount, v_bank_amount, v_nap_amount, v_pos_amount DECIMAL(16);
DEFINE v_f_report_result    SMALLINT;
DEFINE v_order_number    LIKE report_result.order_number;
DEFINE v_payment_canal, v_type LVARCHAR(20);
DEFINE v_department_name like department.name;
DEFINE v_rownum integer;
DEFINE v_current_time VARCHAR(30);
.
.<rest of the code>
.
return v_report_result_id;

END PROCEDURE;

我找到问题所在了。

需要将 statement separator; 更改为代码中未使用的任何其他内容(我将其更改为 @)。

因为解释器将在代码中找到的第一个 ; 字符(位于第一行)被解释为整个代码的结尾(整个过程创建)。

我正在使用 SQurreL 并将 statement separator 更改为:session > session properties > SQL > statement separator.

我希望这会帮助其他遇到同样问题的人。