This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: db interface (was Re: Scheme is too complicated)






>When you forget a required keyword, you will get the same error like
>that from a broken SQL query. Where is the difference?

The difference is that you need to generate SQL dynamically, and generating
SQL strings is ugly - very ugly. Generating them using the native language
can be very nice - See the Rogue Wave DB C++ libraries.

>> - Keywords make it easier to trigger various options in sql, and to
>>   setup your query. You don't have to deal with SQLs syntax like makin
>>   sure you don't put a comma after the last value in a list, etc...
>
>Do you expect someone knowing about inner joins without knowing SQL?

Doesn't matter. Everything in Scheme is a Good Thing.

>> - Unified syntax for generating most SQL, would be independent of the
>>   backends incompatabilities.  So like in postgresql, I think the
>>   outer-join syntax is different than some other DBs.
>
>If so, someone should fix that bug in Postgres.

You are in a dream world if you think all the DB vendors have exactly
the same SQL syntax. There are some very subtle differences which will
bite you when you try to aim to be compatible. As well as that, there
are extensions which all the DB vendors support, but in different ways.
Look at the source code to Rogue Wave DB C++ libraries.

> So even if you write a
> wrapper in Guile, which produces SQL, you will not be able to do more
> than SQL lets you doing.

That will still achieve a lot I would say.

>Why do you think that a query becomes easier when you throw away the
grammatical >structure of normal SQL queries?

Partly because SQL is ugly. Partly because SQL needs to be intergrated with
the
host language. Embedded SQL is as ugly as sin. I think if you had used the
Rogue
Wave C++ libraries you would appreciate how nice it is to have some decent
integration between SQL and the host language.

Imagine if you could write something like..

(define (get-orders clientcode)
  (select ((code product) (name product) (code order))
     :where `(and (equal? (code product) (code order))
(equal? (code client) ,clientcode)))))