Generating SQL strings
Hi, I'm composing what will turn out to be a fairly lengthy SQL statement using the SQL package. I'm using the reader syntax (and in places the functional interface) to construct the query dynamically. When it comes to some constructs that don't appear to be supported by the syntax, such as Common Table Expressions [1] I plan to fall back on string interpolation in order to put generated sub-selects into place. However, once I have an SQL-QUERY object, I haven't found the accessor function to call to get the generated statement, and have fallen back on SLOT-VALUE. (slot-value [select [*] :from [foo]] 'sql::val) ; => "(SELECT * FROM FOO)" Is there a better way for composing SQL that isn't supported by the reader syntax (I tried using SQL-OPERATION and other functions for WITH ... AS but failed). If not, is there a better way for obtaining the string from an SQL-QUERY without sending it to the database? Cheers, Andrew Kirkpatrick [1] http://www.postgresql.org/docs/9.1/static/queries-with.html _______________________________________________ Lisp Hug - the mailing list for LispWorks users lisp-hug@lispworks.com http://www.lispworks.com/support/lisp-hug.html