Stored Procedure Question
Posted in 1997
Topics: Stored Procedures & SPL
Let's consider the following code:
table Payment (
Code Integer not null,
Value Decimal(25,4) not null,
Primary Key (Code) constraint pk_payment
);
Create Procedure xxx()Define nRet Decimal(25,4);
Define dPayCode Integer;
Let dPaycode = 123;
Let nRet = NULL;
Select Value
into nRet
from Payment
Where Code = dPaycode;
If nRet is Null Then
...do this...
Else
... do that...
End If;
End Procedure;
Supose that the table Payment is populated and the Code = 123 exists
in the database.
My problem is that there are some situations, which the variable nRet
is returning with NULL and not with some valid value as we could expect.
What i have found is that using a Foreach clause ( normally unecessary
since the where clause is based on the primary key) solves the problem.
Let nRet = NULL;
Foreach
Select Value
into nRet
from Payment
Where Code = dPaycode
End Foreach
Has anyone passed through the same problem?
I am using Informix Online 5.03.
Thanks,
Gladson M. Russo
gladson@pobox.com