In one of my setup, I'm making simple setup for my users, meaning that most of the strings are saved in a data tool DB, and they can retrieve it by activating a command.
So I've created simple hardcoded key-value model in a defined DB. Now I've got an issue with Datatool, as I'd like that my "keys" to be case-insensitive. I don't want to debug in case a user select "sp" or "Sp" instead of "SP". This is simpler for me to spend some time on input validation.
However, my MWE belo is throwing a bunch of error (among others "Undefined sequence"). What am I doing wrong ?
\documentclass{article}
\usepackage{datatool}
\DTLnewdb{dbSemester}
\DTLnewrow{dbSemester}
\DTLnewdbentry{dbSemester}{key}{SP}
\DTLnewdbentry{dbSemester}{value}{Spring semester}
\DTLnewrow{dbSemester}
\DTLnewdbentry{dbSemester}{key}{SA}
\DTLnewdbentry{dbSemester}{value}{Autumn semester}
\newcommand{\getSemester}[1]{%
\DTLfetch{dbSemester}{key}{\MakeUppercase{#1}}{value}
}
\begin{document}
\getSemester{sa}
\getSemester{SP}
\end{document}
Update 20/08/2018
I found some answers here and there, about some formatting of the output produced by DTLfetch, but nothing related to passing a non expandable parameters to the DTLfetch command. I'm starting to believe that this is not poassible to achieve.
Otherwise, I've thought of a potential workaround would be to add the uppercase version inside of the table and to duplicate the entries