First Guide to SQL Anywhere Studio
PART 2. Getting Results with SQL Anywhere Studio
CHAPTER 10. Building a Dynamic Web Site with PowerDynamo
The basic Dynamo template includes queries as well as formatting and static HTML. PowerDynamo sends embedded queries to Adaptive Server Anywhere, formats the results as defined by the formatting, and sends the formatted results along with any static HTML and text to the Web server, which sends it to the Web client that requested it.
Templates vs Scripts |
In this project you will build a template that includes a query and HTML formatting. It involves the following tasks:
Create the Employee Template with an Embedded Query
Start the Personal Web Server and a Web Browser
View the Output
Embedded queries are stored in the template and are delimited by special HTML comment tags as seen in the following graphic. Dynamo provides wizards to help you create simple templates containing queries and HTML. It is a good idea to familiarize yourself with the tags commonly used in PowerDynamo so that you may later modify your own scripts and customize them to your own needs.
For more information about using Dynamo tags and the DynaScript scripting language see the PowerDynamo User's Guide.
PowerDynamo provides an easy way to build a query and to define formatting for data output with the template wizard.
In this task, you will create a template called Employees that displays basic employee data from the sample database.
Double-click PowerDynamo in the left pane of Sybase Central.
Double-click ASASite.
Double-click the ASASite folder.
Double-click Add Template in the right pane of Sybase Central.
Enter Employees as the name of the Template, and click Next.
Enter a description of the template, such as Employee contact information and click Next.
The descriptions will display as a level-one heading in the Web page you are creating.
You may be asked which connection you wish to use for this template. Select inherited. This indicates that you wish to use the same connection as was used for the root /Site. Click Next
You can either type a SQL statement or use the SQL Query Editor to build one. In this task, you will use the SQL Query Editor
Click Select.
The Edit Query dialog box appears.
Select the Tables tab if it is not already displayed.
Select the employee table by either double clicking on it or by selecting it and clicking Add. Add the department table in the same manner.
Select the Columns tab.
Click the plus sign next to the employee table name to display the available columns.
Select the following columns either by double clicking on them or by selecting the column and clicking the Add button:
emp_lname
emp_fname
street
city
state
zip_code
phone
Open the department table by clicking on the plus sign and select the dept_name column.
The columns appear in the Selected Columns list.
Select the Sort tab. Select the following columns to sort by:
dept_name from the department table
emp_lname from the employee table
emp_fname from the employee table
Select the Test tab.
Click Test to see if the query returns data.
Data appears in the data window, verifying the validity of the query.
Click OK.
Click Next.
Choose Table with Headings as the default HTML format for the data.
Click Finish.
A new template, Employees.stm, appears in the Sybase Central workspace. You will view the resulting document from a Web browser in the next task.
Start the Personal Web Server:
Open the Utilities folder in Sybase Central.
In the right pane of Sybase Central double click the Personal Web Server.
Once the Personal Web Server has been started a small tray icon will appear on the Windows start bar.
Start a Web browser such as Netscape or Microsoft Internet Explorer.
Open the following URL in you Web browser:
http://localhost/ASASite/Employees.stm or http://your machine's name/ASASite/Employees.stm or http://your machine's IP number/ASASite/Employees.stm
If you get an error message in the browser window, double-check the Dynamo configuration.
Another reason for an error may be that you have another Web server loaded on your computer that uses the default port number, 80. You may have to map the ASASite to a port number other than the default. If necessary, see the PowerDynamo User's Guide for information on how to do this. Many users have Web servers on their computers without knowing it.
The document appears in the Web browser window. It displays data in a table format, since you chose Table with Headings as the HTML display format in Task 1. The following graphics illustrate the template content that was generated from the Add Template wizard.
The following graphic illustrates how the above template looks when viewed through a browser: