Hi, here's the solution I had in mind. It's not impeccable though, unless you change the "source LVARCHAR" declaration into "source CHAR(x)" where x is the maximum length of the concatenated datakey 'T' data columns for each relevant stored procedure.
Code:
CREATE FUNCTION "informix".cnt(search LVARCHAR, source LVARCHAR)
RETURNING SMALLINT;
DEFINE i SMALLINT;
DEFINE j SMALLINT;
DEFINE l1 SMALLINT;
DEFINE l2 SMALLINT;
DEFINE nr SMALLINT;
LET nr = 0;
LET l1 = LENGTH(search);
LET l2 = LENGTH(source);
IF l1 > 0 AND l2 >= l1 THEN
FOR i IN (1 TO l2)
IF substr(search,1,1) = substr(source,i,1) THEN
LET j = 2;
IF l1 > 1 THEN
IF l1 - 1 > l2 - i THEN
RETURN nr;
END IF
WHILE j <= l1
IF substr(search,j,1) != substr(source,i+j-1,1) THEN
EXIT WHILE;
END IF
LET j = j + 1;
END WHILE
END IF
IF j > l1 THEN
LET nr = nr + 1;
LET i = i + j - 2;
END IF
END IF
END FOR
END IF
RETURN nr;
END FUNCTION
DOCUMENT '';
Don't know whether this will work absolutely well; I altered there original a little, which was meant to return the first position of a substr in a string. It runs on an IDS 9.2 server and maybe the builtin "substr" function doesn't exist in an IDS 7.x, don't know right now.
But inside a query like yours this stored function can be invoked like:
Code:
AND cnt("temp",s.data) > cnt("with no log",s.data)
As I said there has to be done something more with the 'data' columns since usually stored procedures are written in more than one datarecord (of 256 bytes) in sysprocbody.
Hope this gives any useful hints anyway,
regards
BTW: If you're creating the application in a language with the ability of dynamical memory allocation for variables I think you should build a routine like this one in that application. Everything can be fixed then in a simple way.