Query the trigger-related views (USER_TRIGGERS, USER_TRIG_COLUMNS) to do any of the following:
Here is a query you can use to identify potentially problematic triggers lacking a WHEN clause: /* File on web: nowhen_trigger.sql */ Analyze argument information A very useful view for programmers is USER_ARGUMENTS. It contains information about each of the arguments of each of the stored programs in your schema. It offers, simultaneously, a wealth of nicely parsed information about arguments and a bewildering structure that is very hard to work with. Here is a simple SQL*Plus script to dump the contents of USER_ARGUMENTS for all the programs in the specified package: /* File on web: desctest.sql */ A more elaborate PL/SQL-based program for displaying the contents of USER_ ARGUMENTS may be found in the show_all_arguments.sp file on the book’s web site. You can also write more specific queries against USER_ARGUMENTS to identify possible quality issues with your code base. For example, Oracle recommends that you stay away from the LONG datatype and instead use LOBs. In addition, the fixed-length CHAR datatype can cause logic problems; you are much better off sticking with VARCHAR2. Here is a query that uncovers the usage of these types in argument definitions: /* File on web: long_or_char.sql */ You can even use USER_ARGUMENTS to deduce information about a package’s program units that is otherwise not easily obtainable. Suppose that I want to get a list of all the procedures and functions defined in a package specification. You will say: “No problem! Just query the USER_PROCEDURES view.” And that would be a fine answer, except that it turns out that USER_PROCEDURES doesn’t tell you whether a program is a function or procedure (in fact, it can be both, depending on how the program is overloaded!). You might instead, want to turn to USER_ARGUMENTS. It does, indeed, contain that information, but it is far less than obvious. To determine whether a program is a function or a procedure, you must check to see if there is a row in USER_ARGUMENTS for that package-program combination that has a POSITION of 0. That is the value Oracle uses to store the RETURN “argument” of a function. If it is not present, then the program must be a procedure. The following function uses this logic to return a string that indicates the program type (if it is overloaded with both types, the function returns “FUNCTION, /* File on web: program_type.sf */ l_overloads overload_aat; BEGIN IF l_overloads.COUNT > 0 RETURN retval; Finally, you should also know that the built-in package, DBMS_DESCRIBE, provides a PL/SQL API to provide much of the same information as USER_ ARGUMENTS. There are differences, however, in the way these two elements handle datatypes.
blog comments powered by Disqus |
|
|
|
|
|
|
|