This function runs an SQL select statement a on the database represented by alias b. Placeholders in the form ¶meterNumber in the statement are replaced by the values of parameters c to j. Characters required for valid syntax (for example, quotes around strings) must already be part of the statement. You can limit the number of returned result rows with l. The value 0 returns an unlimited result set.
The function creates a list for each column of the result set. The list name follows the pattern k:COLUMN_NAME, all in uppercase (see examples). If a list with this name already exists, the function deletes its values.
The function returns the number of received records.
If the result set contains columns of type BLOB, parameter m controls the encoding. Set m to true to write the binary data Base64-encoded to the result lists. Otherwise, the data remains unchanged. If there are no such columns in the result set, the parameter value has no effect.
NOTE:
In addition to the
¶meterNumbernotation, you can also use the notation for prepared statements in the form@parameterNumber:parameterType@. Prefer prepared statements, because they prevent SQL injection attacks. Within prepared statements, parameters replace only single values. You cannot use them to pass value lists forIN, table or column names, operators, sort orders, or complete SQL fragments.
Parameters
Parameter | Description |
|---|---|
a | SQL statement to run. |
b | The database alias. |
c | (optional) Parameter |
d | (optional) Parameter |
e | (optional) Parameter |
f | (optional) Parameter |
g | (optional) Parameter |
h | (optional) Parameter |
i | (optional) Parameter |
j | (optional) Parameter |
k | Prefix for the result lists to create. |
l | (optional) The maximum number of rows to read. Default: |
m | (optional) |
n | (optional) |
o | (optional) |
p | (optional) If |
Examples
Assume a table zipcodes that contains the ZIP codes of Germany (an imaginary 20000 entries).
Parameter a | b | c | d-j | k | l | m | n | o | p | Result |
|---|---|---|---|---|---|---|---|---|---|---|
| testdb | ZIPS | 0 | 20000 | ||||||
| testdb | ZIPS | 0 | true | 20000 |
After running example 1, the function created the list ZIPS:ZIPCODE with the values from column zipcode and the list ZIPS:CITY with the values from column city. For example 2, the list names are ZIPS:ZIP and ZIPS:TOWN.
Parameter a | b | c | d-j | k | l | m | n | o | p | Result |
|---|---|---|---|---|---|---|---|---|---|---|
| testdb | 80689 | ZIPS | 0 | 1 | |||||
| testdb | 80689 | ZIPS | 0 | 1 |
Creates the previously mentioned lists from example 1, each with one element: 80689 and Munich.
Parameter a | b | c | d-j | k | l | m | n | o | p | Result |
|---|---|---|---|---|---|---|---|---|---|---|
| testdb | Bavaria | ZIPS | 0 | 1500 | |||||
| testdb | Bavaria | ZIPS | 0 | 1500 | |||||
| testdb | Bavaria | ZIPS | 0 | Error, because text literals must be enclosed in quotes. |
In the first two cases, creates the previously mentioned lists with the ZIP codes of Bavaria.