Re: [CLSQL-Help] subselects in select :from

Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> Tue, 15 Nov 2005 23:41:41 -0700
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
James Bielman wrote:
> It turns out all that's needed to get this working right is to make sure
> the query in FROM gets rendered as a subquery with the proper
> parentheses.  Here's a patch that implements this---I think it would be
> a useful extension to CLSQL, since Lispworks just signals an error.

Yep, setting the *in-subselect* variable is the best way to handle this.
I'll commit your patch.

> (Passes tests with Oracle and SQLite3 on SBCL and Lispworks 4.3.7, not
> sure about others).

I'll test a few other platforms here, but it should pass fine since I
don't recall there being an subselects in the test suite (or they
wouldn't have passed previously). 

>   SELECT * FROM (SELECT * FROM PEOPLE
>                   WHERE name >= 'JAMESJB'
>                   ORDER BY name)
>    WHERE ROWNUM < 10

Yes, that is ugly.

> ..making subselects of this type rather important IMHO.  (The reason I'd
> like an SQL syntax for this is because I eventually want to be able to
> get view class instances back from such a query, but that's another can
> of worms...)

The building of view class instances is a spectacularly deep and wide
can of worms. 

Kevin