Database Connectivity

Under Construction ...

Rapid Development of HTML Database Applications

PowerWeb Server++ APIs and Web Macros let you connect to your database manager to easily perform database queries and tasks such as custom user authentication and access control.

Table of Contents

Introduction
Database Web Macro Sybase and Microsoft SQL Server
IBM DB/2

Introduction

You are not limited to serving static documents with your PowerWeb Server. Through the use of interfaces to popular databases, you can, for example, perform database searches and queries to return information content based on query criteria specified by the user within a fill-in HTML form. With Web Macros, you simply embed the query within your HTML page.

Custom User Authentication and Access Control can also be performed by means of your database, as the examples in the API Reference Manual show.


Database Web Macro

The only obligatory attributes that must be defined are "vendor" and "query". All other attributes have reasonable defaults that will suffice for most situations.

Attributes:

vendor = (sybase/db2)
Defines the vendor. This name is matched against the list specified in the "Config:/Query/Database" object variable directory to determine how to interface to the specified database vendor.

server = (name)
Defines the name of the database server to connect to. If you leave this attribute empty or undefined, the database vendor interface will attempt to connect to a database server running on the same machine as PowerWeb.

userid = (name)
Defines the name of the user to log on to the database with. The special name "PowerWeb" uses the name authenticated by PowerWeb when the client accessed the HTML page.

password = (text)
Defines the password for that user. The special name "PowerWeb" uses the password given by the client when accessing the HTML page.

query = (text)
Defines the query to send to the specified database. Note that some database vendors do not accept tabs or line breaks within queries. The query can be any legitimate database command, including the invocation of a database stored procedure.

maxrows = (number)
The maximum number of rows that will be returned by the database query. Excess rows will be discarded.

heading = (script name/macro) The name of the script to execute, or macro text to execute, to display the column headings.

row = (script name/macro) The name of the script to execute, or macro text to execute, to display each returned result row. If you leave this attribute undefined, along with heading and trailer also, then a default macro is executed which formats your database query result into an HTML table, using the column names returned by the database.

trailer = (script name/macro) The name of the script to execute, or macro text to execute, after all result rows have been retrieved.

error = (script name/macro) The name of the script to execute, or macro text to execute, if an error is encountered processing the database query. Note that returning zero rows is not regarded as an error.

cursor = (name) By default, PowerWeb places all of its database query variables in the object variable directory "Request:/Loop". This can be overridden with the cursor attribute, thus enabling nested SQL queries through naming each level of nesting separately. For example, the outer loop could be named "Loop1" and the inner loop named "Loop2". When specifying the name, you should omit "Request:/" because the variables MUST be located within that location.

live = (yes/no)
Whether to access the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "live".

into = (variable)
Defines the variable in which to place the result of the macro's execution. If omitted or empty, the output is sent with the current document being served.

Examples:
Show a list of all databases available on the server:
<!--#database
   query  = "select * from master..sysdatabases"
   server = "inventory"
   vendor = "sybase"
-->
Database Vendors:
Sybase and Microsoft SQL Server
PowerWeb includes an interface to the Sybase/Microsoft SQL Server. It requires you to have the database DLL "pdblib.dll" on your LIBPATH as well as the LAN server DLL "netapi32.dll".

IBM DB/2 Server
Under construction...