Search code examples
databasestored-proceduresinformix

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


I am trying to create a stored procedure in informix database, but when I try to run the create procedure code the following error appears on the very first line:

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)

this is my code:

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;

Solution

  • I found out what the problem was.

    The statement separator needed to be changed from ; to whatever else that is not used inside the code (I changed it to @).

    Because on the first ; character that the interpreter will find in the code (which was on the first line) was interpreted like end of whole code (whole procedure creation).

    I am using SQurreL and changed statement separator like this: session > session properties > SQL > statement separator.

    I hope this will help everyone else who gets in the same problem as me.