| 1 |
% This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04 |
| 2 |
% Example 95 Constructed Data With Missing (Null) Values |
| 3 |
% Label: "ex:nulldb" |
| 4 |
% arara: pdflatex |
| 5 |
% arara: pdfcrop |
| 6 |
\documentclass[12pt]{article} |
| 7 |
\pagestyle{empty} |
| 8 |
\usepackage{datatool} |
| 9 |
\DTLsetup{default-name=customers} |
| 10 |
% define database: |
| 11 |
\DTLaction{new} |
| 12 |
% add columns in desired order: |
| 13 |
\DTLaction[key=Id]{add column} |
| 14 |
\DTLaction[key=Organisation]{add column} |
| 15 |
\DTLaction[key=Surname]{add column} |
| 16 |
\DTLaction[key=Forename]{add column} |
| 17 |
\DTLaction[key=Email]{add column} |
| 18 |
\DTLaction[key=Age]{add column} |
| 19 |
% 1st row: |
| 20 |
\DTLaction[ |
| 21 |
assign={ |
| 22 |
% Organisation not set |
| 23 |
Id = 1, Email = {[email protected]}, |
| 24 |
Surname = {Parrot}, Forename = {Polly}, Age = 42 |
| 25 |
} |
| 26 |
]{new row} |
| 27 |
% 2nd row: |
| 28 |
\DTLaction[ |
| 29 |
assign={ |
| 30 |
% Age not set |
| 31 |
Id = 2, Organisation = {University of Somewhere}, |
| 32 |
Email = {[email protected]}, Surname = {Canary}, |
| 33 |
Forename = {Mabel} |
| 34 |
} |
| 35 |
]{new row} |
| 36 |
% 3rd row: |
| 37 |
\DTLaction[ |
| 38 |
assign={ |
| 39 |
Id = 3, Organisation = {University of Somewhere}, |
| 40 |
Age = 21, Email = {[email protected]}, Surname = {Zebra}, |
| 41 |
Forename = {Zoë} |
| 42 |
} |
| 43 |
]{new row} |
| 44 |
% 4th row: |
| 45 |
\DTLaction[ |
| 46 |
assign={ |
| 47 |
Id = 4, Organisation = {Zinnia Florestry}, Age = 42, |
| 48 |
Email = {[email protected]}, Surname = {Arara}, |
| 49 |
Forename = {José} |
| 50 |
} |
| 51 |
]{new row} |
| 52 |
% 5th row: |
| 53 |
\DTLaction[ |
| 54 |
assign={ |
| 55 |
% Organisation and Age not set |
| 56 |
Id = 5, Surname = {Duck}, Forename = {Dickie}, |
| 57 |
Email = {[email protected]} |
| 58 |
} |
| 59 |
]{new row} |
| 60 |
% 6th row: |
| 61 |
\DTLaction[ |
| 62 |
assign={ |
| 63 |
% Age not set |
| 64 |
Id = 6, Organisation = {Newt Fellowship}, |
| 65 |
Email = {[email protected]}, Surname = {Axolotl}, |
| 66 |
Forename = {Lizzie} |
| 67 |
} |
| 68 |
]{new row} |
| 69 |
% 7th row: |
| 70 |
\DTLaction[ |
| 71 |
assign={ |
| 72 |
Id = 7, Organisation = {Avian Emporium}, Age =19, |
| 73 |
Email = {[email protected]}, Surname = {Canary}, |
| 74 |
Forename = {Fred} |
| 75 |
} |
| 76 |
]{new row} |
| 77 |
% 8th row: |
| 78 |
\DTLaction[ |
| 79 |
assign={ |
| 80 |
% Age and Surname not set |
| 81 |
Id = 8, Organisation = {Newt Fellowship}, |
| 82 |
Email = {[email protected]}, Forename = {Molgina} |
| 83 |
} |
| 84 |
]{new row} |
| 85 |
% 9th row: |
| 86 |
\DTLaction[ |
| 87 |
assign={ |
| 88 |
% Organisation empty and Age and Email not set |
| 89 |
Id = 9, Organisation = {}, |
| 90 |
Surname = {Mander}, Forename = {Sally} |
| 91 |
} |
| 92 |
]{new row} |
| 93 |
% 10th row: |
| 94 |
\DTLaction[ |
| 95 |
assign={ |
| 96 |
Id = 10, Organisation = {Élite Emporium}, Age = 101, |
| 97 |
Email = {[email protected]}, Surname = {Fant}, |
| 98 |
Forename = {Eli} |
| 99 |
} |
| 100 |
]{new row} |
| 101 |
|
| 102 |
\begin{document} |
| 103 |
Empty values show as a blank. Missing values show as NULL in string columns and 0 in numeric columns. |
| 104 |
|
| 105 |
\DTLaction{display} |
| 106 |
\end{document} |