Create sql queries using the database items tree, Define url parameters – Adobe Dreamweaver CC 2014 v.13 User Manual

Page 615

Advertising
background image

To the top

To the top

Define parameters in a SQL statement (ColdFusion)

Define parameters in a SQL statement; the default value is the value that the parameter should use if no run-time value is returned.

1. Select a parameter name from the Name pop-up menu.

2. Enter a default value for the parameter in the Default Parameter box, and click OK.

Define parameters in a SQL statement (PHP)

Define parameters in a SQL statement; the default value is the value that the parameter should use if no run-time value is returned.

1. Enter a parameter name in the Name box.

2. Enter a default value for the parameter in the Default Parameter box.

3. Enter a run-time value for a parameter in the Run-time Value box, and click OK.

Create SQL queries using the Database Items tree

Instead of manually typing SQL statements into the SQL box, you can use the Database Item’s point-and-click interface to create complex SQL
queries. The Database Items tree lets you select database objects and link them using the SQL SELECT, WHERE, and ORDER BY clauses. After
you create a SQL query, you can define any variables using the Variables area of the dialog box.

The next two examples describe two SQL statements and the steps for creating them using the advanced Recordset dialog box’s Database Items
tree.

Example: Selecting a table

This example selects the entire contents of the Employees table. The SQL statement defining the query appears as follows:

SELECT * FROM Employees

To create this query, follow these steps.

1. Expand the Tables branch to display all of the tables in the selected database.

2. Select the Employees table.

3. Click the Select button.

4. Click OK to add the recordset to the Bindings panel.

Example: Selecting specific rows from a table and ordering the results

The following example selects two rows from the Employees table, and selects the job type using a variable that you must define. The results are
then ordered by employee name.

SELECT emplNo, emplName

FROM Employees

WHERE emplJob = 'varJob'

ORDER BY emplName

1. Expand the Tables branch to display all of the tables in the selected database; then expand the Employees table to display the individual

table rows.

2. Build the SQL statement as follows:

Select emplNo, and click the Select button.

Select emplName, and click the Select button.

Select emplJob, and click the Where button.

Select emplName, and click the Order By button.

3. Place the insertion point after WHERE emplJob in the SQL text area and type ='varJob' (include the equal sign).

4. Define the variable 'varJob' by clicking the Plus (+) button in the Variables area and entering the following values in the Name, Default

Value, and Run-Time Value columns: varJob, CLERK, Request("job").

5. Click OK to add the recordset to the Bindings panel.

Define URL parameters

URL parameters store retrieved information input by users. Before you begin, make sure you pass a form or URL parameter to the server. After
you define the URL variable, you can use its value in the currently selected page.

608

Advertising
This manual is related to the following products: