home -> developer -> SQL -> tutorial -> GetCoffee

back next

A parameterized query: GetCoffee

To this point, we have only done record fetches on the Coffeebreak database, using a <Record>. To search and update the database, we need parameterized operations. These are implemented using a <http://waterken.com/sql/lambda/Lambda>. A <Record> is used for navigating a database, and a <Lambda> is used for operating on a database.

Definition

Unlike a <Record>, a <Lambda> gives a type to the wrapped SQL resource. For each <Lambda>, you must have an associated schema. The schema defines what operation the <Lambda> performs on the database, and how it is invoked, by providing a <http://waterken.com/script/Declaration>.

For example, the <http://waterken.com/coffeebreak/GetCoffee> resource embodies the authority to search for a <Coffee> by name.

The first step in defining a new <Lambda>, is creating the corresponding <Declaration>.

For example, the <Declaration> for the <GetCoffee> resource is in the file at: www/en-US/waterken.com/coffeebreak/GetCoffee-declaration.xml. Navigate to this file in your file manager.

The <Declaration> declares that the <Lambda> takes one parameter, the coffee name, and returns a <Coffee>. Like with the <Schema> resource editor, seen previously, you can use the file manager to create a skeleton <Declaration> and then fill it out with the desired values.

To complete the definition, a new <Schema> must be created for the resource. The <Schema> must have a branch named 'declaration' with arity <Implied>. The implied value is the corresponding <Declaration>.

For example, open the <GetCoffee> schema editor located at: www/en-US/waterken.com/coffeebreak/GetCoffee.xml. The arity of the 'declaration' branch is set to <Implied>, and the implied value is a link to the previously created <GetCoffee-declaration>.

The next page describes the <Lambda> that implements <GetCoffee>.

top

Copyright 2002 - 2003 Waterken Inc. All rights reserved.

Powered by Waterken Server! Valid XHTML 1.0! Valid CSS!