From: Anon
Subject: How do you work with composite types in CLSQL
Date: 
Message-ID: <quudnUe0FPkr19PZnZ2dnUVZ_smdnZ2d@comcast.com>
For example,

CREATE TYPE inventory_item AS (
    name            text,
    supplier_id     integer,
    price           numeric
);

CREATE TABLE on_hand (
    item      inventory_item,
    count     integer
);

INSERT INTO on_hand VALUES (ROW('fuzzy dice', 42, 1.99), 1000);

SELECT (item).name FROM on_hand WHERE (item).price > 9.99;

SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9.99;


How do you code this in both the object-oriented and functional styles?

From: Anon
Subject: Re: How do you work with composite types in CLSQL
Date: 
Message-ID: <66udnV-seseYMdLZnZ2dnUVZ_sadnZ2d@comcast.com>
Anon <·······@pvofotpmaq.net> wrote in
·····································@comcast.com: 

> 
> For example,
> 
> CREATE TYPE inventory_item AS (
>     name            text,
>     supplier_id     integer,
>     price           numeric
> );
> 
> CREATE TABLE on_hand (
>     item      inventory_item,
>     count     integer
> );
> 
> INSERT INTO on_hand VALUES (ROW('fuzzy dice', 42, 1.99), 1000);
> 
> SELECT (item).name FROM on_hand WHERE (item).price > 9.99;
> 
> SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price >
> 9.99; 
> 
> 
> How do you code this in both the object-oriented and functional
> styles? 
> 
> 

So far what I have found to help me with this is that I have to
code expressions, such as CREATE TYPE, using [...] syntax since
there does not seem to be a (def-type-class) such that you can do this:

(def-type-class inventory-item ()
  ((name        :type string)
   (supplier-id :type integer)
   (price       :type numeric)))

(def-view-class on-hand ()
  ((item        :TYPE inventory-item)
   (count       :type integer)))


With something like this I have been able to generate
some of the SQl but it seems low level:

(sql ["CREATE TYPE"] [inventory-item] [as]
     '(["name text"]
       ["supplier_id integer"]))


Am I going about this the wrong way?

Thanks for any help.
From: Andreas Thiele
Subject: Re: How do you work with composite types in CLSQL
Date: 
Message-ID: <e2oaiu$tt5$02$1@news.t-online.com>
"Anon" <·······@pvofotpmaq.net> schrieb im Newsbeitrag 
·····································@comcast.com...
>
> For example,
>
> CREATE TYPE inventory_item AS (
>    name            text,
>    supplier_id     integer,
>    price           numeric
> );
>
> CREATE TABLE on_hand (
>    item      inventory_item,
>    count     integer
> );
>
> INSERT INTO on_hand VALUES (ROW('fuzzy dice', 42, 1.99), 1000);
>
> SELECT (item).name FROM on_hand WHERE (item).price > 9.99;
>
> SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9.99;
>
>
> How do you code this in both the object-oriented and functional styles?
>

A close and explanatory answer to your quesstion can be found in Chapter 27, 
"Practical : An MP3 Database" from Peter Seibels Book Practical Common Lisp 
which is availbale on the net at http://www.gigamonkeys.com/book. The 
chapter is accessible directly at 
http://www.gigamonkeys.com/book/practical-an-mp3-database.html.

Andreas
From: Andreas Thiele
Subject: Re: How do you work with composite types in CLSQL
Date: 
Message-ID: <e2oal4$ul3$03$1@news.t-online.com>
"Andreas Thiele" <······@nospam.com> schrieb im Newsbeitrag 
····················@news.t-online.com...
>
> "Anon" <·······@pvofotpmaq.net> schrieb im Newsbeitrag 
> ·····································@comcast.com...
>>
>> For example,
>>
>> CREATE TYPE inventory_item AS (
>>    name            text,
>>    supplier_id     integer,
>>    price           numeric
>> );
>>
>> CREATE TABLE on_hand (
>>    item      inventory_item,
>>    count     integer
>> );
>>
>> INSERT INTO on_hand VALUES (ROW('fuzzy dice', 42, 1.99), 1000);
>>
>> SELECT (item).name FROM on_hand WHERE (item).price > 9.99;
>>
>> SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 
>> 9.99;
>>
>>
>> How do you code this in both the object-oriented and functional styles?
>>
>
> A close and explanatory answer to your quesstion can be found in Chapter 
> 27, "Practical : An MP3 Database" from Peter Seibels Book Practical Common 
> Lisp which is availbale on the net at http://www.gigamonkeys.com/book. The 
> chapter is accessible directly at 
> http://www.gigamonkeys.com/book/practical-an-mp3-database.html.
>
> Andreas
>
>

Sorry, I did not notice CLSQL, so forget my answer :(