The precedence rule sorts out execution precedence when an execution object belonging to one execution class invokes an execution object of another execution class.
The precedence rule states that the execution class of a stored procedure overrides that of a login, which, in turn, overrides that of a client application.
If a stored procedure has a more preferred execution class than that of the client application process invoking it, the precedence of the client process is temporarily raised to that of the stored procedure for the period of time during which the stored procedure runs. This also applies to nested stored procedures.
Exception to the precedence rule: If an execution object invokes a stored procedure with a less preferred execution class than its own, the execution object’s priority is not temporarily lowered.
This example illustrates the use of the precedence rule. Suppose there is an EC2 login, an EC3 client application, and an EC1 stored procedure.
The login’s attributes override those of the client application, so the login is given preference for processing. If the stored procedure has a higher base priority than the login, the base priority of the Adaptive Server process executing the stored procedure goes up temporarily for the duration of the stored procedure’s execution. Figure 4-4 shows how the precedence rule is applied.
Figure 4-4: Use of the precedence rule
What happens when a login with EC2 invokes a client application with EC1 and the client application calls a stored procedure with EC3? The stored procedure executes with the attributes of EC2 because the execution class of a login precedes that of a client application.