Subject Re: [ib-support] Problem with SP
Author Helen Borrie
At 02:44 AM 14-10-02 +0000, you wrote:
>Hi there,
>I'm still getting used to SP's, so please excuse this if I'm missing
>something obvious.
>
>I have an SP which adjusts certain stock levels, depending if the
>certain item is 'monitored'.
>In the stock table, there is one field (called 'monitor') which
>holds either 'Y' or 'N' (ie, bool).
>
>I first check to see if the item is 'monitored', and if so, the SP
>continues, otherwise, EXIT; is called.
>
>For some reason it is ALWAYS returning 'N', even when I know
>that 'monitor' has a value of 'Y' (confirmed by viewing data with
>IBExpert).
>
>Here is the SP
>
>CREATE PROCEDURE UPD_STK_QTY (
> S_ID INTEGER
>)
>AS
>DECLARE VARIABLE isMon CHAR(1);
>BEGIN
>SELECT MONITOR FROM STOCK
>WHERE STK_ID = :stk_id
>INTO :isMon;
>
>IF (isMon = 'N') THEN
>BEGIN
> EXCEPTION PART_NOT_MON;
> EXIT;
>END
>
>...
>
>END ^
>
>The exception is ALWAYS being called, irregardless of whether the
>record has 'Y' in the 'monitor' field.
>I have checked the value of S_ID, prior to calling the SP, and I
>have viewed this in SQLMonitor, and can clearly see that the correct
>STK_ID is being queried.
>I'm quite baffled by this. What am I doing wrong here?

Are you sure that the Monitor value is constrained to be upper case? What
happens if you specifically test it case-insensitively, e.g.
..
IF (UPPER(isMon) = 'N') THEN
BEGIN
EXCEPTION PART_NOT_MON;
EXIT;
END

heLen