Chapter 4. Applying the Scale of Resilience to the PL/SQL Code
The containerized Oracle Database instance that was set up in Chapter 2 can now be put to further use. Rather than just discussing PL/SQL code in isolation, I can now apply the scale of resilience and use the results to drive the remediation procedure.
In Chapter 1, you saw the unmodified version of Example 4-1.
Example 4-1. PL/SQL example from Chapter 1
DECLARECURSORc1isSELECTename,empno,salFROMempORDERBYsalDESC;-- start with highest paid employeemy_enameVARCHAR2(10);my_empnoNUMBER(4);my_salNUMBER(7,2);BEGINOPENc1;FORiIN1..5LOOPFETCHc1INTOmy_ename,my_empno,my_sal;EXITWHENc1%NOTFOUND;/* in case the number requested *//* is more than the total *//* number of employees */INSERTINTOtempVALUES(my_sal,my_empno,my_ename);COMMIT;ENDLOOP;CLOSEc1;END;
Applying the scale of resilience, the scores in Table 4-1 were recorded.
| Requirement number | Resilience requirement | Score (0–10) |
|---|---|---|
1 |
Capture all errors and exceptions |
0 |
2 |
Recoverability |
2 |
3 |
Observability |
0 |
4 |
Modifiability |
5 |
5 |
Modularity |
2 |
6 |
Simplicity |
5 |
7 |
Coding conventions |
5 |
8 |
Reusability |
2 |
9 |
Repeatable testing |
2 |
10 |
Avoiding common antipatterns |
0 |
11 |
Schema evolution |
0 |
TOTAL SCORE |
23 |
The following sections take each item in Table 4-1 in turn and explore them in more depth. As part of this, I’ll make some targeted code changes with a view ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access