Skip to content

Commit 7b50d70

Browse files
committed
Fix #103 - Consistent use of Example subchapters
1 parent 458b217 commit 7b50d70

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

docs/4-language-usage/3-dml-and-sql/1-general/g-3120.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ select last_name
2121
where extract(month from hire_date) = extract(month from sysdate);
2222
```
2323

24+
If the `jobs` table has no `employee_id` column and `employees` has one this query will not raise an error but return all rows of the `employees` table as a subquery is allowed to access columns of all its parent tables - this construct is known as correlated subquery.
25+
26+
``` sql
27+
select last_name
28+
,first_name
29+
from employees
30+
where employee_id in (
31+
select employee_id
32+
from jobs
33+
where job_title like '%Manager%'
34+
);
35+
```
36+
2437
## Example (better)
2538

2639
``` sql
@@ -47,23 +60,6 @@ select emp.last_name
4760
where extract(month from emp.hire_date) = extract(month from sysdate);
4861
```
4962

50-
## Example Subquery (bad)
51-
52-
If the `jobs` table has no `employee_id` column and `employees` has one this query will not raise an error but return all rows of the `employees` table as a subquery is allowed to access columns of all its parent tables - this construct is known as correlated subquery.
53-
54-
``` sql
55-
select last_name
56-
,first_name
57-
from employees
58-
where employee_id in (
59-
select employee_id
60-
from jobs
61-
where job_title like '%Manager%'
62-
);
63-
```
64-
65-
## Example Subquery (good)
66-
6763
If the `jobs` table has no `employee_id` column this query will return an error due to the directive (given by adding the table alias to the column) to read the `employee_id` column from the `jobs` table.
6864

6965
``` sql
@@ -75,4 +71,4 @@ select emp.last_name
7571
from jobs j
7672
where j.job_title like '%Manager%'
7773
);
78-
```
74+
```

docs/4-language-usage/3-dml-and-sql/1-general/g-3195.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ select e.employee_id
1818

1919
## Example (good)
2020

21+
Using a wildcard:
22+
2123
``` sql
2224
select e.employee_id
2325
,e.last_name
2426
from employees e
2527
where e.last_name like 'Smith%';
2628
```
2729

28-
## Example (good)
30+
Change to equality operator instead:
2931

3032
``` sql
3133
select e.employee_id

docs/4-language-usage/3-dml-and-sql/3-transaction-control/g-3310.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ end;
6767
/
6868
```
6969

70-
## Example (better)
70+
## Example (best)
7171

7272
(Assuming suitable foreign key relationship exists to allow updating a join.)
7373

docs/4-language-usage/5-exception-handling/g-5040.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ end;
3333
/
3434
```
3535

36-
## Example (exception to the rule)
36+
An exception to the rule where `when others` can be good to log the error and then re-raise it:
3737

3838
``` sql
3939
begin

docs/4-language-usage/8-patterns/3-validating-input-parameter-size/g-8310.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ end department_api;
4949
/
5050
```
5151

52-
## Function call
52+
The exception should be handled where the function is called, like this:
5353

5454
``` sql
5555
...

0 commit comments

Comments
 (0)