|
A <Lambda> can also be used
to update a database.
A <Lambda> for an update
operation is declared in the same way as one for a search operation.
For example, in your schemas folder, open SetPrice.xml. This schema is very similar to the
<GetCoffee>
schema created in the previous tutorial section. Open SetPrice-declaration.xml. Note that
the return type is set to
<http://waterken.com/Void>, since an SQL
update statement does not produce a result set. Two parameters are necessary for this update: the
coffee name and price.
A <http://waterken.com/coffeebreak/SetPrice>
resource embodies the authority to update the price of any coffee.
The only difference between an update
<Lambda> and the previously
seen <GetCoffee>
<Lambda> is that an update
<Lambda> wraps an SQL update
resource, instead of an SQL query resource.
For example, open the
<SetPrice> resource at
<revywcgymlra7na6hn5nk5i6bu.xml>.
The <Lambda>'s
type is
<SetPrice>.
The statement link refers to an
<http://waterken.com/sql/update/Statement>.
The price parameter is protected by
an <UnsignedDouble>
guard, and name is unrestricted.
Click
here to view
the representation on your machine. Try setting a price.
This resource is hard to use because the client must enter the coffee name and price. The coffee name
has to correspond exactly to the name in the database. The client cannot see the price before changing
it nor after. We can easily ameliorate this situation by binding the coffee name argument to the
resource. Later in the tutorial we will combine editing and viewing of a coffee price.
The next section describes binding arguments.
|