Defining the columns of the recordset
This section describes how to define the recordset's columns in the SQL statement. Later sections describe how to define the recordset's rows (records).
Here's the basic SQL syntax to define the columns of a recordset:
SELECT ColumnName1, ColumnName2, ColumnNameX FROM TableName
Note: You can add line breaks, tabs, and other white space to SQL statments to clarify the logic.
If you want to include all the columns of a table in the recordset, you can use the wildcard character *, as follows:
SELECT * FROM TableName
Suppose you're building a search feature for an online employee directory and you want to display only the employees' first name, last name, department, and email address on the results page. If your database table is called EMPLOYEES and the columns containing the information you want are called FIRSTNAME, LASTNAME, DEPARTMENT, and EMAIL, then here's the SQL statement that will produce the desired recordset:
SELECT FIRSTNAME, LASTNAME, DEPARTMENT, EMAIL
FROM EMPLOYEES
Using the sample database that ships with UltraDev, the SQL statement generates the following recordset:
To define the columns of the results recordset in UltraDev:
1 |
In the Recordset dialog box used to define your SQL variables, enter a name for the recordset and choose a connection. |
|
The connection should be to a database you want the user to search. |
2 |
In the SQL box, enter your SELECT statement defining the columns in the recordset. |
|
Here's an example: |
|
|
|