Selecting Data with Raw SQL
If you find that the examples in this tutorial do not work as shown, you may need to install or restore the example database with the "DatabaseLink`DatabaseExamples`" package, as described in "Using the Example Databases".
This carries out the same SELECT statement, but uses a prepared statement. The arguments to the statement are given as the third element of the SQLExecute command. The first argument is placed in the location of the `1` and the second in the location of the `2`.
Column and table names must be wrapped in SQLColumn and SQLTable, respectively. This will ensure they are not quoted as strings. The following selects elements of the ROYALTY column in the ROYSCHED table for which the TITLE_ID column value is BS1011.
If you want to give a sequence of arguments to a prepared statement, you can use SQLArgument. This is described in "SQL Execute: Argument Sequences in SQL-Style Queries".
Many databases offer functions that apply to the results of a SELECT operation. Typical examples are COUNT, MIN, MAX, SUM, and AVG. The documentation for your database will describe the details of the functions that are available. The following examples demonstrate some of these functions.