Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Accessing

Relational
Tam
IBM Santa

Databases
Nguyen
Teresa Laboratory

from
V.
IBM Santa

the
Srinivasan
Teresa

World

Wide

Web

Laboratory

555 Bailey

Avenue

555 Bailey

Avenue

San Jose, CA 95161 minhtam@vnet .ibm. com

San Jose, CA 95161 srini@vnet .ibm. com

Abstract
DB2 WWW With Wide the growing Web (Web), popularity there of the internet systems (DBMS) and the World for access the Web. from
Wsb Browssrs on Multiple Plsfforms m DBZF=WY

Overview

is a fast growing

demand

to database We describe gap between Web, and cess relational pose variable language and SQL and HTML forms

management

here techniques that we invented to bridge the HTML, the standard markup language of the SQL, the DBMS. substitution variable strings thus capabilities variable design Connection An standard query language a flexible that between as between used general HTML result to acpurcrossinput rows We propose mechanism as well enabling substitution

provides SQL

query

output

the application for creation mechanism quick DB2 and WWW

developer of query The been called data a has

to use the full cross-language used in the DB2 from tions WWW struction

of HTML substitution that that enables

Av P----_ [

World Wide Web (Internet)

and reports,

and SQL

for queries

and updates. of a system DBMS

DS212

and implementation

Figure

1: The

World

Wide

Web

easy conapplicato naviby web server that can on (URL), is http: to products be the accessed Web ibm. from using corn. a any other for the home

of applications

access relational

the Web.

end user of these

sees only the forms

for his or her requests points

and resulting

location

world-wide

uniform This

reports.

A user fills out the forms,

and clicks

resource
IBM page and home can

locator
page be existing used

For example, //www. and up-to-date services, as

the URL

gate the forms the application.

and to access the database

as determined

provide

information new well various products as to get

1
The

Introduction
World Wide Web (Web) the and is fast internet the Figure together have in tens has 1 becoming due ubiquitous illustrates using the realized Web, to the its most easy how World that way of accessing interface protocol. are Many enormous to grow connected universities, potential exponentially makes a

regarding

services, from

software the Web support. applications

downloads, public regarding

popular to use

feedback like

matters

graphical

HTTP

product

communication workstations Wide and there since and Web. business is an the continues

Business database retrieval precisely, typically 1. Create 2. Extract access read 3. Format report 1 HTML
markup Web page. page

almost system

always (DBMS) valuable for steps:

require for data. a

a and More DBMS

management of the Web involve

storage

governmental already the

agencies, especially of users years. to on

organizations applications the following fill-in from data access results

organizations already

accessing

internet

of millions in recent itself

an HTMLl user any andlor the form.


(HyperText

form

for

the

user. forms DBMS here). HTML and (both

Typically, the Web

an organization public by

accessible page

inputs necessary update query

HTML from

fill-in the

maintaining

home

1s possible mto

Permission to make digitalhard copy of part or all of this work for personal or classroom use is granted without fee provided that capies are not made or distributed for profit or commercial advantage, the copyright notice, the title of the publication and its date appear, and notice is given that copying is by permission of ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. SIGMOD 96 6/96 Montreal, Canada 0 1996 ACM 0-89791 -794-419610006.. .$3.50

a desirable

Markup language a static of the or

Language) World dynamically Wide

[LEMA95] Web generated and

is

the

description is essentially

every HTML

529

4.

Allow HTML ded So far

for in the in

additional possibly discussion, using reports. our

accesses from we an the

to

the

DBMS

and

3. The

full

power to the

of

HTML input must

(including and result developer. be able the HTML to

the forms use forms. Ideally,

latest must be the

pages,

hyperlinks assumed

embedthat Web To we of the a

versions) available application HTML 4. The must to 5. A the 6. A full

for creating developer editor power

application

have

a visual

Web pages

page

accessed files

URL in the that

is static server access pages for

(i.e.,

to construct of SQL

are merely Web

stored

location). a DBMS, result

to access the relational using a visual to

DBMS query access tool the from (or

implement need the Web

applications create the the

be available the for

including SQL

to dynamically user input pages [CG195]. executable the URL to the Web client. in Section for DBMS from and called The provides

Web

as the dynamic

construct mechanism Web client that into

queries

needed input to the DBMS. the viewing

database protocol common protocol

access.

Indeed,

DBMS. transferring the user) the for variables SQL result the query (i.e., for a report

a standard

creation

of Web (CGI) of any using

gateway
enables from the and

interface
the Web calling server client

CGI

queries) query must HTML 7. Allow forms, reports. We Web layout dard dard To pose stitution in

is accessing form

program syntax, executable pages (The that

recognized Inputs program,

by a Web

mechanism be easy features. for

substituting report

of a SQL result. using and It new

are passed can generate Web detail

the program back at the

to redesign

formats queries

are displayed interface is illustrated a Web and invoke This

calling more One accesses that CGI

CGI

is described in Figure

additional from

(related) the hyperlinks purpose access of the of

HTML in the building a page the the stanstan-

2.3 and building data

4.) that

possibly

embedded for using SQL,

approach a DBMS

application it directly has

is to implement

a stand-alone

program as a the

propose applications paradigm, markup query

a general that which

solution

accesses application

databases Web, and

a URL.

approach

encapsulates relational HTML

HTML, databases and variable SQL,

followinc

disadvantages: programmer details the CGI has to be knowledgeable and the DBMS or programis affected the DBMS datasit less outCGI protocol The in

language language the gap

1. the application of the ming by API. 2. The HTML text and any

[SQL92]. we pro-

bridge

between

interfaces. change

application

program

a flexible, that between as between the

general provides HTML SQL

purpose input result for

substitution variable query HTML substrings output, full and forms The

protocol with logic,

mechanism as well thus

cross-language and rows SQL and

is intermixed programming need features involve

complex making HTML

tructures readable. 3. Since put, with CGI many

enabling

application

developer creation and used

to use the

capabilities applications new output the useful will to produce to newer like HTML Changing changes logic and to the reports, substitution eral (and PERL sively a client-server logic statements SQL known will efforts based exactly be executed might environment they typically on user dynamically what (or before inThe mentation that that enables access and can has communicating and easy to switch HTML versions 3.0 which an apcode ac-

of HTML SQL been

of query updates. for and other REXX between here,

for queries that already

variable genlike and exclu-

it is not

mechanism between ). We and

we describe

is quite purposes HTML

is now even 4. Many have need put how the like against

beginning though

to be introduced. application in SQL these

HTML will variable used called DBMS creates them focus

[GERM94]

plications cess remain little and

be extended

to be used SQL.

database

[WALL91] on HTML above quick

however,

unchanged. or no application

applications to generate execute the DBMS. SQL

cross-language of a system and relational developer and server. These stores and macros run-time may WWW points

substitution in the design DB2 data in files WWW from the forms (called are used within by the DB2

mechanism and impleConnection of applications Web. and macros) to link the The SQL at the same Convarious forms user of for out and

mentioned

has been

statements

easy construction HTML

It is not statements input.

many) user these,

application commands, the Web SQL macro. nection visual and for these the

provides

To implement

applications be significant forms. build a which we Web

the formatting

Embedded the

variables HTML

if one needs We propose large Our feel class solution are of

to write code to generate output a general purpose solution to Web applications following any in that access to characteristics approach

commands

forms Since

get processed engine. HTML and for SQL SQL

DB2 WWW

WWW

a DBMS.

Connection tools DB2 forms,

has the

uses native generation

languages, of HTML An end the the

necessary

building

be used of the and and

creation query.

applications that access a DBMS. New applications must be easy 1. no significant 2. Applications with new shielded from HTML coding must effort be easy versions. changes should

to build,

preferably and enhance must be

be involved. they

applications resulting clicks

sees only reports. to navigate

forms forms

to maintain In addition CGI

his or her requests

A user fills

to the

protocol.

to access the database

as determined

by the application.

530

The Section along Web server.

rest 2, with client

of the how to

the

paper CGI

is

organized architecture

as follows, is passed through described from the

In

<TITLE>DB2 <hl>@ery <p> <P> <FORM

WWW URL URL

Query

</TITLE>

basic variable the CGI

Information</hi>

names application the In Section

are

the Web the using 5, real etc.,

METHOD=

llpostll exe/urlquery string: IJAME=SEARCH!! SIZE= 20> .d2v/report,, >

ACTION=

/cgbinidb2wwwww. enter TYPE= a search text

Section DB2

3 describes scheme. WWW

cross-language 4 that scheme. Connection Web we we In built

variable

Please <INPUT <p> Please to <P> <INPUT search

substitution system, the

describe

Connection, substitution WWW

select for TYPE= VALUE= TYPE= VALUE=

what the

field(s) string above :

cross-language how like

Section

we describe world that for issues

DB2 security,

handles pages,

checkbox yes checkboxlr yes checkbox yes what

NAME= USE_URL CHECKED> CHECKED> URL<br> TITLE1l 1 Title<br> NAME= USE.

multi-lingual while building

need to be addressed the Web. new Section area.

any application work in this our

<IIJPUT

6 describes Finally,

related

<INPUT <P> Please

TYPE= VALUE= select

NAFIE=USE-DESC

I I

relatively conclusions.

in Section

7 we present

>Description field(s) SIZE=3 SELECTED> lon to see in the report:

2
Figure

World
using Web

Wide
the

Web
a typical Internet (a.k.a with

Fundamentals
distributed connect http client to server daemons), using Web the computing systems systems Web http to

<br> <SELECT NAME= DBFIELD VALUE= VALUE= VALUE= url>URL title Title [desc!l>Descript MULTIPLE> <DPTION <OPTION <OPTION </SELECT> <hr> Sho~ <INPUT <INPUT <p> <IIJPUT <INPUT TYPE= TYPE= submit reseti VALUE= VALUE= llSubmit Reset Query> Innutll> SQL statement radio VALUE= VALUE= YES> Yes No radio CHECKED> on output? TYPE= TYPE=

1 illustrates

system executing executing clients protocol. that (i) and

clients servers

browsers) Web servers

Web

(a. k.a

communicate

For the purpose

of designing

applications of

NAKE=SHOWSQL( NAI$IE=SHOWSQL

access a DBMS, how (iii) applications inputs support that the

it is necessary work from on the the a Web

to have knowledge Web, client the (ii) web the for methods

used

to pass

Web in page

to the

server, writing

available

applications 2.1 A Web

create

dynamically. Figure of operations the types images, [GOSL95] might the users server 2: A Sample displaying can actually other video, than and, HTML input Form Note client that (e,g JAVA client data to viewer server start

Steps

in Using
pages that An

a Web
based with enables application, may

Application
consists a user access of a sequence input a certain providing to on interactive from a URL Web of

application to Web All client Web. steps accesses

basically start

the page HTML

to the user. certain to the

accesses a user. to a Web

commurucate

special

of data voice,

lately, such

executable The Web specialized [AD OB90j by the form on can

page the

on the following

therefore, be repeated

consists any number

byte-code screen (e.g.,

programs). to render a Postscript

which

use viewers

of times

in a single

application. client (e.g,, Mosaic, a URL. address at that server of a host to and the 2.2 host with Netscape,

1. A user fires WebExplorer) 2. The (and port. following (a) the URL Web a port The

up a Web and client

is started 5. The the user

if a Postscript a URL). viewing all link over in the on

file is returned the again current resulting by form

uses it to access the which the Web internet server the

on accessing process

uses with

number) Web client

is present

in the URL

chckmg

another

communicate

hypertext HTML An example Figure a Web user

provides

Input HTML 3 shows client. The various which

Variables input how This form The the this HTML contains and variable user, the are used to select user need the form form form to define six is given appears has input input in Figure to 2 and

information: itself, portions the for in of which Web HTML an page are used by the

and on

a user

server (b)

to determine values present

to be returned variables instantiated password client mode). variables a Web page or and if

INPUT

to the client, user provided the URL was Web other other Web

SELECT sections input already for the get types view, a flag. page received display form mechanism input. in the defined

are used INPUT

variables variables tags using to is used the

SELECT SEARCH variables to indicate the variable a list who is

(c)

pa e at the !$ ormation m security server

client, (e.g.,

and an encrypted if the Web in a secure and to client. the Web get input at

NAME parameter. text input and from that the the the

inform-ation are operating

US E-URL, three to set the the DBFIELD to

USE-TITLE, is used

USEDESC user

of searches to enable and finally, Note

can be done, variable Web not variables

server 3. The provided by that 4. The from is shipped Web the

uses the

the Web

URL client

of things viewing about user

SHOWSQL is used to know Web

back

to the

that

client server

parses and

(as in Figure

3) does

performs

appropriate

of setting

merely

531

DB2 Www

Detailed Data Flow


Web Browsw Web Server
!$22W
UR1=/Q14,wWwtmaQohlPiW {%l=@uw8vatw8i%2 j PATHJNFO=m8CDkle> fiD,l OUERY_STfiNG= [va(l=m1be18vat=va1*2 , + HTML,Iwhim * WJ1 w MT

DB2 WWW

DB2 Dalabase

Please select what f$d(s)


URL

to see m the repoil


& PAT!+>NKMu<dks,np, OUSRWRIK: la1wbwaos+ai,2 ) %,POSTM,!kd SW: + ,fwalLw,wa,,4

UR1=!q,.bnldOtil<mzml#e>lrqn [w*!e18w2:VJLw.]

08 Opntmmc{ execule SQL commands Ietn query le$lls +

4 HTMLK$M Iom HIM1(WI lom SOL wefyresult

Figure

3: A sample

Web

Page

points the on will the text the

and

clicks and

orI the finally

various submits

buttons, the Query. values these server

enters by Web The

text clicking

in

Figure

4: The

Data

Flow

Using

the

CGI

Interface

box button

query

named the clicks

submit variable and

client by Web a prethat value to the Submit protocol process that the Web CGI the URL. client will while server In start passing received addition, Web using data Figure 4. where twice other the CGI application new the of into process Web the input and as a separate the user- input along . with sent in the by the to a previous to this from all server to fit the flow In

then users

package screen

as indicated onto the

passes to the for Web

server. the user

These

inputs

are sent in Figure that

using is the sends

client

determined of the server input when

format. has made variables

For examp]e, the

the Select,iohs client

3 the following on the button USE.URL


USE_DESC

to the

(discussed a string QUERY~TRING

section)

is formatted

passed

the user clicks = =


=

named =
=

application The in

environment protocol two program inputs. program different called Note can be is

Query. SEARCH USE. TITLE


DBFIELD

variable. 111! yes title yes


during this with

the

CGI

illustrated scenarios DB2WWW that,

figure, different

are shown is invoked

an executable

DBFIELD passed where a variable are treated is what can which are client multiple this we make made values to the from is

= a Web defined identically. call

des.c client to a list have to a its

SHOWSQL = When variables are Web and value the on the be variable, the When server, the case as the variable since SELECT multiple by the null case string the box user to 3), the where DBFIELD

in Figure in place executable accesses logic from The that

4, any

executable

invoked The cation cation data put.

of DB2WWW. program the HTML being input variable and and and its finally by the run as a CGI from the the the the applithe appliany outis Web CGI variables performs generates CGI client to construct after

a variable

is not

defined Finally, valued

WERYsTRING the

environment including database,

accessing

manipulating

multiple variable to for

selections is attached. [as is as DBFIELD will

output is sent

generated back to the

application

selections Web

DBFIELD Web

collected page applicatio~

by the server completes

is used Web execution.

case in returned above.

Figure

server

shown 2.3 In the (CGI) to is

3
Generation enable dynamic the of Web pages of Web by Web URL. pages, users When of what the CGI The creation can be used in (i.e., the the

Cross-Language Substitution
key a SQL challenge DBMS of SQL these to write is languages. and in in to

Variable
writing In their can to Web applications both simplest can be utilize quite be easily their HTML the forms, complex that HTML
basic

Dynamic order Web specify known to

provides an with as a

common
that that program

gateway

interface

access and

understand HTML

protocol

[CG195] executable an URL a CGI Web

knowledge However, tedious functions.

acquired. and editors advanced

presented program),

contains that

the name

languages order there

application server

executable

implements

Fortunately,

are existing

532

and

SQL

query application

tools

that

can

help to SQL be

to and

greatly SQL. to

reduce Since we continue tools, directly these two

3.1

Variable

Definition section value

Section for one of two (e.g., valued using purposes: (b) to can etc.). section that have

the complexity wanted using we their designed HTML using

of generating developers HTML

HTML and

A DEFINE (a) define be to

can be used strings to

able

assign

variables

and a variable variable,

existing a

development that tying

characteristics

of a variable variable, list

simple and SQL

macro sections

language while variable variable input

a conditional

includes together mechanism. mechanism described defining HTML DBMS The teristics:

Variables which

are defined syntaxz:

in macros

a DEFINE

a cross-language The cross-language the HTML

substitution substitution support for

contains

one or more

define-statements

extends in Section new

variable

the following syntax: %DEFINE I %DEFINE{ [clef

2.2 by as support

providing well as

a mechanism using ways the

define-statement

variables variable

existing

input

in novel

to construct

applications. macro language itself has the following charac-

ine-statementl+ may be one of four types, namely, a list declara-

%3 A define-statement a simple assignment, declaration,

a conditional or an executable

assignment, variable

1. It requires developer forms and

very other SQL

little than for

extra the

effort use and of

by the HTML

application to create the

variable tion. 3.1.1

queries

updates

against

database. 2. It is sufficiently that flexible do not for a variety extensive of Web appli-

Simple variable

Variable assignment name with a variable

Assignment in a macro is a way Variable to

simple

cations logic.

require

programming

associate names (-),

a variable must start by or

with

a value ([A-Z] numb;; Variable

string. of

a letter

[a-zl ) or underscore alphanumeric are case names

followed

3. It is easily fact, another 4. It

portable written

to multiple on one

server system

platforms. works

In

characters sensitive. s ynt ax: varname varname

underscore(-).

a macro system.

as is on

is usable query

with tools

existing

Web

HTML

editors

and

value-string-on-one-line %} a variable that that in variable referenced to varl to get might will be

DBMS A macro

= {value-string-on multiplelines string assigned to client can other or using be variables variables the CGI itself to can be input (as to contain in from well get

contains tied together

number via variable four definition

of

SQL

and

HTML Each

The the

value macro Web

sections macro 1. One macro. 2. One contain or file or

substitution. of sections: that in

references the

defined A variable

typically more to

contains variable and

types

sections variables

can the

mechanism. a value using is in obtain = string the its

be used

define

manipulate

varname as in $ (varname). its are value, also

referenced a

other

portions When any

of a macro)

expression value string required . abc string variable, $. the runthe in at from illustration
in this

more one

SQL SQL report

command statement formats section from section for that the as

sections, well SQL be as the can user. will SQL variables. be

that

each

evaluated the $(var2)

(optional)

variables

user-defined 3. An input 4. An that Each the or are prefix more marked The or lower except that HTML variable HTML

statement. used to get

recursively For example, If $ (varname value a being one

evaluated %DEFINE wants ) to

value. input values report reports

is permitted. the form the

a literal of the with will string result $(b)

of

be the be

value

that input

used

to

then For time. useful user 2 The


document
G G

should evaluated

prefixed $$ (b) to the can

another

generate

from

executing

statements

example, This ways in an

%DEFINE escape to

a =

are constructed section symbol lines of is marked

using by The between

variable with one text Unless not (may are be be of

a reserved and and blocks multiple {

keyword can contain lines %}. may

mechanism unnecessary

be used information (for an

in extremely

% (e.g., text. below, are but certain

%SQL),

hide

application
used for

program
the syntax

enclosed specified keywords case), in represent while

notations are

descriptions

explicitly nested. upper sensitive variables rest of the features features

section

as follows: keyword a description of what is to be

case
the

insensitive
names cases the like names. macro the

UPPERCASE lower-case-with-dashes written

variable special column

case
In the

implicit language

G G G G

[...]

parts

inside

[1

appear

once

or O

not more

at

aH times

database describe also

[...1* - part
A I B choice

inside c1 appear zero


of one of the items

section,

we will

[-.1+ - Partsinside[1 am= oneor moretimes


A or B

in detail using

illustrating

use of these

example

macros.

of this, Circular result Simple default define name 3.1.2 syntax: (a)

see the references in an error. variable values variables of the

example among

application variables

in

Appendix allowed used and access

A). and to set also to the are

In the above cust-inp passed

example,

it is assumed HTML CGI

that input

the variables variables that vari-

are not

andprod-inpare through -clause the

interface.

When

the

assignments HTML the input for necessary

are typically variables, database etc. Assignment ? value-stringl value-s

able where variable able gets that tion

gets evaluated is explained used in the From value variable to the such

at run-time in Section 4.3)

(run-time the vari-

for

evaluation

like

where~ist evaluated where of two _list

definition the that

of whereclause it is clear first the containsecond If the 10100 and following bikes% is a concatenathe

database,

userid,

in turn. conditional to the

definitions,

Conditional varname

Variable = testvar

is a list

variable

strings, cust.inp variable that

ing

a reference

and prod-inp.

tring2

containing CGI input

a reference values = are bikes

(b) (c)

varname varname

= ?

value-string ? {value-stringl-onmultiplelines%l : {value-string2-onmultiplelines%l

cust.inp to the

= testvar

andprod.inp where-clause strings. custld =

the variables evaluate _name

where_list

respectively 10100 = = , AND product 10100 the

LIKE _name

WHERE custid If cust-inp wherelist

AND product first value

(d) The run fined. tuted null, The which with

varname value string (a)

= ? {value-string-onmultiple-lines%2assigned to a conditional on whether and (c) above, iftestvar with other other $(varname) exists variable aredeissubstiand isnot at

LIKE bikes% string of the varito null custid enough strings are and =

timeis with

dependent value-stringl it

variables

able iOiOO

conditionally itself evaluates only to variable evaluation ifthemdividual

evaluates the clause value

In cases

where~ist (the toadddelimlters not ates ables or to null).

list

is intelligent

otherwise value are strings (b) and

is substituted may (d) contain when above, ifthis

valuestring2. variable references is processed. is substituted does not contain $(varname)

The

variable = both and

where-clause 10100. value where turn which there in prod-inp are

therefore the either not

evaluvaridefined

dereferenced

$(varname) $(varname) string

to WHERE custid cust_inp to evaluate null, and

In case both strings _list forces also will

In cases

value-string

value

of where~ist itself the evaluates conditional to the the vari-

any undefined is set to null. 3.1.3 syntax: %LIST A hst with the List

(or null)

variables,

otherwise

evaluate the evaluation

to null null string.

hence This _clause words,

of where In other

evaluates using

Variable

Declaration varname in the DEFINE Multiple will in in turn we can conditions in the for The be value between. have for assigned
QUERY_STRINGis

null clause able 3.1.4 The any values

string.

be no WHERE

in a SQL where-clause. Executable execute

statement

constructed

value-separator variable is declared list to with (%LIST) this the list property. variable can hence example or
OR

section strings Note

Variable feature macro

Declaration allows file and macro. the invocation to it of the

assigned together that to the other the

concatenated references dynamically the delimiter variable


a

variable from the

value-separator and (An


AND

program

passing

value-separator variables delimiters user By from with for

contain

of variables

defined

in the

varying from searches). returned list default clause variables the SQL

is to get

syntax: varname The output Section the error, = %EXEC commandstring gets the code, in set for to printing executed in an SQL if varname. NULL can of variable each HTML report any, If be error time input block there used or (see from is no to with Guide

performing

default, an HTML

a multiply form useful query). together on HTML form.

command-string is encountered including The will variable a detailed Section error be is returned An executable section, 3.2. 1). varname

$ (varname)

variable lists

the comma

(,) as the list SELECT

separator and and portions variables

(the FROM list of from

is particularly of a SQL be used based can

resulting (equivalent

conditional input An

execution

to construct example

clause

undefined). a conditional (see the [D2W95] for

user selections below: %def ine{ %list where .-list

on an HTML

is shown

messages

DB2WWW

Application discussion).

Developers

AND

= ?

where_list custid LIKE = ? WHERE = $(cust_lnp) $(pr-od-lnP)% $(where_list)

3.2 syntax:

SQL %SQL

where_list = ~ ,,product_nme where_ %1 clause

[(sql-section-name)l sql-command iplelines . . . %} 1

any-validon-mult

[ %SqL_REpORT{

534

[ %SqL_FIESSAGE{ %3
A macro each section file may containing against format here) with SQL the

. . . %}

1
SQL SQL A SQL (we sections, command section only may Note SQL exact after with to can for

The printed

HTML out value

text repeatedly names,

contained as each special for

in row report

the

ROW

block Just for row

is as

is fetched. variables the

contain

multiple one

the

column

each block

exactly database,

column for

are available purposes: the

use inside

be executed be of a line block ally tain SQL contain can the SQL and block) The when only HTML section may and/or SQL formats be named a valid command

formatting

or a block and each

format SQL

discuss optionconthat the can string 2.2. A

1. ROW-NUM contains processed, 2. vi contains SQL the query,

current

row

number

being

section line.

a unique

sql-sect on one the

ion-name.

command string and

value

of the

ith

column

retrieved

specified therefore at

by the run-time

section SQL

in the

variables be input block contain

3. v-column-name column retrieved 4. VLIST nating The the is data named by the - contains the values footer, block, have

this

contains if and that of the is any printed

the that

value column

of

the was

determined variables must a SQL

evaluating

column-name query, a string of all which will be

described contain report

in Section SQL

a valid section section

command

is created columns HTML out The

by concateretrieved. text following after all

(%SQL_REPORT (I!SQL-MESSAGE). are executed block)

a SQL

message in the

report

commands report

SQL

sections

ROW rows

once special the

the HTML (HTML

section

(!!HTMLJEPORT

been can be

processed. used the to

variable maximum the special as it


(%ROW

processed All cute report cuted mand HTML 3.2.1 A SQL to

reports

are discussed are named named ction-name)

in Section by an

3.4). exe-

RPT-MAXJtOWS number variable is being block number whether of rows fetched. has all SQL SQL been rows of rows

limit

unnamed SQL by section,

SQL and

sections (xEXECs(?L each

executed SQL

to be printed. After that were all rows result

As seen above, current have row been

command

directive) execute

in the HTML section SQL is execomin the

ROW-NUM contains processed),

number fetched the

a corresponding section.

ROW-NUM contains from the query,

total of

(%EXEC_SqL(sql-se report

directive)

regardless

printed. Section (%SC/LMESSAGE) messages For to allows cus-

SQL
report

Report
block

Block
3.2.2 maybe report SQL written formatting query. inside a SQL section The message of error of a SQL DB2WWW . Input Section section tomization as a result fer to the or warning command. Application be printed details, reMessage of data The format resulting of the

provide the

custom associated

from

section is defined s ynt ax: xSQL_REPORT{ report-headerwith resulting %ROtJ{ column

below:

more

Developers

Guide

[D2W95] (any name from query ext, value with column as each name %1 The form (any valid html before names which before variables SQL ith text) the is any the SQL columns HTML block first for the block row report are text (%ROW of table for This valid variables html text) , 3.3 syntax:

HTML

%HTML.INPUT{ any-valid-html-t -on-multiple-lines ext

any-valid-html-t and row %3 report-f %} The block retrieved. in the SQL section), data are SQL ooterquery report block printed Special for use the be column is

variables

fetched

HTML asking section the HTML for

input user is needed complete Report

form inputs only

directive before when

contains generating user input

the the

HTML query.

is required

is initiated and the header, once report the

to form 3.4

query. Section

is processed, The will report

of the the ROW

s ynt ax: XHTML_REPORT{ any-vali.d-html-t on-multiple-lines ext-

preceding

is fetched. available

inside name

report column named and

[ %EXEC_SQL(sql-section-n=e-or-variable)
any-valid-html-texton-multiple-lines

formatting from the

purposes: of the retrieved SQL query, - is set if a column is retrieved a string names by the that query,

1. Ni contains
2. N.column-name column-name 3. NLIST nating the contains

[ %EXEC-SQL
on-multiple-lines

any-valld-html-text-

is created

by concate-

..

of all the

columns

retrieved.

535

The report form mands When report section to their

HTML form contains to for

report

form

section query text and

contains results. execute

the The SQL

HTML report comDB2

..................................

displaying HTML the

Www

~Application
~
bnirk ,.,

Development

the

System Overview Viih.


SQLquary

execute

SQL
All with

statements mode, text variables the

(%EXECsQL). the in the run-time variable sections HTML report valoverof the

Visual Query Tool

a macro form is printed run-time inputs

is processed as is, values. from settings the

in report HTML the that

>

: :

is processed.

deference

r .

.=

-De-.

.<?

(Note

ues of user ride any

QUERY-STRING DEFINE

default

in the

macro). When tion port name section, an execute %EXEC-SQL all in be SQL command with no SQL HTML secre-

is encountered SQL

in the are in

unnamed the order form.

sections

executed macro. in SQL Figure 5: DB2 W WW System Overview

sequentially, There the can HTML

of appearance one execute SQL When a named lon-narne)

the

at

most

command execute ) is encoun-

report

command tered, SQL The mand enced lowed, tion user time. The directive or the to to the

(%EXECSQL(sql-sect SQL command

in the correspondingly

named 2. <FORM METHOD= post http: [{web-server}] {macro-f {web-server} by web macro application existing be used macros. {cmd} If cmd is either input is report, input section the or report. of macro-file HTML report HTML DB2 WWW the Web input variables If cmd is input, is processed. section input of variserver. variget the HTML the W WW and optional {macro-file} ACTION = [. exe] . .I / /cgi.-bin/db2www ilel/{cmd3 name [?name=valk. of web server This of the file 5 query to

section SQL may at name. select run

(%SQL(sql-section-narne)) name stored time; This for the named in e.g., feature SQL a variable %EXEc5QL($ gets can deference be used to to execute that be

is executed SQL comgets derefer) is al-

section

>
is

(sqlcrnd) to a allow execute

is the system the

as defined name current the

where

$( sqlcrnd) which

SQL secthe end at run

administrator. is the name the DB2 As and of name the WWW Figure SQL

default

command

server. is the by developer. HTML by editors storing Connection illustrates, tools create can new defined

HTML may another

text contain macro

before hyperlinks file. in a SQL command) report

and The

after to other

a from

%ExEc~QL
pages executing SQL section

HTML

results

SQL

command one SQL

section

(each

an application

developer

has exactly table section. for printing substitution 4 Using section these variety DB2 used IBM DBMS in format

are printed section exists then exists, using SQL

in a default in the it SQL is used

if no SQL report out the

If a SQL

section format in the

desired

result

variables

as specified

report

section.

macrofile [?name=val& ables that from

is processed. . . . ] are optional may the be passed Web client to through

DB2
the

WWW
macro and and to

Connection
language build implemented provides The DB2 described Web support that a system to we in the that previous processes a wide is called it can be of variety non-IBM system is using DBMS applications, access built and on a wide as other

Connec-

tion

as a basis macros of WWW to access and on these that 5. using As

See Section ables passed When client db2www and the like (or to the and pass {cmd} and

2.2 for a discussion see Section 2.3 for

of HTML how like an these

we designed

to a CGI a Web the it

application receives program

DB2 WWW. URL it from will the HTML using above) a Web start application values input either or the of In the

DBMS. IBM

system

Connection platforms platforms. DB2WWW shown

(DB2WWW) databases as well The in the executes figure, from client. 2.3.)

server one two exe)

described parameters, server values interface these purpose ) Figure input mode two of will to

above,

non-IBM

db2www. and

as a CGI namely

overview

of the

environment Figure invoked the URL

in is illustrated DB2WWW server

{macro-file} Web their

variables pass (case types our mode ({cmd} the 1. DB2WWW

respectively.

addition, variables the

the CGI

interface

a Web (The

provided earlier from

by a Web in Section page

CGI

interface can be

~UERY.STRING input for between the omitted. in the

is described invoked 1. <~

DB2WWW ways:

standard distinctions necessary is therefore

(case 2. above).

(Knowledge discussion

of any finer is not and to calls input) here two =

an HTML

in one of two

of interfaces

HREF= [{web-server}] {macro-f /cgi-bin/db2wWw[. ilel/{crnd3 [?narne=val&. exe] ..1> /

6 illustrates ({cmd} =

http:

DB2WWW and once

once in the report

report).

536

4.1 When mode,

Macro

Processing is invoked only and earlier report the

in

Input

Mode in the input

of

%EXECSQL

directive are described involves the any and

(the in the SQL

three

types

of execute Executing

SQL a

DB2WWW it processes sections) (described The HTML SQL

on a macro variable

statements SQL

Section following: string to

3.2).

definition input section

sections of the

command

(DEFINE macro tively). (including completely input The ents data strings a variable HTML The output i.e., end. section is, except the form and referenced using variable position its appear mode.

HTML in Sections section and SQL over)

1. Constructing
dereferencing mand string) command. 2. Create If no section result tion ables and is exists, are the for a report SQL

be

executed in the the

(by comSQL

3.1 and

3.3 respecsections are in the

variables preparing

referenced and

and any SQL report

executing

message

sections)

ignored

(skipped

by DB2WWW

for

the

result

of the

SQL for

command. the of SQL the secvariVi, 3.2.1) its out-

report

section

is available a default

variable and these

sections

are

sequences and the are

of define

statem-

being printed.

processed, If

format report

are processed Note that definition

stored not

in a transient side printing value until in a evaluated

however, (Ni, the

a SQL system

structure.

right

hand for

then

appropriate

supplied

of a variable

instantiated etc., inside row of the

N-column-name, in block Section and

is (recursively) input section. in the the same HTML order text any the fact

dereferenced

V-column-name, string each once put 3. Any is or

described ROW data

is evaluated

text in Any

input that

section it occurs from

of the in the

macro macro,

is

retrieved

printed. error handled error or warning by message in executing and defined a SQL printing in the command a warning message error DBMS

DB2WWW HTML for without

processes that that ) will

macros occurs output have ) in the

beginning is output which Any

to input as are of

in an HTML patterns

evaluating string

referenced

variables

a SQL

section, message. 4.3 In

if one exists,

or by printing

$$ (varname (using run-time varname where

their

leading

$ stripped variable

as $ (varname

output.

Runtime a DB2WWW

Variable Application, ways: in 3.1.

Substitution variables can be defined

the $ (varname value; occurs the in the

) syntax) values output of

is substituted a referenced at the exact

in one of three 1, Variable scribed 2. The and hidden <INPUT

assignments in Section

a DEFINE

section

as de-

the string input to the

$ (varname) Since only

occurs macros

in the text

of the HTML from defined HTML undefined to the null formatting example of this 4.2 When type Macro the top

section. bottom,

are processed that were

NAME INPUT 2.2) fields

parameter tags. are set in the These by HTML

of

HTML variables

forms

SELECT in by

variables (or provided are

(described or preset e.g.,

in earlier input

DEFINE

sections definitions) input property SQL an error,

through for an in 3

Section

user

inputs

variables in a HTML is not This

recognized Note used that

forms,

dereferencing

section. it is report A for

NAME= varname VALUE=value-strlng>

TYPE= hidden

variable string. reports. application of use.

merely

evaluates heavily of the

See the

section

System-defined at run-time with

variables the 3.2. 1). of the value until space defined variable priority itself

that values

are from

automatically the SQL

set query

in Appendix

an illustration

results The

(Section

key features hand evaluated the the name input user) in the variables side

DB2WWW are lazy strings the in latest the of the values than using

run-time of variable possible input while the macros from the

variable of variables definitions moment variables giving client values Web ),

Processing
is invoked except than

in Report
in report

Mode
mode, report input part section section. produced in the a SQL SQL SQL SQL of the mode gets In

substitution (the are with the (i.e., defined 4.3.1 As right not

mechanism

evaluation

DB2WWW is similar earlier) here of the report report report

processing (described processed fact all

to the processing the HTML the HTML in the that on the

in the input

unifying HTML the

HTML

rather things here mode section. section too

discussed except is based involves

preceding text present execute execute

section

are applicable in the HTML HTML statement sections sections to the in the Exactly an

the output to this,

higher macro

variable sections.

DEFINE

In addition

processing

processing Each

Lazy
previously (e.g., are they

Substitution described, ZDEFINE dereferenced are need form or report to be time the or the at the Consider a variable varx =. may . . contain $(var2) with the either other

statements and

(%EXEC5QL is processed placing place where HTML SQL the at the

directives). by processing output

one or more the report

variables Variables ues) these HTML not when an HTML

of processing directive in the by

(substituted directly where out report. printed of their example section, HTML

. . . ) their valin of the are or values for

in the output the report

corresponding occurs macro. by type the

referenced

or indirectly

position text which

XEXEC5QL section or sections

input input

of the SQL

variables dereferenced

section

are processed

Variables

execute

statement

is determined

use in XDEFINE below:

%SQL sections.

537

DB2 Runtime

Www
Flow Control

4.4 The since macro The

An DB2

Example WWW have of one Web in the

Application Connection already such page input are named product been on built. has been and Appendix macro in We in this released several the A. using 7. user form report to the the the SQL CGI macro the report further on to queries

November file resulting

1995 on multiple application

platforms

applications

provide

invoking

DB2WWW The clicks in user Figure the on the 7,

mode also gets variables

is shown shown. invoked Query in

Figure the the

selections button

When

Submit

on the

DB2WWW input get input section, the

mode, users
HTTP/HTML Common Gateway Inierfece (CGI) Dynamic SQL

HTML DB2WWW HTML

corresponding it by through reading and any The report

selections the

passed executes

to

interface. and HTML necessary form

variables, performing report. 8. The that hyperlinks

processes resulting contains can result click

Figure

6: DB2

WWW

Runtime

report

to generate in Figure hyperlinks (these

is shown specific further

%defi.ne Xciefine $(x) %1 %define Variable When defined, null. not One but Two

X = Y =

One$(Y)$(Z) Two

data calls

the other

user could

proceed

in further

%FITML_INPuI~

to DB2WWW

or be any

URL).

5
Since Z = Three to variables Y and Yisalready to blank One Two and Z. had

Some
to tackle

Practical
is a fully that Web. various system the for

Issues
supported issues issues are important These character support, IBM during include support product, the in developing support for inwe develpractical

DB2 WWW of the

X contains input Z is still $(X) in Y and will Z. Three.

references section undefined be substituted Note that

opment for large

theHTML Thus,

isprocessed, and there with

applications ternational considerations. DB2WWW on a single every

is equivalent is a leading

objects,

multi-byte

languages,

transaction

and security

character

currently client-server SQL

supports

two transaction one

modes mode in

interaction, in and macro a macro another are will variable multiple on future. any

4.3.2 When input every CGI

HTML D132WWW variables

input is are

variable invoked, to that Figure 4 for as a simple processes the to to it assignment HTML other the simple

processing a number DB2WWW through of the format of HTML the treats the how

which all

statement in (i.e., fails). the for are modes does with internet. a For

is a separate mode occur more in which as if complex of more a a any executed

transaction SQL passed DB2WWW is passed assignment as such. statement input variables values it input list variable can variables is also variables example. is the comma variable using single SQL types scheme rudimentary interactions. complex While measure, server, access this to the The and and over

(auto-commit) statements

transaction statement of of transactions, DB2WWW scheme We transact DB2WWW it works the the ion

a rollback executing current enables linking working in the not the products For Developers

QUERY-STRING interface

environment (see

variable.

var=value-string are passed) 3.1.1) and of a simple to variables, references In using list the variables delimiters 3.1.3). lazy variable variables relating as part substitution processing from the implementing multiple of the addition CGI be parsed

substitution client-server

implementation supporting

variables (Section value-string references can needs passed have end this default (Section The input hiding and web abasisfor

statement Since, can and that possible (See ) (,), the have value hence are

variable

provide DB2

new

security the Web data on

contain to

database, additional Guide

before

be correctly

firewall practical

to provide

secure details

computed.

interface, the using

and

other

considerations

please

see the

as HTML for list

DB2WWW 6 There and

Application

[D2W95].

of Section

2.2 for

variables the list

Related
have been governmental applications to automate process. [GSQL]

Work
various efforts, mostly from tools universities for These creating efforts developagencies, that or simplify to develop databases. the

can be overridden

declaration

mechanism features useful end client-server user, can

and also

the

HTML as like the

Web look ment guage

access

be used features on

application

application

scrollable interactions [D2W95].

cursors,

GSQL language

uses

an intermediate of SQL pure and HTML

declarative HTML. and The SQL,

lanGSQL and

which

is a hybrid

same

application

is simpler

than

538

Query
Enter a search parm)lar field

URL

Information
URLS You do not need TOspecffy the snt!revalue or ibm for a use lb lr,stead

string to query For exzmple

URL
Select Use the above searcn sting In which of the followng

Query

Result
to go to the spectf$ed U RL

any of the followlng

MUR. M Tltls .-l Oescrlpt19n


Note If you unselect all of the abo~e checkboxes all of the U PLs m the database A

be displayed

or, OUIPU1 fleld(s] fo see m the repmt

Please select what a,ddlt]onal .,Description ;

Other pages

OTInferest

Figure

7: Application

Input

Form

Figure

8: Application

Report

Form

the

new

language This

blurs

the

line

between is quite does layout

these

two

lanand full there re-

require languages is primarily

extensive described limited

programming above), to Oracle and

(as the

in

the

scripting language

guages. its

language, of variable and HTML defined

however, substitution capabilities. for

restrictive not allow

PL/SQL

method

databases.

use of SQL ports. WDB definition engine. definitions definition The HTML forms provides report contain layout. and WDB

Furthermore,

7
We Web

Conclusion
have that described of developing access The variable Based data basis on in this stored of this our paper in a new, on the commercial is we between have easy World a novel to use applications solution scheme scheme, called the use Web of the scheme by the fact using on the feature scheme versions our these The scheme well versed is of in in the solution HTML forms accessing In the and and and future, variable for Wide cross HTML designed that has

is no mechanism

custom

of query

method [WDB] file The FDF contains generator two components: and to the WDB table extracts build a run and form time field form fields. the report and files form query (FDF) generator DBMSS. language and and The cross paper are

relational

substitution

from file that

a database contains time forms, the engine the FDFs. the about has

a skeleton about the

SQL.

attributes automatic query, the to build database, the limited While

implemented been power language can already and

a system released ease on of

DB2WWW (in beta general described that by cross full HTML SQL their work macro

run on to

generates and FDF simple the the

already

versions). purpose in scores language for SQL. for form for HTML, and this of

query based forms no a quick

SQL

generator query FDF

substitution to built

and easy way navigate WDB building

be attested being developers interesting future) makes substitution

applications

DB2WWW Web. of its the

information form purpose

inputloutput limited

application The variable current This since in our application most

Besides,

very

report

capabilities. scripting databases. using these languages, can Perl be such ex-

support attractive and native needed substitution no coding from full we

General as Perl tended provides Web quires In

interpreted and calls power Rexx to the

(and feature

[WALL91] to support the full

[G ERM94],

extremely

or Rexx but reof the is

developers system.

of a programming

language languages

we support

languages incremental to learn small of our of and

application extensive Oracles

development programming PL/SQL the

and also knowledge a new from

application mechanism all. fact of data The that SQL in is

developers is rather advantage the input relational for building full and

procedural

interfaces. [PL/SQL], HTML output mechanism the PL/SQL output stream. familiar with a simple for building applications

requires is

at the for

stems the

provided

to send

power report for DBMS. page layout Web

available manipulating plan

stored procedure back For the programmer PL/SQL, way Web to the output new

to the Web CGIS who is already routines HTML

designing

power to

available

library into

provides pages building

results

use DB2WWWS approach

substitution databases

applications.

However,

applications

539

and

processing

engines

other

than

DB2

A
Idef

An
ine{

Example
CELDIAL

Macro

File

References
[ADOB90] ence Manual, 1990.
The UrbanaCommon Champa~gn, Gateway Interface, Unwersztg of

DATABASE= dbtbl = = = =

urldb OR L_ II$FO ? LIKE ? LIKE ? I$(sEARcH)%-11 : %$(sEARcH)x11 : IfII USE_URL .UX1 USE. title USE_DESC description = ? WHERE DBFIELDS TITLE

Adobe

Systems,

Postscript Publishers,

Language ISBN

Refer0-201-

%LIsT L_ II!IFO

Addwon-

Wesley

$(dbtbl) LJIiFO $(dbtbl) L_INFO $(dbtbl) WHERELIST XLIST D2 = = ? ? ,

18127-4, [CG195] Illznozs, 1995. [D2W95]

LIKE
$( L-IIJFO)

L$(SEARCH)%

http://hoohoo.ncsa. (DB2

uiuc.edu/cgi/overview. WWW Connection Home

html, Page, IBM

<br>$(V2)8 <br>$(V3)

D3 x}

Corporatzon,

http://service. 1995.
H.,

so ftware.ibm.com/ pl?/dernos-pdocs/
(0 S/2 2.1 Rexx Handbook, Van

pbin-usa-demos/getobj. wwwdb2dnld.html, [GERM94]


Nostrand

%SQLi
SELECT FROM Select
url, $ (DBFIELDS)

German, Reznhold, Gosling,

$(dbtbl) any <LI> of <A the

$( WHERELIST) . . . to the

ORDER specified

BY

title URL: $(D2) $(D3) %}

ISBN
J., and A White

0-442-01734-0,
McGilton, Paper, H., SUN

1994.
The Java Lan-

%SQL-REPDRT{ <lIL> %ROW{ </UL> x} %) HREF=l$(Vl) >$(Vl)</a>

[GOSL95]
guage

Environment:

Macros ystems,

http://www.javaso javawhitepaper.l [GSQL]


Eng, J.,

ft.com/whitePaper/ .html,
GSQL

1995.
Database Gateway,

NCSA,

%HTMLJNPUT{
<TITLE>DB2 <IMG <Hl>Query <P> <P> <FORM HETHOD=post wwu. <INPUT search checkbox [[checkbox tcheckbox . . . in the string . ..> . ..> . ..> exe/urlquery in which .d2w/report''> VALUE=l\ibll> of the following: F? AME=SEARCHII Enter WWW URL URL a Query </TITLE> iflu>u> URLS . . . SRC=/iconheadldg search

http://www.ncsa. pub/gsql/starthere. [KERN88]


gramming

uiuc.edu/SDG/People/jason/ html, B., 1994. and


Ritchie, D , The C Pro-

Kernighan,
Language,

Information</HI> listed after the query.

Prentzce-Hall

Publishers, Yourself Publtshzng, Web ISBN

ISBN Publishing

O-

131-10163-3, [LEMA95] with HTML 30667-0, [MOSA95] Support,


http://www.ncsa. in

1988. Lemay, 1995. Mosaic Umverszty for X version


Urbana-

L.,

Teach
Sums

ACTIOIi=''/cgi-bin/db2 Search Use the <IIJPUT String: above TYPE= TYPE= TYPE= If

a week,

O-672Form

URL<BR> Title<br> Description :<BR> MULTIPLE> SELECTED> >Description Title

2.0

Fill-Out

<INPUT <INPUT <P> Iiote: <SELECT <OPTION <OPTIOIJ

of Ilhnou,
uiuc.edu/SDG/So

Champaign, ftware/Mosaic/ 1995.

report SIZE=2 a)

?JAME=DBFIELDS14 VALUE=$$ VALUE=$$ <P> TYPE= TYPE= TYPE= TYPE= <HR> pages of interest: <HR> on statement radio radio submiti reset (hidden_ (hidden_b)

Dots/fill-out-forms/overview.html, [PER095] Pero, C., HTML FORMS

TutoriaY,

Unwerstty html, Inc.,

</SELECT> Show SQL <INPUT <IEPUT <INPUT <INPUT </FORM> Other

of Illinoisj 1995. [PL/SQL] [SQL92] ISO/IEC [STE195a]


a World Developers,
63389-2,

Urbana-

Champaign uiuc.edu/ carlosp/cs317/cft. Oracle ISO-ANSI,


Set Guide up for and maintain

output? NAHE=SHOWSQL NAME= SHOWSQL VALUE= Submit Reset VALUE= VALUE=> Query Input> i> YES> No Yes

, http://robotO.ge. (PL/SQL Database 9075, Stein,


Wide

Web Extensions, 1995 Language SQL,


to

VALUE=

http://www.oracle.com, 1992. L.
Web Addzson1995.

. . .

%3 D.,
Site: Wesley (How The
%DEFIIIE{ hidden-a hidden_b = = title description

Information
0-201-

Publishers,
World Wide

ISBN
Web

%} %HTML.REpoRT{

[S TE195b]
Frequently

Stein,
Asked

L.

D.,

(The

Security

<TITLE>DB2

WWW URL Query Result

Query </HI>

Result< .gif>

/TITLE>

Questions,

Technology, [S TR093] guage, x, 1993.

http://www-genome. Stroustrup, B., (The

Massachusetts wi.mit.edu/ faq, 1995. C++

Institute

of

<IMG <HR>

SRC=/iconheadldl

<H1>URL %EXEC.SQL

lfWVW/faqs/www-securityAddisonWall, ISBN Wesley


L.,

Programming

Lan-

<HR> Other pages of interest:

Publishers,

ISBN
PERL,

0-201-12078O Redly

[WALL91] Associates,

(Programming

&

0-937-17564-1,

1991. - A Web Interface to SQL Observatory, http://arch1994.

[WDB] Rasmussen, B., WDB Databases, European Southern http.hq.eso.org/bfrasmus/wdb/wdb.html,

540

You might also like