Subject Re: [ib-support] return value
Author Svein Erling Tysvær
Diko,
there are two kinds of stored procedures - executable and those you select
from. SUSPEND should only be used with selectable SPs, which your SP does
not appear to be.

Another thing is that using IN (<subselect>) is terribly slow and that your
procedure is very likely to get serious performance problems once there
gets a bit of data into your tables. Get used to using EXISTS, which is
much faster. In your case that would be something like

UPDATE REF_MASTER A SET CATEGORY_ID = :DST
WHERE EXISTS(SELECT 1 FROM REF_MASTER B
WHERE A.CONTENT_ID = B.CONTENT_ID
AND B.CATEGORY_ID = :SRC
AND NOT EXISTS (SELECT 1 FROM REF_MASTER C
WHERE B.CONTENT_ID=C.CONTENT_ID
AND C.CATEGORY_ID = :DST))
AND CATEGORY_ID = :SRC;

HTH,
Set