Lisp HUG Maillist Archive

Single-table joins and the OO interface

I have a view class on a database table, say something like:

(def-view-class frodo-view (...) ((code ...)...)
  (:base-table frodo))

In the db there are pairs of frodos, identifier by 'code, that I want to
find. In functional sql, I can write this and have it work:

(sql:select ["t1" code] ["t2" code] :from '([frodo "t1"] [frodo "t2"])
:where [and [= ["t1" code] "00100"] [= ["t2" code] "93701"]])

But, I can't figure out how to reference my view class in the query rather
than using this lower level stuff; as in this incorrect phrasing:

(sql:select ["t1" code] ["t2" code] :from '([frodo-view "t1"] [frodo-view
"t2"])
 ...)

I'd appreciate some assistance. Thanks...

David E. Young
Bloodhound Software, Inc.
http://bloodhoundinc.com

"For wisdom is more precious than rubies,
and nothing you desire can compare with her."
  -- Prov. 8:11

"But all the world understands my language."
  -- Franz Joseph Haydn (1732-1809)


This email message is for the sole use of the intended recipients(s) and may contain confidential and privileged information of Bloodhound Software, Inc.. Any unauthorized review, use, disclosure is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


Re: Single-table joins and the OO interface

At 11:27 AM -0400 5/11/04, Young, David wrote:
>I have a view class on a database table, say something like:
>
>(def-view-class frodo-view (...) ((code ...)...)
>  (:base-table frodo))
>
>In the db there are pairs of frodos, identifier by 'code, that I want to
>find. In functional sql, I can write this and have it work:
>
>(sql:select ["t1" code] ["t2" code] :from '([frodo "t1"] [frodo "t2"])
>:where [and [= ["t1" code] "00100"] [= ["t2" code] "93701"]])
>
>But, I can't figure out how to reference my view class in the query rather
>than using this lower level stuff; as in this incorrect phrasing:
>
>(sql:select ["t1" code] ["t2" code] :from '([frodo-view "t1"] [frodo-view
>"t2"])
> ...)

I have just been doing ["t1.code"].  Works fine.

Better make sure you're in ANSI SQL mode on your database, because the view class
layer gets pretty unhappy if you're not (with MySQL anyway).

Try turning on SQL recording so you can see what is being sent to the DB.


Updated at: 2020-12-10 08:56 UTC