Commit 582eccb5 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-01-21 12:25:39 by cmiachon] Empty log message

Original author: cmiachon
Date: 2004-01-21 12:25:39+00:00
parent abd64bb3
(* List the item number and description of all bicycles
that currently have an
auction in progress, ordered by item number. *)
(*
Note:
This solution assumes that the current date is 1999-01-31.
*)
let current_date="1999-01-31";;
(* !!! Currently, there is not order by predicate in CQL !!!*)
(* In CQLx *)
<result> select <item_tuple>[!([i]/Itemno) !([i]/Description)]
from i in [items]/Item_tuple
where [i]/Start_date/_ <= current_date
and [i]/End_date/_ >= current_date
;;
(* In CQLp *)
<result> select <item_tuple>[ino desc]
from <items>[items::Item_tuple*] in [items],
<item_tuple>[ ino&Itemno desc&Description _ <start_date>sd <end_date>ed _*] in items
where sd <= current_date and ed >= current_date
;;
(* In XQUERY
<result>
{
for $i in doc("items.xml")//item_tuple
where $i/start_date <= current-date()
and $i/end_date >= current-date()
and contains($i/description, "Bicycle")
order by $i/itemno
return
<item_tuple>
{ $i/itemno }
{ $i/description }
</item_tuple>
}
</result>
*)
(* This type has been automatically generated from tests/cql/R/type-R.dtd by dtd2cduce *)
type Bid_date = <bid_date {||}>[ ( Char )* ];;
type Bid = <bid {||}>[ ( Char )* ];;
type Bid_tuple = <bid_tuple {||}>[ (Userid Itemno Bid Bid_date) ];;
type Bids = <bids {||}>[ Bid_tuple* ];;
type Reserve_price = <reserve_price {||}>[ ( Char )* ];;
type End_date = <end_date {||}>[ ( Char )* ];;
type Start_date = <start_date {||}>[ ( Char )* ];;
type Offered_by = <offered_by {||}>[ ( Char )* ];;
type Description = <description {||}>[ ( Char )* ];;
type Itemno = <itemno {||}>[ ( Char )* ];;
type Item_tuple =
<item_tuple {||}>[
(Itemno Description Offered_by Start_date? End_date?
Reserve_price?)
];;
type Items = <items {||}>[ Item_tuple* ];;
type Rating = <rating {||}>[ ( Char )* ];;
type Name = <name {||}>[ ( Char )* ];;
type Userid = <userid {||}>[ ( Char )* ];;
type User_tuple = <user_tuple {||}>[ (Userid Name Rating?) ];;
type Users = <users {||}>[ User_tuple* ];;
let users : Users =
<users>[
<user_tuple>[<userid>['U01']<name>['Tom Jones']<rating>['B']]
<user_tuple>[<userid>['U02']<name>['Mary Doe']<rating>['A']]
<user_tuple>[<userid>['U03']<name>['Dee Linquent']<rating>['D']]
<user_tuple>[<userid>['U04']<name>['Roger Smith']<rating>['C']]
<user_tuple>[<userid>['U05']<name>['Jack Sprat']<rating>['B']]
<user_tuple>[<userid>['U06']<name>['Rip Van Winkle']<rating>['B']]
];;
let items : Items =
<items>[
<item_tuple>[ <itemno>['1001'] <description>['Red Bicycle'] <offered_by>['U01']
<start_date>['1999-01-05'] <end_date>['1999-01-20'] <reserve_price>['40']]
<item_tuple>[ <itemno>['1002'] <description>['Motorcycle'] <offered_by>['U02']
<start_date>['1999-02-11'] <end_date>['1999-03-15'] <reserve_price>['500']]
<item_tuple>[ <itemno>['1003'] <description>['Old Bicycle'] <offered_by>['U02']
<start_date>['1999-01-10'] <end_date>['1999-02-20'] <reserve_price>['25']]
<item_tuple>[ <itemno>['1004'] <description>['Tricycle'] <offered_by>['U01']
<start_date>['1999-02-25'] <end_date>['1999-03-08'] <reserve_price>['15']]
<item_tuple>[ <itemno>['1005'] <description>['Tennis Racket'] <offered_by>['U03']
<start_date>['1999-03-19'] <end_date>['1999-04-30'] <reserve_price>['20']]
<item_tuple>[ <itemno>['1006'] <description>['Helicopter'] <offered_by>['U03']
<start_date>['1999-05-05'] <end_date>['1999-05-25'] <reserve_price>['50000']]
<item_tuple>[ <itemno>['1007'] <description>['Racing Bicycle'] <offered_by>['U04']
<start_date>['1999-01-20'] <end_date>['1999-02-20'] <reserve_price>['200']]
<item_tuple>[ <itemno>['1008'] <description>['Broken Bicycle'] <offered_by>['U01']
<start_date>['1999-02-05'] <end_date>['1999-03-06'] <reserve_price>['25']]
];;
let bids : Bids =
<bids>[
<bid_tuple>[ <userid>['U02'] <itemno>['1001'] <bid>['35'] <bid_date>['1999-01-07'] ]
<bid_tuple>[ <userid>['U04'] <itemno>['1001'] <bid>['40'] <bid_date>['1999-01-08'] ]
<bid_tuple>[ <userid>['U02'] <itemno>['1001'] <bid>['45'] <bid_date>['1999-01-11'] ]
<bid_tuple>[ <userid>['U04'] <itemno>['1001'] <bid>['50'] <bid_date>['1999-01-13'] ]
<bid_tuple>[ <userid>['U02'] <itemno>['1001'] <bid>['55'] <bid_date>['1999-01-15'] ]
<bid_tuple>[ <userid>['U01'] <itemno>['1002'] <bid>['400'] <bid_date>['1999-02-14'] ]
<bid_tuple>[ <userid>['U02'] <itemno>['1002'] <bid>['600'] <bid_date>['1999-02-16'] ]
<bid_tuple>[ <userid>['U03'] <itemno>['1002'] <bid>['800'] <bid_date>['1999-02-17'] ]
<bid_tuple>[ <userid>['U04'] <itemno>['1002'] <bid>['1000'] <bid_date>['1999-02-25'] ]
<bid_tuple>[ <userid>['U02'] <itemno>['1002'] <bid>['1200'] <bid_date>['1999-03-02'] ]
<bid_tuple>[ <userid>['U04'] <itemno>['1003'] <bid>['15'] <bid_date>['1999-01-22'] ]
<bid_tuple>[ <userid>['U05'] <itemno>['1003'] <bid>['20'] <bid_date>['1999-02-03'] ]
<bid_tuple>[ <userid>['U01'] <itemno>['1004'] <bid>['40'] <bid_date>['1999-03-05'] ]
<bid_tuple>[ <userid>['U03'] <itemno>['1007'] <bid>['175'] <bid_date>['1999-01-25'] ]
<bid_tuple>[ <userid>['U05'] <itemno>['1007'] <bid>['200'] <bid_date>['1999-02-08'] ]
<bid_tuple>[ <userid>['U04'] <itemno>['1007'] <bid>['225'] <bid_date>['1999-02-12'] ]
];;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment