Hi Family.
I was asked by a user to locate a trigger that accesses a certain table. On the way to finding out, I also needed a query that looks for stored procedures that access a certain table. Here's the query I came up with. (I'm likely re-inventing a wheel already developed by Lester Knutsen.) Note the commented AND clause:
select sp.procname, sp.mode,
sb.datakey, sb.seqno, sb.data
from sysprocedures sp, sysprocbody sb
where sp.procid = sb.procid
-- and sp.procname not like " %" -- Skip built-ins with space in procname
and sb.datakey in ("A", "T") -- Really only need "T"
order by procname, datakey, seqno;
The commented line skips procedures where the first character of the procname is a space. This renders it pretty unusable to users. Similar to the automatic index on a PK constraint (if you didn't create it atop an existing index), so there is no syntax you can use to drop it. I had to add that clause because otherwise it was turning up procs with names like " systdistold" (note the initial space). I have no idea how these are used internally but their existence certainly raised an eyebrow (Spock style. ;-). If anyone is willing to share that knowledge I'm sure the community of Informix geeks would appreciate it.
The next interesting thing is the clause and sb.datakey in ("A", "T"). This is actually from an error I made looking for the text part of sysprocbody and looking for datakey "A" as I did in systrigbody. There were a bunch of procs, even in sysmaster, like these 2:
procname comb_aggrelem
mode d
datakey A
seqno 1
data alter function informix.comb_aggrelem (informix.pointer,informix.poin
ter)
with (add handlesnulls)
procname comb_aggrelemc
mode d
datakey A
seqno 1
data alter function informix.comb_aggrelemc (informix.pointer,informix.poi
nter)
with (add handlesnulls)
Interesting observation: When I tried to see the code using dbschema in a user database to decode the proc it said:
No procedure comb_aggrelem. These procs seem to be supporting aggregates created with the "CREATE AGGREGATE" statement. But how they are used? Well, since I've never used that command it remains mysterious.
Again, anyone able and willing to share these interesting tidbits and how, if at all, we as DBAs can make use of them?
BTW I told my user I got two new scripts out of his question and thanked HIM for bringing it up.
------------------------------
I am pleased to report that I had no problems today.
I had only issues, opportunities, challenges and
valuable learning experiences.
-- Jacob S
------------------------------