About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account

Fetching a Customer's Details With Expansion (SQL)

The customer.dbtex file is created using:

datatooltk --output customer.dbtex --sqldb samples --sqluser sampleuser --sqlpassword sample-passwd --sql "SELECT title, surname, address1, address2, town, county, countries.name AS country, postcode FROM people, countries WHERE surname='Parrot' AND people.country = countries.code"
Alternatively you can use datatooltk-gui to import the data and save it to a file called customer.dbtex.
\documentclass[captions=tableheading]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{datatool}

\DTLloaddbtex{\customer}{customer.dbtex}

\begin{document}

\DTLassign{\customer}{1}{%
  \Surname=surname,%
  \Title=title,%
  \AddressI=address1,%
  \AddressII=address2,%
  \Town=town,%
  \County=county,%
  \Postcode=postcode,%
  \CountryName=country%
}

\begin{tabular}{l}
  \Title\ \Surname\\
  \AddressI\\
  \AddressII\\
  \Town\\
  \County\\
  \Postcode\\
  \CountryName
\end{tabular}

\end{document}

Download sample-xassign-sql.tex or sample-xassign-sql.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs